Skip to content

Commit fabddca

Browse files
committed
New Dockerfile
1 parent 6dd9fc2 commit fabddca

File tree

3 files changed

+48
-6
lines changed

3 files changed

+48
-6
lines changed

.dockerignore

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
__pycache__/
2+
3+
4+
# Django stuff
5+
*.log
6+
local_settings.py
7+
db.sqlite3
8+
db.sqlite3-journal
9+
static
10+
11+
# Environment
12+
.env
13+
.env*
14+
.venv
15+
venv/

Dockerfile

+30-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,35 @@
1-
FROM python:3.10
1+
FROM python:3.13-slim AS builder
2+
3+
RUN mkdir /app
4+
5+
WORKDIR /app
6+
7+
ENV PYTHONDONTWRITEBYTECODE=1
8+
ENV PYTHONUNBUFFERED=1
9+
10+
RUN pip install --upgrade pip
11+
COPY requirements.txt /app/
12+
COPY requirements/ /app/
13+
RUN pip install --no-cache-dir -r requirements.txt
14+
15+
FROM python:3.13-slim
16+
17+
RUN useradd -m -r appuser && \
18+
mkdir /app && \
19+
chown -R appuser /app
20+
21+
COPY --from=builder /usr/local/lib/python3.13/site-packages/ /usr/local/lib/python3.13/site-packages/
22+
COPY --from=builder /usr/local/bin/ /usr/local/bin
223

324
WORKDIR /app
425

5-
COPY requirements/ requirements/
6-
COPY requirements.txt .
7-
RUN pip install -r requirements.txt
26+
COPY --chown=appuser:appuser . .
27+
28+
ENV PYTHONDONTWRITEBYTECODE=1
29+
ENV PYTHONUNBUFFERED=1
30+
31+
RUN chmod +x /app/entrypoint.prod.sh
832

9-
COPY . .
33+
EXPOSE 8000
1034

11-
CMD ["gunicorn", "--workers", "4", "--bind", "unix:/app/asgi.sock", "config.asgi:application"]
35+
CMD ["/app/entrypoint.prod.sh"]

entrypoint.prod.sh

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
python manage.py collectstatic --noinput
2+
python manage.py migrate --noinput
3+
python -m gunicorn --bind 0.0.0.0:8000 --workers 4 config.asgi:application

0 commit comments

Comments
 (0)