-
Notifications
You must be signed in to change notification settings - Fork 31
/
Dockerfile
61 lines (48 loc) · 1.79 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
# Create the "base" stage
FROM python:3.7-buster as base
COPY requirements.txt start-server.sh /opt/app/
COPY vuln_django/ /opt/app/vuln_django/vuln_django
COPY static/ /opt/app/vuln_django/static
COPY templates/ /opt/app/vuln_django/templates
COPY polls/ /opt/app/vuln_django/polls
COPY manage.py /opt/app/vuln_django/
RUN pip install -r /opt/app/requirements.txt
# Create a "micro" stage to run as a gunicorn container
FROM base as micro
ARG SERVER_PORT=8010
ENV SERVER_PORT=${SERVER_PORT}
EXPOSE ${SERVER_PORT}:${SERVER_PORT}
RUN apt-get update && \
apt-get install -y --no-install-recommends \
netcat
WORKDIR /opt/app/vuln_django
CMD exec gunicorn vuln_django.wsgi --bind 0.0.0.0:${SERVER_PORT} --workers 3
# Create a "dev" stage as the default final build target.
# - Includes sqlite and nginx
# - Runs data migrations and seeds poll data
FROM base as dev
ARG SERVER_PORT=8020
ARG DJANGO_SUPERUSER_USERNAME=admin
ARG DJANGO_SUPERUSER_PASSWORD=adminpassword
ENV SERVER_PORT=${SERVER_PORT}
ENV DJANGO_SUPERUSER_USERNAME=${DJANGO_SUPERUSER_USERNAME}
ENV DJANGO_SUPERUSER_PASSWORD=${DJANGO_SUPERUSER_PASSWORD}
ENV DJANGO_SUPERUSER_EMAIL=${DJANGO_SUPERUSER_EMAIL}
EXPOSE ${SERVER_PORT}:${SERVER_PORT}
WORKDIR /opt/app
RUN apt-get update && \
apt-get install -y --no-install-recommends \
nginx \
vim \
less
COPY ./nginx.default /etc/nginx/sites-available/default
RUN ln -sf /dev/stdout /var/log/nginx/access.log \
&& ln -sf /dev/stderr /var/log/nginx/error.log
RUN chown -R www-data:www-data /opt/app \
&& python vuln_django/manage.py migrate
RUN python vuln_django/manage.py createsuperuser --no-input \
&& chown -R www-data:www-data /opt/app \
&& python vuln_django/manage.py seed polls --number=5
STOPSIGNAL SIGINT
CMD ["/opt/app/start-server.sh"]