Skip to content

Commit

Permalink
ci(docker): build image for each Python version (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
uniqueg committed May 2, 2021
1 parent ac6767b commit 68a2513
Show file tree
Hide file tree
Showing 5 changed files with 187 additions and 4 deletions.
39 changes: 36 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,44 @@ jobs:
fi
- |
docker build . \
-f "${TRAVIS_BUILD_DIR}/docker/Dockerfile_py3.6" \
-t "${DOCKER_REPO_NAME}:${DOCKER_TAG}-py3.6" \
|| travis_terminate 1
- |
docker build . \
-f "${TRAVIS_BUILD_DIR}/docker/Dockerfile_py3.7" \
-t "${DOCKER_REPO_NAME}:${DOCKER_TAG}-py3.7" \
|| travis_terminate 1
- |
docker build . \
-f "${TRAVIS_BUILD_DIR}/docker/Dockerfile_py3.8" \
-t "${DOCKER_REPO_NAME}:${DOCKER_TAG}-py3.8" \
|| travis_terminate 1
- |
docker build . \
-f "${TRAVIS_BUILD_DIR}/docker/Dockerfile_py3.9" \
-t "${DOCKER_REPO_NAME}:${DOCKER_TAG}-py3.9" \
|| travis_terminate 1
- |
docker build . \
-f "${TRAVIS_BUILD_DIR}/docker/Dockerfile_py3.9" \
-t "${DOCKER_REPO_NAME}:latest" \
-t "${DOCKER_REPO_NAME}:${DOCKER_TAG}" \
|| travis_terminate 1
- echo "${DOCKER_TOKEN}" | docker login -u "${DOCKER_USER}" --password-stdin
- docker push "${DOCKER_REPO_NAME}:${DOCKER_TAG}"
- |
echo "${DOCKER_TOKEN}" | \
docker login -u "${DOCKER_USER}" --password-stdin
- |
docker push "${DOCKER_REPO_NAME}:${DOCKER_TAG}-py3.6" \
|| travis_terminate 1
- |
docker push "${DOCKER_REPO_NAME}:${DOCKER_TAG}-py3.7" \
|| travis_terminate 1
- |
docker push "${DOCKER_REPO_NAME}:${DOCKER_TAG}-py3.8" \
|| travis_terminate 1
- |
docker push "${DOCKER_REPO_NAME}:${DOCKER_TAG}-py3.9" \
|| travis_terminate 1
- if [ "$TRAVIS_BRANCH" = "dev" ]; then docker push "${DOCKER_REPO_NAME}:latest"; fi
- rm ${HOME}/.docker/config.json # delete token

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile → docker/Dockerfile_py3.6
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ RUN apt-get update && \
WORKDIR /app

# Install Python dependencies
COPY requirements.txt setup.py README.md ./
COPY requirements.txt ./
RUN pip install \
--no-warn-script-location \
--prefix="/install" \
Expand Down
50 changes: 50 additions & 0 deletions docker/Dockerfile_py3.7
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
FROM python:3.7-slim-stretch as base

# Metadata
LABEL software="FOCA"
LABEL software.description="Kickstart OpenAPI-based microservice development with Flask & Connexion"
LABEL software.website="https://github.com/elixir-cloud-aai/foca"
LABEL software.license="https://spdx.org/licenses/Apache-2.0"
LABEL maintainer="alexander.kanitz@alumni.ethz.ch"
LABEL maintainer.organisation="ELIXIR Cloud & AAI"

# Build image
FROM base as builder

# Install general dependencies
ENV PACKAGES openssl git build-essential python3-dev curl jq
RUN apt-get update && \
apt-get install -y --no-install-recommends ${PACKAGES} && \
rm -rf /var/lib/apt/lists/*
WORKDIR /app

# Install Python dependencies
COPY requirements.txt ./
RUN pip install \
--no-warn-script-location \
--prefix="/install" \
-r requirements.txt

# Install FOCA
COPY setup.py README.md ./
COPY foca/ ./foca/
RUN pip install . \
--no-warn-script-location \
--prefix="/install"

# Final image
FROM base

# Python UserID workaround for OpenShift/K8S
ENV LOGNAME=ipython
ENV USER=ipython
ENV HOME=/tmp/user

# Install general dependencies
ENV PACKAGES openssl git build-essential python3-dev curl jq
RUN apt-get update && \
apt-get install -y --no-install-recommends ${PACKAGES} && \
rm -rf /var/lib/apt/lists/*

# Copy Python packages
COPY --from=builder /install /usr/local
50 changes: 50 additions & 0 deletions docker/Dockerfile_py3.8
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
FROM python:3.8-slim-buster as base

# Metadata
LABEL software="FOCA"
LABEL software.description="Kickstart OpenAPI-based microservice development with Flask & Connexion"
LABEL software.website="https://github.com/elixir-cloud-aai/foca"
LABEL software.license="https://spdx.org/licenses/Apache-2.0"
LABEL maintainer="alexander.kanitz@alumni.ethz.ch"
LABEL maintainer.organisation="ELIXIR Cloud & AAI"

# Build image
FROM base as builder

# Install general dependencies
ENV PACKAGES openssl git build-essential python3-dev curl jq
RUN apt-get update && \
apt-get install -y --no-install-recommends ${PACKAGES} && \
rm -rf /var/lib/apt/lists/*
WORKDIR /app

# Install Python dependencies
COPY requirements.txt ./
RUN pip install \
--no-warn-script-location \
--prefix="/install" \
-r requirements.txt

# Install FOCA
COPY setup.py README.md ./
COPY foca/ ./foca/
RUN pip install . \
--no-warn-script-location \
--prefix="/install"

# Final image
FROM base

# Python UserID workaround for OpenShift/K8S
ENV LOGNAME=ipython
ENV USER=ipython
ENV HOME=/tmp/user

# Install general dependencies
ENV PACKAGES openssl git build-essential python3-dev curl jq
RUN apt-get update && \
apt-get install -y --no-install-recommends ${PACKAGES} && \
rm -rf /var/lib/apt/lists/*

# Copy Python packages
COPY --from=builder /install /usr/local
50 changes: 50 additions & 0 deletions docker/Dockerfile_py3.9
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
FROM python:3.9-slim-buster as base

# Metadata
LABEL software="FOCA"
LABEL software.description="Kickstart OpenAPI-based microservice development with Flask & Connexion"
LABEL software.website="https://github.com/elixir-cloud-aai/foca"
LABEL software.license="https://spdx.org/licenses/Apache-2.0"
LABEL maintainer="alexander.kanitz@alumni.ethz.ch"
LABEL maintainer.organisation="ELIXIR Cloud & AAI"

# Build image
FROM base as builder

# Install general dependencies
ENV PACKAGES openssl git build-essential python3-dev curl jq
RUN apt-get update && \
apt-get install -y --no-install-recommends ${PACKAGES} && \
rm -rf /var/lib/apt/lists/*
WORKDIR /app

# Install Python dependencies
COPY requirements.txt README.md ./
RUN pip install \
--no-warn-script-location \
--prefix="/install" \
-r requirements.txt

# Install FOCA
COPY setup.py ./
COPY foca/ ./foca/
RUN pip install . \
--no-warn-script-location \
--prefix="/install"

# Final image
FROM base

# Python UserID workaround for OpenShift/K8S
ENV LOGNAME=ipython
ENV USER=ipython
ENV HOME=/tmp/user

# Install general dependencies
ENV PACKAGES openssl git build-essential python3-dev curl jq
RUN apt-get update && \
apt-get install -y --no-install-recommends ${PACKAGES} && \
rm -rf /var/lib/apt/lists/*

# Copy Python packages
COPY --from=builder /install /usr/local

0 comments on commit 68a2513

Please sign in to comment.