-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
272 additions
and
110 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 +1,67 @@ | ||
# old Dockerfile | ||
# old Dockerfile -- specifically for the use of Mcrypt, since Al2 image does not support Mcrypt (which is used in usersyncjob) | ||
# To run: docker run --rm -d -v /path/to/fence-config.yaml:/var/www/fence/fence-config.yaml --name=fence -p 80:80 fence | ||
# To check running container do: docker exec -it fence /bin/bash | ||
|
||
FROM quay.io/cdis/python:python3.9-buster-2.0.0 | ||
|
||
ENV appname=fence | ||
WORKDIR /$appname | ||
|
||
|
||
RUN pip install --upgrade pip | ||
RUN pip install --upgrade poetry | ||
RUN apt-get update \ | ||
&& apt-get install -y --no-install-recommends curl bash git \ | ||
&& apt-get -y install vim \ | ||
libmcrypt4 mcrypt \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/ | ||
|
||
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 | ||
|
||
# aws cli v2 - needed for storing files in s3 during usersync k8s job | ||
RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" \ | ||
&& unzip awscliv2.zip \ | ||
&& ./aws/install \ | ||
&& /bin/rm -rf awscliv2.zip ./aws | ||
|
||
|
||
# copy ONLY poetry artifact, install the dependencies but not fence | ||
# this will make sure than the dependencies is cached | ||
COPY poetry.lock pyproject.toml /$appname/ | ||
RUN pwd | ||
|
||
RUN sed -i 's/psycopg2-binary = "<3"/psycopg2 = "<3"/g' /$appname/pyproject.toml | ||
|
||
RUN poetry lock -vv --no-update \ | ||
&& poetry config virtualenvs.create false \ | ||
&& poetry install -vv --no-root --no-dev --no-interaction \ | ||
&& poetry show -v | ||
|
||
# copy source code ONLY after installing dependencies | ||
COPY . /$appname | ||
RUN sed -i 's/psycopg2-binary = "<3"/psycopg2 = "<3"/g' /$appname/pyproject.toml | ||
|
||
# Changing the ownership of gunicorn to root for this dockerfile to run | ||
RUN sed -i 's/gen3/root/g' /$appname/deployment/wsgi/gunicorn.conf.py | ||
|
||
COPY ./deployment/uwsgi/uwsgi.ini /etc/uwsgi/uwsgi.ini | ||
COPY ./deployment/wsgi/wsgi.py /$appname/wsgi.py | ||
COPY clear_prometheus_multiproc /$appname/clear_prometheus_multiproc | ||
|
||
# install fence | ||
RUN poetry config virtualenvs.create false \ | ||
&& poetry lock -vv --no-update \ | ||
&& poetry install -vv --no-dev --no-interaction \ | ||
&& poetry show -v | ||
|
||
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 | ||
|
||
CMD ["poetry", "run", "gunicorn", "-c", "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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
[uwsgi] | ||
protocol = uwsgi | ||
socket = /var/run/gen3/uwsgi.sock | ||
buffer-size = 32768 | ||
uid = nginx | ||
gid = nginx | ||
chown-socket = nginx:nginx | ||
chmod-socket = 666 | ||
master = true | ||
harakiri-verbose = true | ||
# No global HARAKIRI, using only user HARAKIRI, because export overwrites it | ||
# Cannot overwrite global HARAKIRI with user's: https://git.io/fjYuD | ||
# harakiri = 45 | ||
http-timeout = 45 | ||
socket-timeout = 45 | ||
worker-reload-mercy = 45 | ||
reload-mercy = 45 | ||
mule-reload-mercy = 45 | ||
disable-logging = true | ||
wsgi-file=/fence/wsgi.py | ||
plugins = python3 | ||
vacuum = true | ||
pythonpath = /var/www/fence/ | ||
pythonpath = /fence/ | ||
# poetry installs git dependencies at /usr/local/src | ||
pythonpath = /usr/local/src/* | ||
|
||
# metrics setup | ||
stats = 127.0.0.1:9191 | ||
stats-http = true | ||
env = prometheus_multiproc_dir=/var/tmp/uwsgi_flask_metrics | ||
exec-asap = /fence/clear_prometheus_multiproc /var/tmp/uwsgi_flask_metrics | ||
|
||
# Initialize application in worker processes, not master. This prevents the | ||
# workers from all trying to open the same database connections at startup. | ||
lazy = true | ||
lazy-apps = true |
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
Oops, something went wrong.