Skip to content

Commit

Permalink
feat: add docker in project
Browse files Browse the repository at this point in the history
mateuszszymaniak committed Mar 9, 2024
1 parent 796da58 commit 7fca419
Showing 3 changed files with 39 additions and 1 deletion.
10 changes: 10 additions & 0 deletions .docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM python:3.11
ENV PYTHONUNBUFFERED=1
WORKDIR /app

COPY requirements.txt /app
RUN pip install -r requirements.txt

COPY . .
EXPOSE 8000
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
27 changes: 27 additions & 0 deletions .docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: food_helper
services:
app:
build:
context: ../
dockerfile: .docker/Dockerfile
container_name: web-app
ports:
- "8000:8000"
depends_on:
db:
condition:
service_healthy
volumes:
- .:/usr/app
db:
image: postgres
container_name: postgres_db
environment:
- POSTGRES_DB=${POSTGRES_DB}
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
healthcheck:
test: ['CMD', "pg_isready", "-U", "postgres"]
interval: 5s
timeout: 30s
retries: 6
3 changes: 2 additions & 1 deletion food_helper/settings.py
Original file line number Diff line number Diff line change
@@ -105,7 +105,8 @@
"NAME": env("DB_NAME"),
"USER": env("DB_USER"),
"PASSWORD": env("DB_PASSWORD"),
"HOST": env("DB_HOST"),
"HOST": env("DB_HOST"), # localhost db
# "HOST": "db", docker db
"PORT": env("DB_PORT"),
}
}

0 comments on commit 7fca419

Please sign in to comment.