Skip to content

Commit

Permalink
updating dockerfile to consolidate
Browse files Browse the repository at this point in the history
  • Loading branch information
EliseCastle23 committed Oct 24, 2024
1 parent 4e792a5 commit 1090ed5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 89 deletions.
50 changes: 6 additions & 44 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,38 +1,24 @@
ARG AZLINUX_BASE_VERSION=master

# Base stage with python-build-base
FROM quay.io/cdis/python-build-base:${AZLINUX_BASE_VERSION} AS base
## For local development
# FROM quay.io/cdis/python-nginx-al2:feat_python-nginx AS base

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

Check warning on line 6 in Dockerfile

View workflow job for this annotation

GitHub Actions / Build Image and Push to Quay / Build Image and Push

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/

ENV appname=indexd
ENV POETRY_NO_INTERACTION=1 \
POETRY_VIRTUALENVS_IN_PROJECT=1 \
POETRY_VIRTUALENVS_CREATE=1

WORKDIR /${appname}

# create gen3 user
# Create a group 'gen3' with GID 1000 and a user 'gen3' with UID 1000
RUN groupadd -g 1000 gen3 && \
useradd -m -s /bin/bash -u 1000 -g gen3 gen3 && \
chown -R gen3:gen3 /$appname && \
chown -R gen3:gen3 /venv

RUN chown -R gen3:gen3 /$appname

# Builder stage
FROM base AS builder

USER gen3


RUN python -m venv /venv

COPY poetry.lock pyproject.toml /${appname}/

RUN pip install --upgrade poetry && \
poetry install -vv --only main --no-interaction
RUN poetry install -vv --only main --no-interaction

COPY --chown=gen3:gen3 . /$appname
COPY --chown=gen3:gen3 ./deployment/wsgi/wsgi.py /$appname/wsgi.py
Expand All @@ -46,35 +32,11 @@ RUN git config --global --add safe.directory /${appname} && COMMIT=`git rev-pars
# Final stage
FROM base

COPY --from=builder /venv /venv
COPY --from=builder /$appname /$appname

# Install nginx
RUN yum install nginx -y

# allows nginx to run on port 80 without being root user
RUN setcap 'cap_net_bind_service=+ep' /usr/sbin/nginx

# chown nginx directories
RUN chown -R gen3:gen3 /var/log/nginx

# pipe nginx logs to stdout and stderr
RUN ln -sf /dev/stdout /var/log/nginx/access.log && ln -sf /dev/stderr /var/log/nginx/error.log

# create /var/lib/nginx/tmp/client_body to allow nginx to write to indexd
RUN mkdir -p /var/lib/nginx/tmp/client_body
RUN chown -R gen3:gen3 /var/lib/nginx/

# copy nginx config
COPY ./deployment/nginx/nginx.conf /etc/nginx/nginx.conf


# Switch to non-root user 'gen3' for the serving process
USER gen3

RUN source /venv/bin/activate

ENV PYTHONUNBUFFERED=1 \
PYTHONIOENCODING=UTF-8
WORKDIR /$appname

CMD ["/bin/bash", "-c", "/indexd/dockerrun.bash"]
44 changes: 0 additions & 44 deletions deployment/nginx/nginx.conf

This file was deleted.

2 changes: 1 addition & 1 deletion dockerrun.bash
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash

source .venv/bin/activate
nginx
gunicorn -c "/indexd/deployment/wsgi/gunicorn.conf.py"

0 comments on commit 1090ed5

Please sign in to comment.