-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
43 lines (37 loc) · 1.16 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
FROM python:3.7-slim AS builder
WORKDIR /code
RUN set -ex \
&& apt-get update \
&& apt-get install -y \
build-essential \
default-libmysqlclient-dev \
git \
&& rm -rf /var/lib/apt/lists/*
COPY requirements.txt ./requirements.txt
RUN set -ex \
&& python -m venv /venv \
&& bash -c ': \
&& source /venv/bin/activate \
&& set -ex \
&& pip install -r requirements.txt'
COPY . ./
FROM python:3.7-slim
WORKDIR /code
RUN set -ex \
&& apt-get update \
&& apt-get install -y \
build-essential \
default-libmysqlclient-dev \
nginx \
supervisor \
&& rm -rf /var/lib/apt/lists/* \
&& echo "\ndaemon off;" >> /etc/nginx/nginx.conf \
&& rm /etc/nginx/sites-enabled/default \
&& chown -R www-data:www-data /var/lib/nginx \
&& ln -sf /code/nginx-app.conf /etc/nginx/sites-enabled/ \
&& ln -sf /code/supervisor-app.conf /etc/supervisor/conf.d/ \
&& sed -i -e 's#access_log /var/log/nginx/access.log;#access_log off;#' /etc/nginx/nginx.conf
COPY --from=builder /venv /venv
COPY --from=builder /code /code
EXPOSE 80
CMD ["bash", "-c", "source /venv/bin/activate && supervisord -n"]