Create a Python3.9 based Dockerfile for cara to run on openshift.

This commit is contained in:
Phil Elson 2021-07-29 10:59:02 +02:00
parent 234ca99d28
commit 3103663978
7 changed files with 99 additions and 55 deletions

View file

@ -2,4 +2,5 @@ venv
env* env*
prototypes prototypes
support support
Dockerfile Dockerfile
_*

View file

@ -7,7 +7,7 @@ include:
variables: variables:
project_name: cara project_name: cara
PY_VERSION: "3.6" # This is what we have running in OpenShift currently. PY_VERSION: "3.9" # This is what we have running in OpenShift currently.
# A full installation of CARA, tested with pytest. # A full installation of CARA, tested with pytest.
@ -84,7 +84,7 @@ test_dev-39:
DOCKER_TOKEN: "${OPENSHIFT_DOCKER_TOKEN_PROD}" DOCKER_TOKEN: "${OPENSHIFT_DOCKER_TOKEN_PROD}"
script: script:
- echo "{\"auths\":{\"$DOCKER_REGISTRY\":{\"auth\":\"$DOCKER_TOKEN\"}}}" > /kaniko/.docker/config.json - echo "{\"auths\":{\"$DOCKER_REGISTRY\":{\"auth\":\"$DOCKER_TOKEN\"}}}" > /kaniko/.docker/config.json
- /kaniko/executor --context $CI_PROJECT_DIR/$DOCKERFILE_DIRECTORY --dockerfile $CI_PROJECT_DIR/$DOCKERFILE_DIRECTORY/Dockerfile --destination $DOCKER_REGISTRY/$IMAGE_NAME:latest - /kaniko/executor --context $CI_PROJECT_DIR/$DOCKER_CONTEXT_DIRECTORY --dockerfile $CI_PROJECT_DIR/$DOCKERFILE_DIRECTORY/Dockerfile --destination $DOCKER_REGISTRY/$IMAGE_NAME:latest
auth-service-image_builder: auth-service-image_builder:
@ -93,6 +93,16 @@ auth-service-image_builder:
variables: variables:
IMAGE_NAME: auth-service IMAGE_NAME: auth-service
DOCKERFILE_DIRECTORY: app-config/auth-service DOCKERFILE_DIRECTORY: app-config/auth-service
DOCKER_CONTEXT_DIRECTORY: app-config/auth-service
cara-webservice-image_builder:
extends:
- .image_builder
variables:
IMAGE_NAME: cara-webservice
DOCKERFILE_DIRECTORY: app-config/cara-webservice
DOCKER_CONTEXT_DIRECTORY: ""
trigger_build_on_openshift: trigger_build_on_openshift:
@ -101,7 +111,6 @@ trigger_build_on_openshift:
- if: '$OPENSHIFT_BUILD_WEBHOOK_SECRET' - if: '$OPENSHIFT_BUILD_WEBHOOK_SECRET'
script: script:
- curl -X POST -k https://openshift.cern.ch:443/apis/build.openshift.io/v1/namespaces/cara/buildconfigs/cara-router/webhooks/${OPENSHIFT_BUILD_WEBHOOK_SECRET}/generic - curl -X POST -k https://openshift.cern.ch:443/apis/build.openshift.io/v1/namespaces/cara/buildconfigs/cara-router/webhooks/${OPENSHIFT_BUILD_WEBHOOK_SECRET}/generic
- curl -X POST -k https://openshift.cern.ch:443/apis/build.openshift.io/v1/namespaces/cara/buildconfigs/cara-webservice/webhooks/${OPENSHIFT_BUILD_WEBHOOK_SECRET}/generic
deploy_to_test: deploy_to_test:
@ -110,7 +119,6 @@ deploy_to_test:
- if: '$CI_COMMIT_BRANCH == "live/test-cara" && $OPENSHIFT_TEST_BUILD_WEBHOOK_SECRET' - if: '$CI_COMMIT_BRANCH == "live/test-cara" && $OPENSHIFT_TEST_BUILD_WEBHOOK_SECRET'
script: script:
- 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-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
oci_calculator: oci_calculator:

View file

@ -0,0 +1,27 @@
FROM condaforge/mambaforge as conda
RUN mamba create --yes -p /opt/app python=3.9
COPY . /opt/app-source
RUN cd /opt/app-source && conda run -p /opt/app python -m pip install -r ./requirements.txt .[app]
COPY app-config/cara-webservice/app.sh /opt/app/bin/cara-app.sh
RUN cd /opt/app \
&& find -name '*.a' -delete \
&& rm -rf /opt/app/conda-meta \
&& rm -rf /opt/app/include \
&& find -name '__pycache__' -type d -exec rm -rf '{}' '+' \
&& rm -rf /opt/app/lib/python*/site-packages/pip /opt/app/lib/python*/idlelib /opt/app/lib/python*/ensurepip \
/opt/app/bin/x86_64-conda-linux-gnu-ld \
/opt/app/bin/sqlite3 \
/opt/app/bin/openssl \
/opt/app/share/terminfo \
&& find /opt/app/lib/ -name 'tests' -type d -exec rm -rf '{}' '+' \
&& find /opt/app/lib -name '*.pyx' -delete \
;
FROM debian
COPY --from=conda /opt/app /opt/app
ENV PATH=/opt/app/bin/:$PATH
CMD [ \
"cara-app.sh" \
]

View file

@ -19,5 +19,8 @@ if [[ "$APP_NAME" == "cara-webservice" ]]; then
elif [[ "$APP_NAME" == "cara-voila" ]]; then elif [[ "$APP_NAME" == "cara-voila" ]]; then
echo "Starting the voila service" echo "Starting the voila service"
voila app/ --port=8080 --no-browser --base_url=/voila-server/ --Voila.tornado_settings="{'allow_origin': '*'}" voila app/ --port=8080 --no-browser --base_url=/voila-server/ --Voila.tornado_settings="{'allow_origin': '*'}"
else
echo "No APP_NAME specified"
exit 1
fi fi

View file

@ -201,7 +201,7 @@
- name: CARA_CALCULATOR_PREFIX - name: CARA_CALCULATOR_PREFIX
value: /calculator-cern value: /calculator-cern
- name: CARA_THEME - name: CARA_THEME
value: cara/apps/calculator/themes/cern value: /opt/app/lib/python3.9/site-packages/cara/apps/calculator/themes/cern
image: '${PROJECT_NAME}/cara-webservice' image: '${PROJECT_NAME}/cara-webservice'
ports: ports:
- containerPort: 8080 - containerPort: 8080

View file

@ -1,80 +1,85 @@
# Created by installing the cara[app] extra and running: # Created by installing the cara[app] extra and running:
# echo '.[app]' > requirements.txt # echo '.[app]' > requirements.txt
# pip freeze | grep -v cara >> requirements.txt # pip list --format freeze | grep -vi cara | grep -v pip | grep -v setuptools >> requirements.txt
.[app] .[app]
anyio==2.1.0 anyio==3.3.0
appnope==0.1.2
argon2-cffi==20.1.0 argon2-cffi==20.1.0
async-generator==1.10 async-generator==1.10
attrs==20.3.0 attrs==21.2.0
backcall==0.2.0 backcall==0.2.0
bleach==3.3.0 bleach==3.3.1
certifi==2020.12.5 certifi==2021.5.30
cffi==1.14.5 cffi==1.14.6
contextvars==2.4 charset-normalizer==2.0.3
cloudpickle==1.6.0
cycler==0.10.0 cycler==0.10.0
dataclasses==0.8 debugpy==1.4.1
decorator==4.4.2 decorator==5.0.9
defusedxml==0.6.0 defusedxml==0.7.1
entrypoints==0.3 entrypoints==0.3
idna==3.1 idna==3.2
immutables==0.15 ipykernel==6.0.3
importlib-metadata==3.5.0 ipympl==0.7.0
ipykernel==5.5.0 ipython==7.25.0
ipympl==0.6.3
ipython==7.16.1
ipython-genutils==0.2.0 ipython-genutils==0.2.0
ipywidgets==7.6.3 ipywidgets==7.6.3
jedi==0.18.0 jedi==0.18.0
Jinja2==2.11.3 Jinja2==3.0.1
joblib==1.0.1
jsonschema==3.2.0 jsonschema==3.2.0
jupyter-client==6.1.11 jupyter-client==6.1.12
jupyter-core==4.7.1 jupyter-core==4.7.1
jupyter-server==1.4.1 jupyter-server==1.10.1
jupyterlab-pygments==0.1.2 jupyterlab-pygments==0.1.2
jupyterlab-widgets==1.0.0 jupyterlab-widgets==1.0.0
kiwisolver==1.3.1 kiwisolver==1.3.1
loky==2.9.0 loky==2.9.0
MarkupSafe==1.1.1 MarkupSafe==2.0.1
matplotlib==3.3.4 matplotlib==3.4.2
matplotlib-inline==0.1.2
memoization==0.3.2 memoization==0.3.2
mistune==0.8.4 mistune==0.8.4
nbclient==0.5.2 nbclient==0.5.3
nbconvert==6.0.7 nbconvert==6.1.0
nbformat==5.1.2 nbformat==5.1.3
nest-asyncio==1.5.1 nest-asyncio==1.5.1
notebook==6.2.0 notebook==6.4.0
numpy==1.19.5 numpy==1.21.1
packaging==20.9 packaging==21.0
pandocfilters==1.4.3 pandocfilters==1.4.3
parso==0.8.1 parso==0.8.2
pexpect==4.8.0 pexpect==4.8.0
pickleshare==0.7.5 pickleshare==0.7.5
Pillow==8.1.0 Pillow==8.3.1
prometheus-client==0.9.0 prometheus-client==0.11.0
prompt-toolkit==3.0.16 prompt-toolkit==3.0.19
psutil==5.8.0 psutil==5.8.0
ptyprocess==0.7.0 ptyprocess==0.7.0
pycparser==2.20 pycparser==2.20
Pygments==2.8.0 Pygments==2.9.0
pyparsing==2.4.7 pyparsing==2.4.7
pyrsistent==0.17.3 pyrsistent==0.18.0
python-dateutil==2.8.1 python-dateutil==2.8.2
pyzmq==22.0.3 pyzmq==22.1.0
qrcode==6.1 qrcode==7.2
scipy==1.5.4 requests==2.26.0
scikit_learn==0.23.1 requests-unixsocket==0.2.0
Send2Trash==1.5.0 scikit-learn==0.24.2
six==1.15.0 scipy==1.7.0
Send2Trash==1.7.1
six==1.16.0
sklearn==0.0
sniffio==1.2.0 sniffio==1.2.0
terminado==0.9.2 terminado==0.10.1
testpath==0.4.4 testpath==0.5.0
threadpoolctl==2.2.0
tornado==6.1 tornado==6.1
traitlets==4.3.3 traitlets==5.0.5
typing-extensions==3.7.4.3 urllib3==1.26.6
voila==0.2.7 voila==0.2.10
wcwidth==0.2.5 wcwidth==0.2.5
webencodings==0.5.1 webencodings==0.5.1
websocket-client==1.1.0
wheel==0.36.2
widgetsnbextension==3.5.1 widgetsnbextension==3.5.1
zipp==3.4.0

View file

@ -61,7 +61,7 @@ setup(
url='cern.ch/cara', url='cern.ch/cara',
packages=find_packages(), packages=find_packages(),
python_requires='~=3.6', python_requires='~=3.9',
classifiers=[ classifiers=[
"Programming Language :: Python :: 3", "Programming Language :: Python :: 3",
"Operating System :: OS Independent", "Operating System :: OS Independent",