Spaces:
Sleeping
Sleeping
feat: add Dockerfile and improve docker-compose configuration
Browse files- Add Dockerfile based on python:3.12-slim for containerizing the API
- Add .dockerignore to exclude unnecessary files from build context
- Switch postgres_data volume to named volume in docker-compose.yaml
- .dockerignore +13 -0
- Dockerfile +13 -0
- docker-compose.yaml +5 -2
.dockerignore
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
venv/
|
| 2 |
+
.env
|
| 3 |
+
__pycache__/
|
| 4 |
+
*.pyc
|
| 5 |
+
*.pyo
|
| 6 |
+
.pytest_cache/
|
| 7 |
+
htmlcov/
|
| 8 |
+
.coverage
|
| 9 |
+
data/
|
| 10 |
+
*.md
|
| 11 |
+
.git/
|
| 12 |
+
.gitignore
|
| 13 |
+
postgres_data/
|
Dockerfile
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.12-slim
|
| 2 |
+
|
| 3 |
+
WORKDIR /app
|
| 4 |
+
|
| 5 |
+
COPY requirements.txt .
|
| 6 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 7 |
+
|
| 8 |
+
COPY app/ ./app/
|
| 9 |
+
COPY ml_model/ ./ml_model/
|
| 10 |
+
|
| 11 |
+
EXPOSE 7860
|
| 12 |
+
|
| 13 |
+
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
|
docker-compose.yaml
CHANGED
|
@@ -6,7 +6,7 @@ services:
|
|
| 6 |
- POSTGRES_USER=postgres
|
| 7 |
- POSTGRES_PASSWORD=postgres
|
| 8 |
volumes:
|
| 9 |
-
-
|
| 10 |
ports:
|
| 11 |
- "5432:5432"
|
| 12 |
pgadmin:
|
|
@@ -15,4 +15,7 @@ services:
|
|
| 15 |
- PGADMIN_DEFAULT_EMAIL=admin@admin.com
|
| 16 |
- PGADMIN_DEFAULT_PASSWORD=root
|
| 17 |
ports:
|
| 18 |
-
- "8080:80"
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
- POSTGRES_USER=postgres
|
| 7 |
- POSTGRES_PASSWORD=postgres
|
| 8 |
volumes:
|
| 9 |
+
- postgres_data:/var/lib/postgresql/data:rw
|
| 10 |
ports:
|
| 11 |
- "5432:5432"
|
| 12 |
pgadmin:
|
|
|
|
| 15 |
- PGADMIN_DEFAULT_EMAIL=admin@admin.com
|
| 16 |
- PGADMIN_DEFAULT_PASSWORD=root
|
| 17 |
ports:
|
| 18 |
+
- "8080:80"
|
| 19 |
+
|
| 20 |
+
volumes:
|
| 21 |
+
postgres_data:
|