chore(docker): add test compose fixtures
This commit is contained in:
+4
-4
@@ -1,10 +1,10 @@
|
||||
API_PORT=3671
|
||||
MONGO_INITDB_ROOT_PASSWORD=pass# esegui 'openssl rand -hex 5' in un terminale e copia qui
|
||||
MONGODB_URI=mongodb://theplug:pass@localhost:27017/theplug?authSource=admin
|
||||
MONGO_INITDB_ROOT_PASSWORD=change-this-mongo-password
|
||||
MONGODB_URI=mongodb://theplug:change-this-mongo-password@localhost:27017/theplug?authSource=admin
|
||||
MONGODB_DB_NAME=theplug
|
||||
REDIS_URL=redis://localhost:6379
|
||||
JWT_SECRET_KEY= # esegui 'openssl rand -hex 20' in un terminale e copia qui
|
||||
JWT_SECRET_KEY=change-this-secret
|
||||
JWT_ALGORITHM=HS256
|
||||
JWT_EXPIRE_MINUTES=30
|
||||
AUTH_USERNAME=admin
|
||||
AUTH_PASSWORD= # esegui 'openssl rand -hex 20' in un terminale e copia qui
|
||||
AUTH_PASSWORD=change-this-password
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
FROM python:3.14-slim
|
||||
|
||||
ENV PYTHONDONTWRITEBYTECODE=1 \
|
||||
PYTHONUNBUFFERED=1 \
|
||||
PYTHONPATH=/app/app
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY pyproject.toml ./
|
||||
|
||||
RUN pip install --no-cache-dir --upgrade pip && \
|
||||
pip install --no-cache-dir \
|
||||
"authlib>=1.6.0" \
|
||||
"fastapi[standard]>=0.135.3" \
|
||||
"motor>=3.7.1" \
|
||||
"pwdlib[argon2,bcrypt]>=0.3.0" \
|
||||
"pydantic>=2.12.5" \
|
||||
"pydantic-settings>=2.13.1" \
|
||||
"pyyaml>=6.0.3" \
|
||||
"redis>=7.4.0"
|
||||
|
||||
COPY app ./app
|
||||
|
||||
EXPOSE 3671
|
||||
|
||||
CMD ["sh", "-c", "fastapi run /app/app/main.py --host 0.0.0.0 --port ${API_PORT:-3671}"]
|
||||
@@ -0,0 +1,80 @@
|
||||
services:
|
||||
app:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.test
|
||||
container_name: theplug-app-test
|
||||
restart: unless-stopped
|
||||
env_file:
|
||||
- .env
|
||||
environment:
|
||||
MONGODB_URI: mongodb://theplug:${MONGO_INITDB_ROOT_PASSWORD}@mongodb:27017/${MONGO_DB:-theplug}?authSource=admin
|
||||
MONGODB_DB_NAME: ${MONGO_DB:-theplug}
|
||||
REDIS_URL: redis://redis:6379
|
||||
API_PORT: ${API_PORT:-3671}
|
||||
DEBUG: "true"
|
||||
depends_on:
|
||||
mongodb:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
ports:
|
||||
- "${API_PORT:-3671}:${API_PORT:-3671}"
|
||||
volumes:
|
||||
- ./example-http-one:/root/example-http-one:ro
|
||||
- ./example-http-two:/root/example-http-two:ro
|
||||
|
||||
mongodb:
|
||||
image: mongo:8.2
|
||||
container_name: theplug-mongodb-test
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
MONGO_INITDB_ROOT_USERNAME: ${MONGO_USER:-theplug}
|
||||
MONGO_INITDB_ROOT_PASSWORD: ${MONGO_INITDB_ROOT_PASSWORD}
|
||||
MONGO_INITDB_DATABASE: ${MONGO_DB:-theplug}
|
||||
ports:
|
||||
- "27017:27017"
|
||||
volumes:
|
||||
- mongodb_test_data:/data/db
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "mongosh --quiet --username ${MONGO_USER:-theplug} --password ${MONGO_INITDB_ROOT_PASSWORD} --authenticationDatabase admin --eval \"db.adminCommand({ ping: 1 }).ok\" | grep 1"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
start_period: 10s
|
||||
|
||||
redis:
|
||||
image: redis:8-alpine
|
||||
container_name: theplug-redis-test
|
||||
restart: unless-stopped
|
||||
command: ["redis-server", "--appendonly", "yes"]
|
||||
ports:
|
||||
- "6379:6379"
|
||||
volumes:
|
||||
- redis_test_data:/data
|
||||
healthcheck:
|
||||
test: ["CMD", "redis-cli", "ping"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
start_period: 5s
|
||||
|
||||
example-http-one:
|
||||
build:
|
||||
context: ./example-http-one
|
||||
container_name: theplug-example-http-one
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "18081:8080"
|
||||
|
||||
example-http-two:
|
||||
build:
|
||||
context: ./example-http-two
|
||||
container_name: theplug-example-http-two
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "18082:8080"
|
||||
|
||||
volumes:
|
||||
mongodb_test_data:
|
||||
redis_test_data:
|
||||
+1
-1
@@ -12,7 +12,7 @@ services:
|
||||
volumes:
|
||||
- mongodb_data:/data/db
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "mongosh --quiet --username ${MONGO_USER:-theplug} --password ${MONGO_PASSWORD:-theplug_dev_password} --authenticationDatabase admin --eval \"db.adminCommand({ ping: 1 }).ok\" | grep 1"]
|
||||
test: ["CMD-SHELL", "mongosh --quiet --username ${MONGO_USER:-theplug} --password ${MONGO_INITDB_ROOT_PASSWORD} --authenticationDatabase admin --eval \"db.adminCommand({ ping: 1 }).ok\" | grep 1"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
FROM python:3.14-slim
|
||||
|
||||
WORKDIR /srv/www
|
||||
|
||||
COPY index.html ./
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
CMD ["python", "-m", "http.server", "8080", "--bind", "0.0.0.0", "--directory", "/srv/www"]
|
||||
@@ -0,0 +1,6 @@
|
||||
services:
|
||||
web:
|
||||
build: .
|
||||
container_name: example-http-one
|
||||
ports:
|
||||
- "18081:8080"
|
||||
@@ -0,0 +1,11 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Example HTTP One</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Example HTTP One</h1>
|
||||
<p>This container serves a static page with Python's http.server.</p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,9 @@
|
||||
FROM python:3.14-slim
|
||||
|
||||
WORKDIR /srv/www
|
||||
|
||||
COPY index.html ./
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
CMD ["python", "-m", "http.server", "8080", "--bind", "0.0.0.0", "--directory", "/srv/www"]
|
||||
@@ -0,0 +1,6 @@
|
||||
services:
|
||||
web:
|
||||
build: .
|
||||
container_name: example-http-two
|
||||
ports:
|
||||
- "18082:8080"
|
||||
@@ -0,0 +1,11 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Example HTTP Two</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Example HTTP Two</h1>
|
||||
<p>This container serves a static page with Python's http.server.</p>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user