-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.prod
52 lines (39 loc) · 1.71 KB
/
Dockerfile.prod
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# Use an official Python runtime as a parent image
FROM python:3.12-slim-bookworm
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
ENV DJANGO_SETTINGS_MODULE=ferozfaiz.settings
ENV PYTHONPATH=/app/ferozfaiz:$PYTHONPATH
# {{ with secret "kv/data/django_token" }}
ENV VAULT_ADDR={{ .Data.data.VAULT_ADDR }}
ENV VAULT_TOKEN={{ .Data.data.VAULT_TOKEN }}
# {{ end }}
# Set work directory
WORKDIR /app
COPY ./django/requirements.txt /app/
# psycopg2 dependencies otherwise it fails to install with error: pg_config executable not found
# RUN apt-get update && apt-get install -y libpq-dev gcc python3-dev musl-dev
RUN apt-get update && apt-get install -y --no-install-recommends gcc libpq-dev && \
rm -rf /var/lib/apt/lists/*
RUN pip install --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
ENV ENVCONSUL_VERSION 0.13.2
RUN apt-get update && apt-get install -y wget unzip \
&& wget https://releases.hashicorp.com/envconsul/${ENVCONSUL_VERSION}/envconsul_${ENVCONSUL_VERSION}_linux_amd64.zip \
&& unzip envconsul_${ENVCONSUL_VERSION}_linux_amd64.zip -d /usr/local/bin \
&& chmod +x /usr/local/bin/envconsul \
&& rm -rf envconsul_${ENVCONSUL_VERSION}_linux_amd64.zip \
&& apt-get remove -y wget unzip \
&& apt-get autoremove -y \
&& apt-get clean
# Copy project
COPY ./django/ /app/
RUN chmod +x /app/update_cert.sh /app/start_app.sh
# Collect static files
RUN envconsul -config=/app/envconsul-config.hcl -- python ferozfaiz/manage.py collectstatic --noinput
# Application port
EXPOSE 8000
# Run Gunicorn
# CMD gunicorn ferozfaiz.wsgi:application --bind 0.0.0.0:8000
CMD ["envconsul", "-config=/app/envconsul-config.hcl", "--", "/app/start_app.sh", "prod"]