diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2103491b..5df28185 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -37,3 +37,18 @@ deploy_to_test: - curl -X POST -k https://openshift-dev.cern.ch:443/apis/build.openshift.io/v1/namespaces/test-cara/buildconfigs/cara-router/webhooks/${OPENSHIFT_TEST_BUILD_WEBHOOK_SECRET}/generic - curl -X POST -k https://openshift-dev.cern.ch:443/apis/build.openshift.io/v1/namespaces/test-cara/buildconfigs/cara-webservice/webhooks/${OPENSHIFT_TEST_BUILD_WEBHOOK_SECRET}/generic - curl -X POST -k https://openshift-dev.cern.ch:443/apis/build.openshift.io/v1/namespaces/test-cara/buildconfigs/auth-service/webhooks/${OPENSHIFT_TEST_BUILD_WEBHOOK_SECRET}/generic + + +oci_calculator: + # A convenient way for users to run the CARA calculator. + stage: deploy + image: + name: gitlab-registry.cern.ch/ci-tools/docker-image-builder + entrypoint: [""] + script: + # Prepare Kaniko configuration file + - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json + # Build and push the image from the Dockerfile at the root of the project. + # To push to a specific docker tag, amend the --destination parameter, e.g. --destination $CI_REGISTRY_IMAGE:$CI_BUILD_REF_NAME + # See https://docs.gitlab.com/ee/ci/variables/predefined_variables.html#variables-reference for available variables + - /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE/calculator:latest diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..0cb78092 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.6 + +COPY ./ /opt/cara/src +RUN python -m venv /opt/cara/app +RUN cd /opt/cara/src && /opt/cara/app/bin/pip install -r /opt/cara/src/requirements.txt +EXPOSE 8080 +ENTRYPOINT ["/bin/sh", "-c", "echo 'CARA is running on http://localhost:8080' && echo 'Please see https://gitlab.cern.ch/cara/cara for terms of use.' && /opt/cara/app/bin/python -m cara.apps.calculator --no-debug"] diff --git a/README.md b/README.md index e75fdbd4..0967912a 100644 --- a/README.md +++ b/README.md @@ -59,9 +59,20 @@ The software is provided "as is", without warranty of any kind, express or impli In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software. +## Running CARA locally + +The easiest way to run a version of CARA Calculator is to use docker. A pre-built +image of CARA is made available at https://gitlab.cern.ch/cara/cara/container_registry. +In order to run cara locally with docker, run the following: + + $ docker run -it -p 8080:8080 gitlab-registry.cern.ch/cara/cara/calculator + +This will start a local version of CARA, which can be visited at http://localhost:8080/. + + ## Development guide -### Running the COVID calculator app locally +### Running the COVID calculator app in development mode ``` pip install -e . # At the root of the repository @@ -74,7 +85,7 @@ To run with the CERN theme: python -m cara.apps.calculator --theme=cara/apps/calculator/themes/cern ``` -### Running the CARA Expert-App app locally +### Running the CARA Expert-App app in development mode ``` pip install -e . # At the root of the repository @@ -92,7 +103,7 @@ pip install -e .[test] pytest ./cara ``` -### Building the whole environment for local execution +### Building the whole environment for local development **Simulate the docker build that takes place on openshift with:** @@ -217,3 +228,4 @@ $ oc process -f route.yaml --param HOST='test-cara.web.cern.ch' | oc replace -f ``` Be aware that if you change/replace the **route** of the PROD instance, it will loose the annotation to be exposed outside CERN (not committed in this repo). +