-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into chore/refine-single-table-migration
- Loading branch information
Showing
8 changed files
with
370 additions
and
325 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,40 @@ | ||
# To run: docker run -v /path/to/wsgi.py:/var/www/indexd/wsgi.py --name=indexd -p 81:80 indexd | ||
# To check running container: docker exec -it indexd /bin/bash | ||
ARG AZLINUX_BASE_VERSION=master | ||
|
||
FROM quay.io/cdis/python:python3.9-buster-2.0.0 | ||
# Base stage with python-build-base | ||
FROM quay.io/cdis/python-nginx-al:${AZLINUX_BASE_VERSION} AS base | ||
|
||
ENV appname=indexd | ||
|
||
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 | ||
USER gen3 | ||
|
||
# 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 --no-dev --no-interaction \ | ||
&& poetry show -v | ||
COPY poetry.lock pyproject.toml /${appname}/ | ||
|
||
# copy source code ONLY after installing dependencies | ||
COPY . /$appname | ||
COPY ./deployment/uwsgi/uwsgi.ini /etc/uwsgi/uwsgi.ini | ||
COPY ./deployment/uwsgi/wsgi.py /$appname/wsgi.py | ||
COPY clear_prometheus_multiproc /$appname/clear_prometheus_multiproc | ||
RUN poetry install -vv --without dev --no-interaction | ||
|
||
# install indexd | ||
RUN poetry config virtualenvs.create false \ | ||
&& poetry install -vv --no-dev --no-interaction \ | ||
&& poetry show -v | ||
COPY --chown=gen3:gen3 . /${appname} | ||
COPY --chown=gen3:gen3 ./deployment/wsgi/wsgi.py /${appname}/wsgi.py | ||
|
||
RUN COMMIT=`git rev-parse HEAD` && echo "COMMIT=\"${COMMIT}\"" >$appname/index/version_data.py \ | ||
&& VERSION=`git describe --always --tags` && echo "VERSION=\"${VERSION}\"" >>$appname/index/version_data.py | ||
# Run poetry again so this app itself gets installed too | ||
RUN poetry install --without dev --no-interaction | ||
|
||
# directory where the app can find Alembic files | ||
WORKDIR /indexd | ||
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 | ||
|
||
CMD ["/dockerrun.sh"] | ||
# Final stage | ||
FROM base | ||
|
||
COPY --from=builder /${appname} /${appname} | ||
|
||
# Switch to non-root user 'gen3' for the serving process | ||
USER gen3 | ||
|
||
WORKDIR /${appname} | ||
|
||
CMD ["/bin/bash", "-c", "/indexd/dockerrun.bash"] |
This file was deleted.
Oops, something went wrong.
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 = "deployment.wsgi.wsgi:application" | ||
bind = "0.0.0.0:8000" | ||
workers = 1 | ||
preload_app = True | ||
user = "gen3" | ||
group = "gen3" | ||
timeout = 300 | ||
keepalive = 2 | ||
keepalive_timeout = 5 |
File renamed without changes.
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 "/indexd/deployment/wsgi/gunicorn.conf.py" |
Oops, something went wrong.