Skip to content

Commit c77b25e

Browse files
committed
Add nginx
1 parent 4a963f5 commit c77b25e

File tree

4 files changed

+68
-4
lines changed

4 files changed

+68
-4
lines changed

Dockerfile

+21-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
ARG AZLINUX_BASE_VERSION=master
22

33
# Base stage with python-build-base
4-
FROM quay.io/cdis/python-build-base:${AZLINUX_BASE_VERSION} as base
4+
FROM quay.io/cdis/python-build-base:${AZLINUX_BASE_VERSION} AS base
55

66
# Comment this in, and comment out the line above, if quay is down
77
# FROM 707767160287.dkr.ecr.us-east-1.amazonaws.com/gen3/python-build-base:${AZLINUX_BASE_VERSION} as base
@@ -22,7 +22,7 @@ RUN groupadd -g 1000 gen3 && \
2222

2323

2424
# Builder stage
25-
FROM base as builder
25+
FROM base AS builder
2626

2727
USER gen3
2828

@@ -49,6 +49,24 @@ FROM base
4949
COPY --from=builder /venv /venv
5050
COPY --from=builder /$appname /$appname
5151

52+
# install nginx
53+
RUN yum install nginx postgresql-devel -y
54+
55+
# allow nginx to bind to port 80
56+
RUN setcap 'cap_net_bind_service=+ep' /usr/sbin/nginx
57+
58+
# chown nginx directories
59+
RUN chown -R gen3:gen3 /var/log/nginx
60+
61+
# pipe nginx logs to stdout and stderr
62+
RUN ln -sf /dev/stdout /var/log/nginx/access.log && ln -sf /dev/stderr /var/log/nginx/error.log
63+
64+
# create /var/lib/nginx/tmp/client_body to allow nginx to write to fence
65+
RUN mkdir -p /var/lib/nginx/tmp/client_body
66+
RUN chown -R gen3:gen3 /var/lib/nginx/
67+
68+
# copy nginx config
69+
COPY ./deployment/nginx/nginx.conf /etc/nginx/nginx.conf
5270

5371
# Switch to non-root user 'gen3' for the serving process
5472
USER gen3
@@ -60,4 +78,4 @@ ENV PYTHONUNBUFFERED=1 \
6078

6179
WORKDIR /var/www/${appname}
6280

63-
CMD ["gunicorn", "-c", "/peregrine/deployment/wsgi/gunicorn.conf.py"]
81+
CMD ["/peregrine/dockerrun.bash"]

deployment/nginx/nginx.conf

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
user gen3;
2+
worker_processes auto;
3+
error_log /var/log/nginx/error.log notice;
4+
pid /var/lib/nginx/nginx.pid;
5+
6+
# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
7+
include /usr/share/nginx/modules/*.conf;
8+
9+
events {
10+
worker_connections 1024;
11+
}
12+
13+
http {
14+
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
15+
'$status $body_bytes_sent "$http_referer" '
16+
'"$http_user_agent" "$http_x_forwarded_for"';
17+
18+
access_log /var/log/nginx/access.log main;
19+
20+
sendfile on;
21+
tcp_nopush on;
22+
keepalive_timeout 65;
23+
types_hash_max_size 4096;
24+
25+
include /etc/nginx/mime.types;
26+
default_type application/octet-stream;
27+
28+
# Load modular configuration files from the /etc/nginx/conf.d directory.
29+
# See http://nginx.org/en/docs/ngx_core_module.html#include
30+
# for more information.
31+
include /etc/nginx/conf.d/*.conf;
32+
33+
server {
34+
35+
listen 80;
36+
server_name localhost;
37+
38+
location / {
39+
proxy_pass http://127.0.0.1:8000;
40+
proxy_set_header Host $host;
41+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
42+
}
43+
}
44+
}

deployment/wsgi/wsgi.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
sys.path.append("/var/www/peregrine/")
44
sys.path.append("/peregrine/")
5-
from wsgi import app as application
5+
from peregrine.api import app as application

dockerrun.bash

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
nginx
2+
gunicorn -c /peregrine/deployment/wsgi/gunicorn.conf.py

0 commit comments

Comments
 (0)