-
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.
- Loading branch information
Showing
2 changed files
with
37 additions
and
41 deletions.
There are no files selected for viewing
64 changes: 23 additions & 41 deletions
64
...vtools/templates/repository/{{cookiecutter.repository_name}}/docker/Dockerfile.production
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,62 +1,44 @@ | ||
ARG OAREPO_DEVELOPMENT_IMAGE=oarepo/oarepo-base-development:{{cookiecutter.oarepo_version}} | ||
ARG OAREPO_PRODUCTION_IMAGE=oarepo/oarepo-base-production:{{cookiecutter.oarepo_version}} | ||
ARG OAREPO_DEVELOPMENT_IMAGE=oarepo/oarepo-base-development:12 | ||
ARG OAREPO_PRODUCTION_IMAGE=oarepo/oarepo-base-production:12 | ||
ARG BUILDPLATFORM=linux/amd64 | ||
|
||
FROM --platform=$BUILDPLATFORM $OAREPO_DEVELOPMENT_IMAGE as production-build | ||
|
||
ARG REPOSITORY_SITE_NAME | ||
ARG SITE_DIR=/repository/sites/${REPOSITORY_SITE_NAME} | ||
|
||
ENV SITE_DIR=$SITE_DIR | ||
ENV REPOSITORY_SITE_NAME=${REPOSITORY_SITE_NAME} | ||
ENV PATH=/pdm/bin:${PATH} | ||
|
||
RUN echo "Site dir is ${SITE_DIR}, repository site name is ${REPOSITORY_SITE_NAME}" | ||
|
||
COPY . /repository | ||
|
||
# DEBUG only | ||
#COPY nrp-sources /nrp-sources | ||
#RUN PYTHONPATH=/nrp-sources DOCKER_AROUND=1 /nrp/bin/nrp build --production --site $REPOSITORY_SITE_NAME --project-dir /repository | ||
# build the repository | ||
WORKDIR /repository | ||
RUN rm -rf .nrp .pdm-build .venv | ||
RUN PYTHON=`which python3` ./nrp build --override-config venv_dir=/invenio/venv --override-config invenio_instance_path=/invenio/instance | ||
|
||
# production | ||
RUN DOCKER_AROUND=1 /nrp/bin/nrp build --production --site $REPOSITORY_SITE_NAME --project-dir /repository | ||
# cleanup | ||
RUN rm -rf .nrp .pdm-build .venv | ||
RUN find . -name "__pycache__" -type d -exec rm -rf {} + | ||
|
||
|
||
FROM --platform=$BUILDPLATFORM ${OAREPO_PRODUCTION_IMAGE} as production | ||
|
||
ARG REPOSITORY_SITE_ORGANIZATION | ||
ARG REPOSITORY_SITE_NAME | ||
ARG REPOSITORY_IMAGE_URL | ||
ARG REPOSITORY_AUTHOR | ||
ARG REPOSITORY_GITHUB_URL | ||
ARG REPOSITORY_URL | ||
ARG REPOSITORY_DOCUMENTATION | ||
|
||
ARG SITE_DIR=/repository/sites/${REPOSITORY_SITE_NAME} | ||
LABEL maintainer="" \ | ||
org.opencontainers.image.authors="" \ | ||
org.opencontainers.image.title="{{ repository_name }}" \ | ||
org.opencontainers.image.url="" \ | ||
org.opencontainers.image.source="" \ | ||
org.opencontainers.image.documentation="" | ||
|
||
LABEL maintainer="${REPOSITORY_SITE_ORGANIZATION}" \ | ||
org.opencontainers.image.authors="${REPOSITORY_AUTHOR}" \ | ||
org.opencontainers.image.title="MBDB production image for ${REPOSITORY_SITE_NAME}" \ | ||
org.opencontainers.image.url="${REPOSITORY_IMAGE_URL}" \ | ||
org.opencontainers.image.source="${REPOSITORY_GITHUB_URL}" \ | ||
org.opencontainers.image.documentation="${REPOSITORY_DOCUMENTATION}" | ||
|
||
# copy build from production build - just the final directories, not the whole build | ||
|
||
# copy build | ||
RUN mkdir -p /invenio/instance | ||
COPY --from=production-build /invenio/instance/invenio.cfg /invenio/instance/invenio.cfg | ||
COPY --from=production-build /invenio/instance/variables /invenio/instance/variables | ||
COPY --from=production-build /invenio/instance/static /invenio/instance/static | ||
COPY --from=production-build /invenio/venv /invenio/venv | ||
|
||
# copy sources (just for sure, should not be needed for production run) | ||
COPY --from=production-build /invenio /invenio | ||
COPY --from=production-build /repository /repository | ||
|
||
# copy uwsgi.ini - keep the path the same as in invenio | ||
RUN mkdir -p /opt/invenio/src/uwsgi/ | ||
COPY sites/${REPOSITORY_SITE_NAME}/docker/uwsgi/uwsgi.ini /opt/invenio/src/uwsgi/uwsgi.ini | ||
|
||
ENV PATH=${INVENIO_VENV}/bin:${PATH} | ||
COPY ./docker/development.crt /development.crt | ||
COPY ./docker/development.key /development.key | ||
|
||
COPY ./docker/uwsgi.ini /opt/invenio/src/uwsgi/uwsgi.ini | ||
|
||
ENV PATH=/invenio/venv/bin:${PATH} | ||
|
||
ENTRYPOINT [ "sh", "-c" ] |
14 changes: 14 additions & 0 deletions
14
src/nrp_devtools/templates/repository/{{cookiecutter.repository_name}}/docker/uwsgi.ini
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,14 @@ | ||
[uwsgi] | ||
socket = 0.0.0.0:5000 | ||
stats = 0.0.0.0:9000 | ||
|
||
https = 0.0.0.0:8443,/development.crt,/development.key | ||
|
||
module = invenio_app.wsgi:application | ||
master = true | ||
die-on-term = true | ||
processes = 2 | ||
threads = 4 | ||
single-interpreter = true | ||
buffer-size = 8192 | ||
wsgi-disable-file-wrapper = true |