Skip to content

Commit d66e42a

Browse files
committed
Add nginx python base image
1 parent 138591a commit d66e42a

File tree

4 files changed

+9
-98
lines changed

4 files changed

+9
-98
lines changed

Dockerfile

+6-49
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,23 @@
11
ARG AZLINUX_BASE_VERSION=master
22

3-
# Base stage with python-build-base
4-
FROM quay.io/cdis/python-build-base:${AZLINUX_BASE_VERSION} AS base
3+
FROM quay.io/cdis/python-nginx-al:${AZLINUX_BASE_VERSION} AS base
54

6-
# Comment this in, and comment out the line above, if quay is down
7-
# FROM 707767160287.dkr.ecr.us-east-1.amazonaws.com/gen3/python-build-base:${AZLINUX_BASE_VERSION} as base
5+
# FROM 707767160287.dkr.ecr.us-east-1.amazonaws.com/gen3/python-nginx-al2:feat_python-nginx AS base
86

97
ENV appname=peregrine
10-
ENV POETRY_NO_INTERACTION=1 \
11-
POETRY_VIRTUALENVS_IN_PROJECT=1 \
12-
POETRY_VIRTUALENVS_CREATE=1
138

149
WORKDIR /${appname}
1510

16-
# create gen3 user
17-
# Create a group 'gen3' with GID 1000 and a user 'gen3' with UID 1000
18-
RUN groupadd -g 1000 gen3 && \
19-
useradd -m -s /bin/bash -u 1000 -g gen3 gen3 && \
20-
chown -R gen3:gen3 /$appname && \
21-
chown -R gen3:gen3 /venv
22-
23-
RUN dnf update && dnf install -y \
24-
python3-devel \
25-
postgresql15-server-devel \
26-
&& rm -rf /var/cache/yum
11+
RUN chown -R gen3:gen3 /$appname
2712

2813
# Builder stage
2914
FROM base AS builder
3015

3116
USER gen3
3217

33-
RUN python -m venv /venv
34-
3518
COPY poetry.lock pyproject.toml /${appname}/
3619

37-
RUN pip install poetry && \
38-
poetry install -vv --only main --no-interaction
20+
RUN poetry install -vv --only main --no-interaction
3921

4022
COPY --chown=gen3:gen3 . /$appname
4123
COPY --chown=gen3:gen3 ./deployment/wsgi/wsgi.py /$appname/wsgi.py
@@ -49,36 +31,11 @@ RUN git config --global --add safe.directory /${appname} && COMMIT=`git rev-pars
4931
# Final stage
5032
FROM base
5133

52-
COPY --from=builder /venv /venv
5334
COPY --from=builder /$appname /$appname
5435

55-
# install nginx
56-
RUN yum install nginx -y
57-
58-
# allow nginx to bind to port 80
59-
RUN setcap 'cap_net_bind_service=+ep' /usr/sbin/nginx
60-
61-
# chown nginx directories
62-
RUN chown -R gen3:gen3 /var/log/nginx
63-
64-
# pipe nginx logs to stdout and stderr
65-
RUN ln -sf /dev/stdout /var/log/nginx/access.log && ln -sf /dev/stderr /var/log/nginx/error.log
66-
67-
# create /var/lib/nginx/tmp/client_body to allow nginx to write to fence
68-
RUN mkdir -p /var/lib/nginx/tmp/client_body
69-
RUN chown -R gen3:gen3 /var/lib/nginx/
70-
71-
# copy nginx config
72-
COPY ./deployment/nginx/nginx.conf /etc/nginx/nginx.conf
73-
7436
# Switch to non-root user 'gen3' for the serving process
7537
USER gen3
7638

77-
RUN source /venv/bin/activate
78-
79-
ENV PYTHONUNBUFFERED=1 \
80-
PYTHONIOENCODING=UTF-8
81-
82-
WORKDIR /var/www/${appname}
39+
WORKDIR /$appname
8340

84-
CMD ["/bin/bash", "-c", "/peregrine/dockerrun.bash"]
41+
CMD ["/bin/bash", "-c", "/${appname}/dockerrun.bash"]

deployment/nginx/nginx.conf

-44
This file was deleted.

deployment/wsgi/wsgi.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import sys
1+
from peregrine.api import app
22

3-
sys.path.append("/var/www/peregrine/")
4-
sys.path.append("/peregrine/")
5-
from wsgi import app as application
3+
application = app

dockerrun.bash

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/bash
22

33
nginx
4-
gunicorn -c /peregrine/deployment/wsgi/gunicorn.conf.py
4+
poetry run gunicorn -c /peregrine/deployment/wsgi/gunicorn.conf.py

0 commit comments

Comments
 (0)