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

Updating Docker image to use new AL2 image, Gunicorn, and multi-stage build #37

Open
wants to merge 66 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
ab69822
Updating Docker image to use new AL2 image, Gunicorn, and multi-stage…
EliseCastle23 Nov 22, 2023
ae1e2db
(PPS-694) bump cryptography to 41.0.6
george42-ctds Feb 1, 2024
e335107
Merge pull request #40 from uc-cdis/chore/bump-cryptography
george42-ctds Feb 6, 2024
fe417b6
(PPS-807) upgrade cryptography to 42.0.5
george42-ctds Mar 5, 2024
c634864
Merge pull request #41 from uc-cdis/chore/upgrade-cryptography-to-42.0.5
george42-ctds Mar 6, 2024
424b81d
Add GH action workflow for integration tests
haraprasadj Mar 29, 2024
dad86f8
remove jenkins pipeline (using GH Actions for integration tests)
haraprasadj Mar 29, 2024
43e7f98
Merge pull request #42 from uc-cdis/chore/add_gh_action_integration_t…
haraprasadj Apr 5, 2024
6552215
adding 3 new routes for manifest retrieval/upload, and some helper fu…
piotrsenkow Apr 11, 2024
6184caa
decorator path wrong for get_metadata_file function
piotrsenkow Apr 30, 2024
676fb40
changing back decorator but adding subpath to folder_name variable
piotrsenkow Apr 30, 2024
e95febe
added one too many forward slashes /
piotrsenkow Apr 30, 2024
7f6a02c
test
piotrsenkow Apr 30, 2024
22d118d
test 2
piotrsenkow Apr 30, 2024
018b6cb
Fixing docstring description of get metadata
piotrsenkow May 2, 2024
588d394
black formmating
piotrsenkow May 2, 2024
14298f4
black formatting, again
piotrsenkow May 2, 2024
35dae13
bug fix
piotrsenkow May 2, 2024
02e09a6
Changes for integration yaml (#45)
krishnaa05 May 3, 2024
c753172
removed TODO comments
piotrsenkow May 3, 2024
3f46bc5
Black formatting
piotrsenkow May 6, 2024
5edf92b
Refactoring function name
piotrsenkow May 7, 2024
8c8c087
Python Black formatting
piotrsenkow May 9, 2024
3b5cf73
fixing breaking tests
piotrsenkow May 9, 2024
49d9981
black formatting
piotrsenkow May 9, 2024
d3e2ff2
fixing key error
piotrsenkow May 9, 2024
77b7868
fixing config again
piotrsenkow May 9, 2024
e702f65
black
piotrsenkow May 9, 2024
57dc3fd
small verbiage change
piotrsenkow May 10, 2024
38408c9
Merge branch 'master' into piotr/feat-discovery-metadata-handoff
mfshao May 11, 2024
fbba38d
Merge pull request #43 from uc-cdis/piotr/feat-discovery-metadata-han…
piotrsenkow May 13, 2024
5a00bfe
Bump werkzeug from 3.0.1 to 3.0.3
dependabot[bot] May 13, 2024
628a73b
Bump jinja2 from 3.1.3 to 3.1.4
dependabot[bot] May 13, 2024
c03ebe7
trigger ci
mfshao May 14, 2024
0de4c4b
Merge pull request #47 from uc-cdis/dependabot/pip/werkzeug-3.0.3
mfshao May 15, 2024
1536581
Merge branch 'master' into dependabot/pip/jinja2-3.1.4
mfshao May 15, 2024
2c88a81
Bump idna from 3.6 to 3.7
dependabot[bot] May 15, 2024
0281afa
Merge pull request #48 from uc-cdis/dependabot/pip/jinja2-3.1.4
mfshao May 15, 2024
a2de007
Merge branch 'master' into dependabot/pip/idna-3.7
mfshao May 15, 2024
4e44a96
Merge pull request #46 from uc-cdis/dependabot/pip/idna-3.7
mfshao May 15, 2024
8d907cc
---
dependabot[bot] May 21, 2024
e4d67d3
trigger action
mfshao May 22, 2024
2ad85ea
Merge pull request #49 from uc-cdis/dependabot/pip/requests-2.32.0
mfshao May 22, 2024
5c9e555
Bump authlib from 1.3.0 to 1.3.1
dependabot[bot] Jun 10, 2024
8efa601
trigger action
mfshao Jun 10, 2024
8b49558
Merge pull request #50 from uc-cdis/dependabot/pip/authlib-1.3.1
mfshao Jun 10, 2024
bfc6623
update open api docs
mfshao Jun 13, 2024
6231c9a
update readme
mfshao Jun 13, 2024
a7dba7b
update for filename
mfshao Jun 13, 2024
8157464
update docs
mfshao Jun 13, 2024
3d275f6
fix tests
mfshao Jun 13, 2024
af89481
Merge pull request #51 from uc-cdis/chore/docs
mfshao Jun 13, 2024
abfeb55
Bump urllib3 from 1.26.18 to 1.26.19
dependabot[bot] Jun 17, 2024
a837aa0
trigger gh action
mfshao Jun 18, 2024
de932e1
Merge pull request #52 from uc-cdis/dependabot/pip/urllib3-1.26.19
mfshao Jun 18, 2024
4fe18a0
Bump certifi from 2024.2.2 to 2024.7.4
dependabot[bot] Jul 6, 2024
e12b148
trigger gh action
mfshao Jul 9, 2024
12076d5
Bump zipp from 3.17.0 to 3.19.1
dependabot[bot] Jul 9, 2024
65a0722
Merge pull request #53 from uc-cdis/dependabot/pip/certifi-2024.7.4
mfshao Jul 9, 2024
fcc962c
Merge branch 'master' into dependabot/pip/zipp-3.19.1
mfshao Jul 9, 2024
e7e7272
Merge pull request #54 from uc-cdis/dependabot/pip/zipp-3.19.1
mfshao Jul 15, 2024
f5b8bbf
json type
mfshao Aug 13, 2024
d286545
update version
mfshao Aug 14, 2024
cb45c00
Merge pull request #55 from uc-cdis/fix/export-json
mfshao Aug 14, 2024
959623a
Rebase off master
jawadqur Sep 4, 2024
8d7d9be
Merge branch 'feat/GPE-1108' of github.com:uc-cdis/manifestservice in…
jawadqur Sep 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/labeler.yml

This file was deleted.

25 changes: 25 additions & 0 deletions .github/workflows/integration_tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Integration Tests

on: pull_request

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
integration_tests:
name: Integration tests
uses: uc-cdis/.github/.github/workflows/integration_tests.yaml@master
with:
SERVICE_TO_TEST: manifestservice
secrets:
CI_AWS_ACCESS_KEY_ID: ${{ secrets.CI_AWS_ACCESS_KEY_ID }}
CI_AWS_SECRET_ACCESS_KEY: ${{ secrets.CI_AWS_SECRET_ACCESS_KEY }}
JENKINS_API_TOKEN: ${{ secrets.JENKINS_API_TOKEN }}
QA_DASHBOARD_S3_PATH: ${{ secrets.QA_DASHBOARD_S3_PATH }}
CI_TEST_ORCID_USERID: ${{ secrets.CI_TEST_ORCID_USERID }}
CI_TEST_ORCID_PASSWORD: ${{ secrets.CI_TEST_ORCID_PASSWORD }}
CI_TEST_RAS_USERID: ${{ secrets.CI_TEST_RAS_USERID }}
CI_TEST_RAS_PASSWORD: ${{ secrets.CI_TEST_RAS_PASSWORD }}
CI_SLACK_BOT_TOKEN: ${{ secrets.CI_SLACK_BOT_TOKEN }}
CI_SLACK_CHANNEL_ID: ${{ secrets.CI_SLACK_CHANNEL_ID }}
12 changes: 0 additions & 12 deletions .github/workflows/labeler.yml

This file was deleted.

89 changes: 52 additions & 37 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,52 +1,67 @@
# To run: docker run -v /path/to/wsgi.py:/var/www/manifestservice/wsgi.py --name=manifestservice -p 81:80 manifestservice
# To check running container: docker exec -it manifestservice /bin/bash
ARG AZLINUX_BASE_VERSION=master

FROM quay.io/cdis/python:python3.9-buster-2.0.0
# Base stage with python-build-base
FROM quay.io/cdis/python-build-base:${AZLINUX_BASE_VERSION} as base

# Comment this in, and comment out the line above, if quay is down
# FROM 707767160287.dkr.ecr.us-east-1.amazonaws.com/gen3/python-build-base:${AZLINUX_BASE_VERSION} as base

ENV appname=manifestservice
ENV POETRY_NO_INTERACTION=1 \
POETRY_VIRTUALENVS_IN_PROJECT=1 \
POETRY_VIRTUALENVS_CREATE=1

WORKDIR /${appname}

# create gen3 user
# Create a group 'gen3' with GID 1000 and a user 'gen3' with UID 1000
RUN groupadd -g 1000 gen3 && \
useradd -m -s /bin/bash -u 1000 -g gen3 gen3 && \
chown -R gen3:gen3 /$appname && \
chown -R gen3:gen3 /venv


# Builder stage
FROM base as builder

USER gen3


RUN python -m venv /venv

COPY poetry.lock pyproject.toml /${appname}/

RUN pip install --upgrade pip
RUN pip install poetry && \
poetry install -vv --only main --no-interaction

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

RUN apt-get update \
&& apt-get install -y --no-install-recommends\
libmcrypt4 libmhash2 mcrypt \
curl bash git vim \
&& apt-get clean
# 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

EXPOSE 80
# Final stage
FROM base

WORKDIR /$appname
COPY --from=builder /venv /venv
COPY --from=builder /$appname /$appname

# copy ONLY poetry artifact and install
# this will make sure than the dependencies is cached
COPY poetry.lock pyproject.toml /$appname/
RUN poetry config virtualenvs.create false \
&& poetry install -vv --no-root --no-dev --no-interaction \
&& poetry show -v

COPY . /$appname
COPY ./deployment/uwsgi/uwsgi.ini /etc/uwsgi/uwsgi.ini
COPY ./deployment/uwsgi/wsgi.py /$appname/wsgi.py
# Switch to non-root user 'gen3' for the serving process
USER gen3

# install Indexd and dependencies via poetry
RUN poetry config virtualenvs.create false \
&& poetry install -vv --no-dev --no-interaction \
&& poetry show -v
RUN source /venv/bin/activate

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
ENV PYTHONUNBUFFERED=1 \
PYTHONIOENCODING=UTF-8

WORKDIR /var/www/$appname
CMD ["gunicorn", "-c", "deployment/wsgi/gunicorn.conf.py"]

CMD /dockerrun.sh
# RUN apt-get update \
# && apt-get install -y --no-install-recommends\
# libmcrypt4 libmhash2 mcrypt \
# curl bash git vim \
# && apt-get clean
6 changes: 0 additions & 6 deletions Jenkinsfile

This file was deleted.

20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Manifest Service

### Overview
This service handles reading from and writing to a user's s3 folder containing their manifests. A manifest is a JSON file that lists records a researcher may be interested in analyzing. This service stores a manifest to a user folder in an s3 bucket and delivers it for later use, such as when the researcher wants to mount the manifest in their workspace. If the "prefix" config variable is set, user folders will be stored in a directory of that name within the s3 bucket.

Expand Down Expand Up @@ -48,10 +49,29 @@ Create a cohort GUID in the user's folder:
Post body: { "guid": "5183a350-9d56-4084-8a03-6471cafeb7fe" }
Returns: { "filename" : "5183a350-9d56-4084-8a03-6471cafeb7fe" }

Lists a user's exported metadata objects:

GET /metadata
Returns: { "metadata" : [ { "filename" : "metadata-2024-06-13T17-14-46.026593.json", "last_modified" : "2024-06-13 17:14:47" }, ... ] }

Create an exported metadata object in the user's folder:

POST /metadata
Post body: { "some_metadata_key": "some_metadata_value" }
Returns: { "filename" : "metadata-2024-06-13T17-14-46.026593.json" }

Read the contents of an exported metadata object file in the user's folder:

GET /metadata/<filename.json>
Returns: { "body" : "the-body-of-the-exported-metadata-object-file-as-a-string" }

On failure, the above endpoints all return JSON in the form

{ "error" : "error-message" }

### OpenAPI spec

The [OpenAPI](https://github.com/OAI/OpenAPI-Specification)/[Swagger 2.0](https://swagger.io/) specification of a service is stored in its `swagger.yaml` and can be visualized [here](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/uc-cdis/manifestservice/master/openapi/swagger.yaml).

### Running the service locally
If you want to run this service locally, fill out the config.json file with the correct values and then run:
Expand Down
23 changes: 0 additions & 23 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.
Loading
Loading