-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
31 lines (24 loc) · 844 Bytes
/
Dockerfile
File metadata and controls
31 lines (24 loc) · 844 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# Dockerfile
FROM python:3.11-slim
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
WORKDIR /app
# Install system deps so pg_isready and psycopg2 can work
RUN apt-get update && apt-get install -y \
gcc \
libpq-dev \
postgresql-client \
&& rm -rf /var/lib/apt/lists/*
# Python deps
COPY requirements.txt /app/
RUN pip install --no-cache-dir -r requirements.txt
# Copy project
COPY . /app/
# sensible defaults (can be overridden by docker-compose env)
ENV DATABASE_HOST=db
ENV DATABASE_PORT=5432
ENV POSTGRES_DB=mydb
ENV POSTGRES_USER=postgres
ENV POSTGRES_PASSWORD=123
# Wait for DB, run migrations, then start server
CMD ["sh", "-c", "until pg_isready -h \"$DATABASE_HOST\" -p \"$DATABASE_PORT\"; do echo 'Waiting for DB...'; sleep 1; done; python manage.py migrate --noinput; python manage.py runserver 0.0.0.0:8000"]