-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.prod
76 lines (52 loc) · 1.63 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# -- < BUILDER > ---------------------
FROM python:3.10.2 as builder
# set work directory
WORKDIR /usr/src/app
# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
# install psycopg2 dependencies
# RUN apk update \
# && apk add postgresql-dev gcc python3-dev musl-dev
# lint
# RUN pip install flake8==3.9.2
RUN pip install --upgrade pip
RUN pip install --upgrade setuptools
COPY . .
# RUN flake8 --ignore=E501,F401 .
# -- < Final > -----------------------
FROM python:3.10.2
RUN apt-get update
RUN apt-get install -y netcat
# -- This should be installed with poetry, fix later TODO
RUN pip install gunicorn
# ------------------------------------
# create the app user
RUN addgroup --system vsf && adduser --system vsf --ingroup vsf
# # create directory for the app user
# RUN mkdir -p /home/vsf
# create the appropriate directories
ENV HOME=/home/vsf
ENV APP_HOME=/home/vsf/web
RUN mkdir $APP_HOME
RUN mkdir $APP_HOME/staticfiles
WORKDIR $APP_HOME
# Install more dependencies
COPY ./requirements.txt .
RUN pip install -r requirements.txt --no-cache-dir
# RUN apt-get update && apt-get install libpq
COPY ./entrypoint.prod.sh .
RUN sed -i 's/\r$//g' $APP_HOME/entrypoint.prod.sh
RUN chmod +x $APP_HOME/entrypoint.prod.sh
COPY . $APP_HOME
# chown all the files to the app user
RUN chown -R vsf:vsf $APP_HOME
# Install project
RUN poetry config virtualenvs.create false --local
RUN poetry install && rm -rf ~/.cache/pypoetry/{cache,artifacts}
# change to the app user
USER vsf
# Add local executables
ENV PATH=${PATH}:$HOME/.local/bin
# run entrypoint.prod.sh
ENTRYPOINT ["/home/vsf/web/entrypoint.prod.sh"]