From 3ee37ab20482884844bcec02eb882a99301ae273 Mon Sep 17 00:00:00 2001
From: Jeremy Fee <jmfee@usgs.gov>
Date: Tue, 17 Aug 2021 12:37:12 -0600
Subject: [PATCH] Update docker build to use new usgs/python:3.8-obspy image

---
 Dockerfile | 60 +++++-------------------------------------------------
 1 file changed, 5 insertions(+), 55 deletions(-)

diff --git a/Dockerfile b/Dockerfile
index 8bcc278a..ec156e04 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,56 +1,7 @@
-ARG FROM_IMAGE=usgs/centos:7
+ARG FROM_IMAGE=usgs/python:3.8-obspy
 
 
-################################################################################
-# base python image
-
-FROM ${FROM_IMAGE} as python
-ARG PYTHON_VERSION=38
-
-LABEL maintainer="Jeremy Fee <jmfee@usgs.gov>"
-
-# put rh-python38 at start of path
-ENV PATH="/opt/rh/rh-python38/root/usr/bin:/opt/rh/rh-python38/root/usr/local/bin:${PATH}"
-# configure ssl intercept
-ENV PIP_CERT="${SSL_CERT_FILE}"
-ENV REQUESTS_CA_BUNDLE="${SSL_CERT_FILE}"
-
-RUN yum install -y \
-    centos-release-scl \
-    glibc-langpack-en \
-    which \
-    && yum install -y rh-python${PYTHON_VERSION} \
-    && python -m pip install -U \
-    pip \
-    poetry \
-    wheel \
-    && yum clean all
-
-
-################################################################################
-# python builder image
-
-FROM python as obspy
-ARG PYTHON_VERSION=38
-
-# build with compilers in separate stage
-RUN yum groupinstall -y "Development Tools"
-RUN yum install -y rh-python${PYTHON_VERSION}-python-devel
-ENV LD_LIBRARY_PATH="/opt/rh/rh-python${PYTHON_VERSION}/root/usr/lib64"
-ENV PKG_CONFIG_PATH="/opt/rh/rh-python${PYTHON_VERSION}/root/usr/lib64/pkgconfig"
-
-# obspy
-RUN python -m pip wheel obspy --wheel-dir /wheels
-# pycurl
-RUN yum install -y libcurl-devel openssl-devel
-RUN export PYCURL_SSL_LIBRARY=nss \
-    && python -m pip wheel pycurl --wheel-dir /wheels
-
-
-################################################################################
-# geomag-algorithms image
-
-FROM python
+FROM ${FROM_IMAGE}
 
 ARG GIT_BRANCH_NAME=none
 ARG GIT_COMMIT_SHA=none
@@ -61,9 +12,8 @@ ENV GIT_BRANCH_NAME=${GIT_BRANCH_NAME} \
     GIT_COMMIT_SHA=${GIT_COMMIT_SHA} \
     WEBSERVICE=${WEBSERVICE}
 
-# install obspy and pycurl using wheels
-COPY --from=obspy /wheels /wheels
-RUN python -m pip install --find-links file:///wheels obspy pycurl
+# install to system python
+USER root
 
 # install packages when dependencies change
 COPY pyproject.toml poetry.lock /geomag-algorithms/
@@ -73,7 +23,7 @@ RUN cd /geomag-algorithms \
     # only install dependencies, not project
     && poetry install --no-root
 
-# install rest of library as editable
+# install rest of library separate from dependencies
 COPY . /geomag-algorithms
 RUN cd /geomag-algorithms \
     # now install project to install scripts
-- 
GitLab