Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding nginx to wts #90

Merged
merged 15 commits into from
Nov 18, 2024
Merged
48 changes: 12 additions & 36 deletions .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
{
"name": "AWSKeyDetector"
},
{
"name": "AzureStorageKeyDetector"
},
{
"name": "Base64HighEntropyString",
"limit": 4.5
Expand All @@ -20,15 +17,9 @@
{
"name": "CloudantDetector"
},
{
"name": "DiscordBotTokenDetector"
},
{
"name": "GitHubTokenDetector"
},
{
"name": "HexHighEntropyString",
"limit": 3.0
"limit": 3
},
{
"name": "IbmCloudIamDetector"
Expand All @@ -46,24 +37,15 @@
{
"name": "MailchimpDetector"
},
{
"name": "NpmDetector"
},
{
"name": "PrivateKeyDetector"
},
{
"name": "SendGridDetector"
},
{
"name": "SlackDetector"
},
{
"name": "SoftlayerDetector"
},
{
"name": "SquareOAuthDetector"
},
{
"name": "StripeDetector"
},
Expand All @@ -75,6 +57,10 @@
{
"path": "detect_secrets.filters.allowlist.is_line_allowlisted"
},
{
"path": "detect_secrets.filters.common.is_baseline_file",
"filename": ".secrets.baseline"
},
{
"path": "detect_secrets.filters.common.is_ignored_due_to_verification_policies",
"min_level": 2
Expand Down Expand Up @@ -105,18 +91,15 @@
},
{
"path": "detect_secrets.filters.heuristic.is_templated_secret"
},
{
"path": "detect_secrets.filters.regex.should_exclude_file",
"pattern": [
"^.secrets.baseline$"
]
}
],
"results": {
".github/workflows/ci.yaml": [
{
"type": "Secret Keyword",
"filename": ".github/workflows/ci.yaml",
"hashed_secret": "3e26d6750975d678acb8fa35a0f69237881576b0",
"is_verified": false,
"line_number": 13
}
],
"README.md": [
{
"type": "Secret Keyword",
Expand Down Expand Up @@ -181,15 +164,8 @@
"hashed_secret": "109f4b3c50d7b0df729d299bc6f8e9ef9066971f",
"is_verified": false,
"line_number": 13
},
{
"type": "Secret Keyword",
"filename": "tests/test_settings.json",
"hashed_secret": "3ebfa301dc59196f18593c45e519287a23297589",
"is_verified": false,
"line_number": 28
}
]
},
"generated_at": "2024-07-25T20:59:28Z"
"generated_at": "2023-09-19T21:25:48Z"
}
57 changes: 26 additions & 31 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,43 +1,38 @@
# To run: docker run -v /path/to/wsgi.py:/var/www/wts/wsgi.py --name=wts -p 81:80 wts
# To check running container: docker exec -it wts /bin/bash
ARG AZLINUX_BASE_VERSION=master

FROM quay.io/cdis/python:python3.9-buster-2.0.0

RUN apt-get update \
&& apt-get install -y --no-install-recommends curl bash git vim
# Base stage with python-build-base
FROM quay.io/cdis/python-nginx-al:${AZLINUX_BASE_VERSION} AS base

ENV appname=wts

COPY . /$appname
COPY ./deployment/uwsgi/uwsgi.ini /etc/uwsgi/uwsgi.ini
COPY ./deployment/uwsgi/wsgi.py /$appname/wsgi.py
WORKDIR /$appname
WORKDIR /${appname}

RUN chown -R gen3:gen3 /${appname}

# Builder stage
FROM base AS builder

USER gen3

COPY poetry.lock pyproject.toml /${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
RUN poetry install -vv --without dev --no-interaction

RUN pip install --upgrade pip
RUN pip install --upgrade poetry
COPY --chown=gen3:gen3 . /${appname}
COPY --chown=gen3:gen3 ./deployment/wsgi/wsgi.py /${appname}/wsgi.py

COPY poetry.lock pyproject.toml /$appname/
RUN poetry config virtualenvs.create false \
&& poetry install -vv --no-dev --no-interaction \
&& poetry show -v
# Run poetry again so this app itself gets installed too
RUN poetry install --without dev --no-interaction

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 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

# py httpx in authlib wants to access $HOME/.netrc -
# there is nothing secret in /root
RUN touch /root/.netrc && chmod -R a+rX /root
# Final stage
FROM base

EXPOSE 80
COPY --from=builder /${appname} /${appname}

WORKDIR /var/www/$appname
# Switch to non-root user 'gen3' for the serving process
USER gen3

CMD /dockerrun.sh
CMD ["/bin/bash", "-c", "/wts/dockerrun.bash"]
21 changes: 0 additions & 21 deletions deployment/uwsgi/uwsgi.ini

This file was deleted.

6 changes: 6 additions & 0 deletions deployment/wsgi/gunicorn.conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
wsgi_app = "deployment.wsgi.wsgi:application"
bind = "0.0.0.0:8000"
workers = 1
user = "gen3"
group = "gen3"
timeout = 300
File renamed without changes.
4 changes: 4 additions & 0 deletions dockerrun.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

nginx
poetry run gunicorn -c "/wts/deployment/wsgi/gunicorn.conf.py"
Loading
Loading