-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathDockerfile
61 lines (51 loc) · 1.77 KB
/
Dockerfile
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
FROM python:3.9-slim
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
USER=calitp
# create non-root $USER and home directory
RUN useradd --create-home --shell /bin/bash $USER && \
# setup $USER permissions for nginx
mkdir -p /var/cache/nginx && \
chown -R $USER /var/cache/nginx && \
mkdir -p /var/lib/nginx && \
chown -R $USER /var/lib/nginx && \
mkdir -p /var/log/nginx && \
chown -R $USER /var/log/nginx && \
touch /var/log/nginx/error.log && \
chown $USER /var/log/nginx/error.log && \
touch /var/run/nginx.pid && \
chown -R $USER /var/run/nginx.pid && \
# setup directories and permissions for Django and gunicorn
mkdir -p /home/$USER/app/config && \
mkdir -p /home/$USER/app/run && \
mkdir -p /home/$USER/app/static && \
chown -R $USER /home/$USER && \
# install server components
apt-get update && \
apt-get install -qq --no-install-recommends gettext nginx && \
# install git for use when installing dependencies from VCS (https://pip.pypa.io/en/stable/topics/vcs-support/)
apt-get install -qq --no-install-recommends git
# enter app directory
WORKDIR /home/$USER/app
# switch to non-root $USER
USER $USER
# install python dependencies
COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt
# copy config files
COPY gunicorn.conf.py gunicorn.conf.py
COPY manage.py manage.py
# overwrite default nginx.conf
COPY nginx.conf /etc/nginx/nginx.conf
# update PATH for local pip installs
ENV PATH "$PATH:/home/$USER/.local/bin"
# copy source files
COPY bin/ bin/
COPY benefits/ benefits/
# ensure $USER can compile messages in the locale directories
USER root
RUN chmod -R 777 benefits/locale
USER $USER
# configure container executable
ENTRYPOINT ["/bin/bash"]
CMD ["bin/start.sh"]