Skip to content

Commit d3e5d01

Browse files
committed
Add prod container elements
1 parent 22533b2 commit d3e5d01

File tree

3 files changed

+77
-9
lines changed

3 files changed

+77
-9
lines changed

Dockerfile

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,39 @@
1+
# syntax=docker/dockerfile:experimental
12
FROM python:3.6
23

3-
RUN apt-get update \
4-
&& apt-get install -y --no-install-recommends \
4+
EXPOSE 80
5+
RUN apt-get update && apt-get install -y --no-install-recommends \
6+
libsasl2-dev libldap2-dev libssl-dev \
7+
nginx supervisor \
58
&& rm -rf /var/lib/apt/lists/*
9+
RUN mkdir ~/.ssh && echo "Host git*\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
10+
RUN echo 'TLS_REQCERT allow' >> /etc/ldap/ldap.conf
11+
12+
RUN echo "daemon off;" >> /etc/nginx/nginx.conf
13+
COPY etc/nginx.conf /etc/nginx/sites-available/default
14+
COPY etc/supervisor.conf /etc/supervisor/conf.d/app.conf
615

716
WORKDIR /usr/src/app
817
COPY requirements.txt ./
9-
RUN pip3 install -r requirements.txt
10-
COPY . .
1118

12-
RUN python3 ./manage.py initial_setup
13-
RUN python3 ./manage.py load_test_data
19+
ARG IFXURLS_COMMIT=549af42dbe83d07b12dd37055a5ec6368d4b649
20+
ARG NANITES_CLIENT_COMMIT=a11ff96ccb2c888d0d07ac97f27de1153463bf59
21+
ARG IFXUSER_COMMIT=8832f49c218375eb1a2f0a4a4488d33fd76ccbb6
22+
ARG FIINE_CLIENT_COMMIT=b944730dcdf7de9df3479efdeb48848813a14032
23+
ARG IFXBILLING_COMMIT=89382408913ac3a3292493dbcf5fbde1573be120
24+
25+
RUN --mount=type=ssh pip install --upgrade pip && \
26+
pip install 'Django>2.2,<3' && \
27+
pip install django-author==1.0.2 && \
28+
pip install git+ssh://[email protected]/harvardinformatics/ifxurls.git@${IFXURLS_COMMIT} && \
29+
pip install git+ssh://[email protected]/harvardinformatics/nanites.client.git@${NANITES_CLIENT_COMMIT} && \
30+
pip install git+ssh://[email protected]/harvardinformatics/ifxuser.git@${IFXUSER_COMMIT} && \
31+
pip install git+ssh://[email protected]/informatics/fiine.client.git@${FIINE_CLIENT_COMMIT} && \
32+
pip install git+ssh://[email protected]/informatics/ifxbilling.git@${IFXBILLING_COMMIT} && \
33+
pip install ldap3 django_auth_ldap && \
34+
pip install -r requirements.txt
35+
36+
COPY . .
1437

15-
ENV DEBUG=True
38+
CMD ./manage.py collectstatic --no-input && ./manage.py makemigrations && ./manage.py migrate && /usr/bin/supervisord -n
1639

17-
EXPOSE 8000
18-
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]

etc/nginx.conf

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
upstream wsgisock {
2+
# fail_timeout=0 means we always retry an upstream even if it failed
3+
# to return a good HTTP response (in case the Unicorn master nukes a
4+
# single worker for timing out).
5+
6+
server unix:/app/app.sock fail_timeout=0;
7+
}
8+
9+
error_log /dev/stdout info;
10+
11+
server {
12+
listen 80 default_server;
13+
proxy_pass_request_headers on;
14+
underscores_in_headers on;
15+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
16+
proxy_set_header Host $http_host;
17+
client_max_body_size 4000M;
18+
19+
proxy_redirect off;
20+
21+
server_name localhost;
22+
charset utf-8;
23+
24+
location /static {
25+
alias /static;
26+
}
27+
28+
location / {
29+
proxy_pass http://wsgisock;
30+
}
31+
32+
access_log /dev/stdout;
33+
}

etc/supervisor.conf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[program:gunicorn]
2+
command = /usr/local/bin/gunicorn wsgi:application --bind=unix:/app/app.sock --workers=3 --timeout 3600 --log-file -
3+
stdout_logfile=/dev/stdout
4+
stdout_logfile_maxbytes=0
5+
stderr_logfile=/dev/stderr
6+
stderr_logfile_maxbytes=0
7+
8+
[program:nginx]
9+
command = /usr/sbin/nginx
10+
stdout_logfile=/dev/stdout
11+
stdout_logfile_maxbytes=0
12+
stderr_logfile=/dev/stderr
13+
stderr_logfile_maxbytes=0
14+

0 commit comments

Comments
 (0)