forked from uc-cdis/sheepdog
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request uc-cdis#421 from uc-cdis/feat/al2-updates
Feat/al2 updates
- Loading branch information
Showing
21 changed files
with
225 additions
and
532 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,56 @@ | ||
# To run: | ||
# - Create and fill out `creds.json`: | ||
# { | ||
# "fence_host": "", | ||
# "fence_username": "", | ||
# "fence_password": "", | ||
# "fence_database": "", | ||
# "db_host": "", | ||
# "db_username": "", | ||
# "db_password": "", | ||
# "db_database": "", | ||
# "gdcapi_secret_key": "", | ||
# "indexd_password": "", | ||
# "hostname": "" | ||
# } | ||
# - Build the image: `docker build . -t sheepdog -f Dockerfile` | ||
# - Run: `docker run -v /full/path/to/creds.json:/var/www/sheepdog/creds.json -p 81:80 sheepdog` | ||
# To check running container: `docker exec -it sheepdog /bin/bash` | ||
|
||
FROM quay.io/cdis/python:python3.9-buster-2.0.0 | ||
ARG AZLINUX_BASE_VERSION=master | ||
|
||
# Base stage with python-build-base | ||
FROM quay.io/cdis/python-nginx-al:${AZLINUX_BASE_VERSION} AS base | ||
|
||
ENV appname=sheepdog | ||
|
||
RUN pip install --upgrade pip poetry | ||
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
build-essential libffi-dev musl-dev gcc libxml2-dev libxslt-dev \ | ||
curl bash git vim | ||
WORKDIR /${appname} | ||
|
||
RUN mkdir -p /var/www/$appname \ | ||
&& mkdir -p /var/www/.cache/Python-Eggs/ \ | ||
&& mkdir /run/nginx/ \ | ||
&& ln -sf /dev/stdout /var/log/nginx/access.log \ | ||
&& ln -sf /dev/stderr /var/log/nginx/error.log \ | ||
&& chown nginx -R /var/www/.cache/Python-Eggs/ \ | ||
&& chown nginx /var/www/$appname | ||
RUN chown -R gen3:gen3 /${appname} | ||
|
||
EXPOSE 80 | ||
# Builder stage | ||
FROM base AS builder | ||
|
||
WORKDIR /$appname | ||
RUN yum install -y \ | ||
gcc \ | ||
python3-devel \ | ||
postgresql-devel \ | ||
libpq-devel && \ | ||
yum clean all | ||
|
||
# copy ONLY poetry artifact, install the dependencies but not indexd | ||
# this will make sure than the dependencies is cached | ||
COPY poetry.lock pyproject.toml /$appname/ | ||
RUN poetry config virtualenvs.create false \ | ||
&& poetry install -vv --no-root --without dev --no-interaction \ | ||
&& poetry show -v | ||
USER gen3 | ||
|
||
COPY --chown=gen3:gen3 . /${appname} | ||
|
||
RUN poetry install -vv --without dev --no-interaction | ||
|
||
# copy source code ONLY after installing dependencies | ||
COPY . /$appname | ||
COPY ./deployment/uwsgi/uwsgi.ini /etc/uwsgi/uwsgi.ini | ||
COPY ./bin/settings.py /var/www/$appname/settings.py | ||
COPY ./bin/confighelper.py /var/www/$appname/confighelper.py | ||
RUN git config --global --add safe.directory /${appname} && COMMIT=`git rev-parse HEAD` && echo "COMMIT=\"${COMMIT}\"" > /${appname}/version_data.py \ | ||
&& VERSION=`git describe --always --tags` && echo "VERSION=\"${VERSION}\"" >> /${appname}/version_data.py | ||
|
||
# Final stage | ||
FROM base | ||
|
||
# Install runtime dependencies | ||
RUN yum install -y \ | ||
gcc \ | ||
python3-devel \ | ||
postgresql-devel \ | ||
libpq-devel && \ | ||
yum clean all | ||
|
||
# Copy poetry artifacts and install the dependencies | ||
COPY poetry.lock pyproject.toml /$appname/ | ||
RUN poetry config virtualenvs.create false && \ | ||
poetry install -vv --no-root --without dev --no-interaction && \ | ||
poetry show -v | ||
|
||
# install sheepdog | ||
RUN poetry config virtualenvs.create false \ | ||
&& poetry install -vv --without dev --no-interaction \ | ||
&& poetry show -v | ||
# Copy application files from the builder stage | ||
COPY --from=builder /${appname} /${appname} | ||
|
||
RUN COMMIT=`git rev-parse HEAD` && echo "COMMIT=\"${COMMIT}\"" >$appname/version_data.py \ | ||
&& VERSION=`git describe --always --tags` && echo "VERSION=\"${VERSION}\"" >>$appname/version_data.py | ||
# Switch to non-root user 'gen3' for the serving process | ||
USER gen3 | ||
|
||
WORKDIR /var/www/$appname | ||
WORKDIR /${appname} | ||
|
||
RUN ls | ||
CMD /dockerrun.sh | ||
CMD ["/sheepdog/dockerrun.bash"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
wsgi_app = "bin.settings:application" | ||
bind = "0.0.0.0:8000" | ||
workers = 1 | ||
preload_app = True | ||
user = "gen3" | ||
group = "gen3" | ||
timeout = 300 | ||
keepalive = 2 | ||
keepalive_timeout = 5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
|
||
nginx | ||
poetry run gunicorn -c "/sheepdog/deployment/wsgi/gunicorn.conf.py" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.