From 502692f3e76f4d936892836cb7c8012a64e5d334 Mon Sep 17 00:00:00 2001 From: Scott Collins Date: Tue, 13 Apr 2021 12:04:28 -0700 Subject: [PATCH] Initial addition of the configuration files for Dockerization of the PDS DOI Service --- .dockerignore | 8 ++++++++ Dockerfile | 16 ++++++++++++++++ docker-compose.yml | 20 ++++++++++++++++++++ doi_service.env | 35 +++++++++++++++++++++++++++++++++++ 4 files changed, 79 insertions(+) create mode 100644 .dockerignore create mode 100755 Dockerfile create mode 100644 docker-compose.yml create mode 100644 doi_service.env diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..d3e4222e --- /dev/null +++ b/.dockerignore @@ -0,0 +1,8 @@ +pds_doi_service.ini +doi.db +doi_temp.db +transaction_history/ +**/test* +**/.DS_Store +**/__pycache__ +**/.pytest_cache diff --git a/Dockerfile b/Dockerfile new file mode 100755 index 00000000..96521b20 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM python:3.7-slim + +RUN mkdir -p /usr/src/app +WORKDIR /usr/src/app + +COPY requirements.txt /usr/src/app/ + +RUN pip3 install --no-cache-dir -r requirements.txt + +COPY ./pds_doi_service /usr/src/app/pds_doi_service + +EXPOSE 8080 + +ENTRYPOINT ["python3"] + +CMD ["-m", "pds_doi_service.api"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..f3f26122 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,20 @@ +version: "3.7" + +services: + pds-doi-api: + image: pds-doi-service:latest + ports: + - 8080:8080 + working_dir: /usr/src/app + volumes: + - sqllite-data:/usr/src/data + environment: + # By setting this envvar in the Compose file, it supersedes anything set + # in doi_service.env. This is how we ensure the SQLite file is written to + # the sqllite-data persistent volume. + - OTHER_DB_FILE=/usr/src/data/doi.db + env_file: + - doi_service.env + +volumes: + sqllite-data: diff --git a/doi_service.env b/doi_service.env new file mode 100644 index 00000000..89e09e56 --- /dev/null +++ b/doi_service.env @@ -0,0 +1,35 @@ +# This file is used with docker-compose.yml to specify a number of environment +# variable key/value pairs to add to the DOI Service's environment when +# launching the container via docker compose up. + +# The DOI Service prioritizes environment variables over the included INI, +# so this file may be used to inject credentials or any other supported +# options into the DOI Service when in a containerized context. + +# The naming convention for expected environment variables follows from the +# format of the INI, where the section name and option name are concatenated +# with an underscore and converted to uppercase, for example: + +# OSTI_USER=username -> overrides the "user" option of the [OSTI] INI section. + +# If the default values from the bundled INI are desired, do not specify +# environment variables for them here or they will be overridden. + +# Also note that Docker performs "no special handling of quotation marks" for +# values. This means that they become part of the value provided to the DOI Service. + +# [OSTI] +OSTI_URL=https://www.osti.gov/iad2test/api/records +OSTI_USER=username +OSTI_PASSWORD=secret + +# [PDS4_DICTIONARY] +PDS4_DICTIONARY_URL=https://pds.nasa.gov/pds4/pds/v1/PDS4_PDS_JSON_1D00.JSON + +# [LANDING_PAGES] +LANDING_PAGES_URL=https://pds.nasa.gov/ds-view/pds/view{}.jsp?identifier={}&version={} + +# [OTHER] +OTHER_EMAILER_SENDER=pdsen-doi-test@jpl.nasa.gov +OTHER_PDS_REGISTRATION_DOI_TOKEN=10.17189 +OTHER_LOGGING_LEVEL=DEBUG