Skip to content
Snippets Groups Projects
Commit 35dfef23 authored by Jeremy M Fee's avatar Jeremy M Fee
Browse files

Merge branch 'update-container' into 'master'

Update how container builds (remove conda)

See merge request !56
parents d8b05e53 3a0af235
No related branches found
No related tags found
2 merge requests!146Release CMO metadata to production,!56Update how container builds (remove conda)
Pipeline #28116 passed
......@@ -18,7 +18,7 @@ variables:
TRIVY_VERSION: "0.13.0"
# docker variables
DOCKER_DRIVER: overlay2
FROM_IMAGE: ${CODE_REGISTRY}/devops/images/usgs/centos:7
FROM_IMAGE: ${CODE_REGISTRY}/devops/images/usgs/obspy:3.8
# environment variables
APP_NAME: geomag-algorithms
DATA_HOST: "cwbpub.cr.usgs.gov"
......@@ -67,15 +67,20 @@ variables:
- build
.check_code:
image: ${DEVOPS_REGISTRY}usgs/conda:latest
script:
- export PYTHON_VERSION=${PYTHON_VERSION:-3.8}
- scripts/ci_check_code.sh
artifacts:
paths:
- cov.xml
reports:
junit: cov.xml
cobertura: cov.xml
junit: junit.xml
before_script:
# install dependencies
- pipenv --site-packages install --dev --pre --skip-lock
- pipenv run which python
image: ${DEVOPS_REGISTRY}usgs/obspy:latest
script:
# run checks
- pipenv run black --check .
- pipenv run pytest --cov=geomagio --cov-report xml:cov.xml --junitxml junit.xml
- pipenv run safety check
stage: test
tags:
- development
......@@ -148,23 +153,12 @@ variables:
Check Python 3.6:
extends:
- .check_code
script:
- export PYTHON_VERSION=3.6
- scripts/ci_check_code.sh
Check Python 3.7:
extends:
- .check_code
script:
- export PYTHON_VERSION=3.7
- scripts/ci_check_code.sh
image: ${DEVOPS_REGISTRY}usgs/obspy:3
Check Python 3.8:
extends:
- .check_code
script:
- export PYTHON_VERSION=3.8
- scripts/ci_check_code.sh
image: ${DEVOPS_REGISTRY}usgs/obspy:3.8
## --------------------------------------------------
# Integration Stage
......
ARG FROM_IMAGE=usgs/centos:7
ARG FROM_IMAGE=usgs/obspy:3.8
FROM ${FROM_IMAGE} as conda
FROM ${FROM_IMAGE}
LABEL maintainer="Jeremy Fee <jmfee@usgs.gov>"
ARG GIT_BRANCH_NAME=none
ARG GIT_COMMIT_SHA=none
ARG WEBSERVICE="false"
# set environment variables
ENV GIT_BRANCH_NAME=${GIT_BRANCH_NAME} \
GIT_COMMIT_SHA=${GIT_COMMIT_SHA} \
LANG='en_US.UTF-8' \
LC_ALL='en_US.UTF-8' \
PATH=/conda/bin:$PATH \
PIP_CERT=${SSL_CERT_FILE} \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
REQUESTS_CA_BUNDLE=${SSL_CERT_FILE}
WEBSERVICE=${WEBSERVICE}
# install conda
RUN echo 'export PATH=/conda/bin:$PATH' > /etc/profile.d/conda.sh \
&& curl \
https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh \
-o ~/miniconda.sh \
&& /bin/bash ~/miniconda.sh -b -p /conda \
&& rm ~/miniconda.sh
# install dependencies via conda
RUN conda config --set ssl_verify $SSL_CERT_FILE \
&& conda config --add channels conda-forge \
&& conda install --yes python=3.7 jupyter obspy pycurl \
&& conda clean --all -y \
&& export PIP_CERT=$SSL_CERT_FILE \
&& pip install pipenv 'virtualenv!=20.0.22' \
&& yum install -y which \
&& yum clean all
################################################################################
## Development image
# build by running
# docker build -t geomag-algorithms-development --target development .
FROM conda as development
# install dependencies via pipenv
WORKDIR /geomag-algorithms
COPY Pipfile /geomag-algorithms
RUN pipenv --site-packages install --dev --skip-lock
# copy library (ignores set in .dockerignore)
COPY . /geomag-algorithms
################################################################################
## Production image
FROM conda
RUN useradd \
-c 'Docker image user' \
......@@ -72,12 +27,11 @@ USER geomag_user
# install dependencies via pipenv
WORKDIR /data
COPY Pipfile /data/
RUN pipenv --site-packages install --skip-lock
RUN pipenv --site-packages install --dev --skip-lock
# copy library (ignores set in .dockerignore)
COPY . /geomag-algorithms
EXPOSE 8000
# entrypoint needs double quotes
ENTRYPOINT [ "/geomag-algorithms/docker-entrypoint.sh" ]
EXPOSE 8000
......@@ -6,6 +6,7 @@ verify_ssl = true
[dev-packages]
bandit = "*"
black = "==20.8b1"
jupyter = "*"
pre-commit = "*"
pytest = "*"
pytest-cov = "*"
......
......@@ -7,9 +7,10 @@ export WEBSERVICE=${WEBSERVICE:-false}
export PYTHONPATH=/geomag-algorithms
if [ $WEBSERVICE = 'false' ]; then
if [ "${WEBSERVICE}" = "false" ]; then
# run jupyter notebook server
exec jupyter notebook \
exec pipenv run jupyter \
notebook \
--ip='*' \
--notebook-dir=/data \
--no-browser \
......
#! /bin/bash -ex
PYTHON_VERSION=${PYTHON_VERSION:-"3.8"}
if [ -f "/etc/profile.d/conda.sh" ]; then
# Add conda to path
source /etc/profile.d/conda.sh
fi
# Install Project Dependencies
conda config --add channels conda-forge
conda install python=${PYTHON_VERSION} obspy pycurl
pip install pipenv
pipenv --site-packages install --dev --pre --skip-lock
pipenv run which python
# Run Code Checks
pipenv run black --check .
pipenv run pytest --cov-report xml:cov.xml --cov=geomagio
pipenv run safety check
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment