Skip to content

Commit

Permalink
build images for multiple python versions
Browse files Browse the repository at this point in the history
  • Loading branch information
aperrin66 committed Oct 27, 2023
1 parent d51f853 commit f2784ea
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
28 changes: 24 additions & 4 deletions .github/workflows/build_images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ env:
jobs:
build_standard_docker_image:
runs-on: 'ubuntu-20.04'
strategy:
matrix:
python_version:
- '3.7'
- '3.8'
- '3.9'
- '3.10'
- '3.11'
- '3.12'
steps:
- name: 'Checkout repository'
uses: actions/checkout@v2
Expand All @@ -18,9 +27,9 @@ jobs:
id: get_version
run: |
if [[ $GITHUB_REF == refs/tags/* ]];then
TAG="${GITHUB_REF#refs/tags/}"
TAG="${GITHUB_REF#refs/tags/}-python${{ matrix.python_version }}"
else
TAG='tmp'
TAG='tmp-python${{ matrix.python_version }}'
fi
echo "::set-output name=VERSION::${TAG}"
Expand All @@ -46,6 +55,7 @@ jobs:
with:
context: .
file: Dockerfile
build-args: 'PYTHON_VERSION=${{ matrix.python_version }}'
push: ${{ startsWith(github.ref, 'refs/tags/') }}
tags: |
${{ env.IMAGE_NAME }}:latest
Expand All @@ -63,6 +73,15 @@ jobs:
build_slim_docker_image:
runs-on: 'ubuntu-20.04'
strategy:
matrix:
python_version:
- '3.7'
- '3.8'
- '3.9'
- '3.10'
- '3.11'
- '3.12'
steps:
- name: 'Checkout repository'
uses: actions/checkout@v2
Expand All @@ -71,9 +90,9 @@ jobs:
id: get_version
run: |
if [[ $GITHUB_REF == refs/tags/* ]];then
TAG="${GITHUB_REF#refs/tags/}"
TAG="${GITHUB_REF#refs/tags/}-python${{ matrix.python_version }}"
else
TAG='tmp'
TAG='tmp-python${{ matrix.python_version }}'
fi
echo "::set-output name=VERSION::${TAG}"
Expand All @@ -99,6 +118,7 @@ jobs:
with:
context: .
file: Dockerfile_slim
build-args: 'PYTHON_VERSION=${{ matrix.python_version }}'
push: ${{ startsWith(github.ref, 'refs/tags/') }}
tags: |
${{ env.IMAGE_NAME }}:latest-slim
Expand Down
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ FROM continuumio/miniconda3
LABEL maintainer="Anton Korosov <[email protected]>"
LABEL purpose="Python libs for developing and running Nansat"

ARG PYTHON_VERSION=3.7

ENV PYTHONUNBUFFERED=1 \
PYTHONPATH=/src \
MOD44WPATH=/usr/share/MOD44W/
Expand All @@ -15,8 +17,9 @@ RUN apt-get update \
&& rm -rf /var/lib/apt/lists/*

COPY environment.yml /tmp/environment.yml
RUN sed -i -E "s/^(\s+- python=).*$/\1${PYTHON_VERSION}/" /tmp/environment.yml

RUN conda install python=3.7 setuptools \
RUN conda install python="${PYTHON_VERSION}" setuptools \
&& conda update conda \
&& conda env update -n base --file /tmp/environment.yml \
&& rm /tmp/environment.yml \
Expand Down
4 changes: 4 additions & 0 deletions Dockerfile_slim
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@ FROM continuumio/miniconda3 as builder
LABEL maintainer="Anton Korosov <[email protected]>"
LABEL purpose="Python libs for developing and running Nansat"

ARG PYTHON_VERSION=3.7

# Install build tools
RUN apt-get update && \
apt-get install -y --no-install-recommends \
gcc \
wget

COPY environment.yml /tmp/environment.yml
RUN sed -i -E "s/^(\s+- python=).*$/\1${PYTHON_VERSION}/" /tmp/environment.yml

RUN conda env create -f /tmp/environment.yml

RUN wget -nc -nv -P /usr/share/MOD44W https://github.com/nansencenter/mod44w/raw/master/MOD44W.tgz && \
Expand Down

0 comments on commit f2784ea

Please sign in to comment.