-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PPR API update to poetry; GCP CI, CD set up (#2072)
Signed-off-by: Doug Lovett <[email protected]>
- Loading branch information
1 parent
1fe76ab
commit d6de16d
Showing
194 changed files
with
15,491 additions
and
14,089 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
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,34 +1,92 @@ | ||
FROM python:3.11-buster | ||
FROM python:3.12-bullseye AS development_build | ||
|
||
USER root | ||
|
||
ARG VCS_REF="missing" | ||
ARG BUILD_DATE="missing" | ||
|
||
ENV VCS_REF=${VCS_REF} | ||
ENV BUILD_DATE=${BUILD_DATE} | ||
ENV PORT=8080 | ||
|
||
LABEL org.label-schema.vcs-ref=${VCS_REF} \ | ||
org.label-schema.build-date=${BUILD_DATE} | ||
|
||
# Create working directory | ||
RUN mkdir /opt/app-root && chmod 755 /opt/app-root | ||
WORKDIR /opt/app-root | ||
LABEL maintainer="thorwolpert" | ||
LABEL vendor="BCROS" | ||
|
||
ARG APP_ENV \ | ||
# Needed for fixing permissions of files created by Docker: | ||
UID=1000 \ | ||
GID=1000 | ||
|
||
ENV APP_ENV=${APP_ENV} \ | ||
# python: | ||
PYTHONFAULTHANDLER=1 \ | ||
PYTHONUNBUFFERED=1 \ | ||
PYTHONHASHSEED=random \ | ||
PYTHONDONTWRITEBYTECODE=1 \ | ||
# pip: | ||
PIP_NO_CACHE_DIR=1 \ | ||
PIP_DISABLE_PIP_VERSION_CHECK=1 \ | ||
PIP_DEFAULT_TIMEOUT=100 \ | ||
PIP_ROOT_USER_ACTION=ignore \ | ||
# poetry: | ||
POETRY_VERSION=1.8.3 \ | ||
POETRY_NO_INTERACTION=1 \ | ||
POETRY_VIRTUALENVS_CREATE=false \ | ||
POETRY_CACHE_DIR='/var/cache/pypoetry' \ | ||
POETRY_HOME='/usr/local' | ||
|
||
SHELL ["/bin/bash", "-eo", "pipefail", "-c"] | ||
|
||
RUN apt-get update && apt-get upgrade -y \ | ||
&& apt-get install --no-install-recommends -y \ | ||
bash \ | ||
brotli \ | ||
build-essential \ | ||
curl \ | ||
gettext \ | ||
git \ | ||
libpq-dev \ | ||
wait-for-it \ | ||
&& curl -sSL 'https://install.python-poetry.org' | python - \ | ||
&& poetry --version \ | ||
# Cleaning cache: | ||
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \ | ||
&& apt-get clean -y && rm -rf /var/lib/apt/lists/* | ||
|
||
WORKDIR /code | ||
|
||
RUN groupadd -g "${GID}" -r web \ | ||
&& useradd -d '/code' -g web -l -r -u "${UID}" web \ | ||
&& chown web:web -R '/code' | ||
|
||
# Install the requirements | ||
COPY ./requirements.txt . | ||
# Copy only requirements, to cache them in docker layer | ||
COPY --chown=web:web ./poetry.lock ./pyproject.toml /code/ | ||
|
||
RUN pip install --upgrade pip | ||
RUN pip install --no-cache-dir -r requirements.txt | ||
COPY --chown=web:web ./src /code/src | ||
COPY --chown=web:web ./README.md /code | ||
|
||
COPY . . | ||
# Project initialization: | ||
RUN --mount=type=cache,target="$POETRY_CACHE_DIR" \ | ||
echo "$APP_ENV" \ | ||
&& poetry version \ | ||
# Install deps: | ||
&& poetry run pip install -U pip \ | ||
&& poetry install \ | ||
$(if [ -z ${APP_ENV+x} ] | [ "$APP_ENV" = 'production' ]; then echo '--only main'; fi) \ | ||
--no-interaction --no-ansi | ||
|
||
RUN pip install . | ||
# Running as non-root user: | ||
USER web | ||
|
||
USER 1001 | ||
# The following stage is only for production: | ||
FROM development_build AS production_build | ||
COPY --chown=web:web . /code | ||
|
||
# Run the server | ||
ENV PYTHONPATH=/opt/app-root/src | ||
# ENV PYTHONPATH=/opt/app-root/src | ||
|
||
EXPOSE 8080 | ||
# CMD gunicorn --bind 0.0.0.0:${PORT} --config /code/gunicorn_config.py wsgi:app | ||
|
||
CMD ["gunicorn", "--bind", "0.0.0.0:8080", "--config", "/opt/app-root/gunicorn_config.py", "wsgi:application"] | ||
CMD exec gunicorn --bind :$PORT --workers 1 --threads 8 --timeout 0 wsgi:app |
Oops, something went wrong.