Skip to content

Commit

Permalink
Merge pull request #16 from nansencenter/multi_python_versions
Browse files Browse the repository at this point in the history
Support multiple Python versions
  • Loading branch information
aperrin66 authored Dec 13, 2023
2 parents 2b6e3b3 + 1cd2d2d commit ef7781e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 24 deletions.
34 changes: 19 additions & 15 deletions .github/workflows/build_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@ on:
push:
branches: ['**']
release:
types: [released]
types: [prereleased, released]
env:
IMAGE_NAME: "${{ secrets.DOCKER_ORG }}/geospaas_uwsgi"
jobs:
build_docker_image:
runs-on: 'ubuntu-20.04'
runs-on: 'ubuntu-latest'
env:
latest: ${{ matrix.python_version == '3.11' && 'true' || '' }}
BASE_IMAGE: "${{ vars.DOCKER_ORG }}/geospaas:2.5.2-python${{ matrix.python_version }}"
strategy:
matrix:
python_version:
- '3.8'
- '3.9'
- '3.10'
- '3.11'
steps:
- name: 'Checkout repository'
uses: actions/checkout@v4

- name: "Extract tag name"
id: get_version
run: |
if [[ $GITHUB_REF == refs/tags/* ]];then
TAG="${GITHUB_REF#refs/tags/}"
else
TAG='tmp'
fi
echo "::set-output name=VERSION::${TAG}"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

Expand All @@ -45,10 +45,14 @@ jobs:
uses: docker/build-push-action@v5
with:
context: .
push: ${{ startsWith(github.ref, 'refs/tags/') }}
build-args: |
BASE_IMAGE=${{ env.BASE_IMAGE }}
push: ${{ github.event_name == 'release' }}
tags: |
${{ env.IMAGE_NAME }}:latest
${{ env.IMAGE_NAME }}:${{ steps.get_version.outputs.VERSION }}
${{ env.IMAGE_NAME }}:${{ github.ref_name }}-python${{ matrix.python_version }}
${{ env.latest && format('{0}:{1}', env.IMAGE_NAME, github.ref_name) || '' }}
${{ env.IMAGE_NAME }}:latest-python${{ matrix.python_version }}
${{ env.latest && format('{0}:latest', env.IMAGE_NAME) || '' }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new

Expand Down
16 changes: 7 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
FROM nansencenter/geospaas:2.5.1-slim
ARG BASE_IMAGE=nansencenter/geospaas:latest
FROM ${BASE_IMAGE} as base

ENV LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${VIRTUAL_ENV}/lib"

RUN apt update && \
apt install -y gcc && \
# Disable LTO optimization because the LTO versions from the standard
# debian buster GCC and the version of GCC used by Anaconda are different
LDFLAGS='-fno-lto' pip install uwsgi && \
apt remove -y gcc && \
apt clean && apt autoremove -y && \
rm -rf /var/lib/apt/lists/*
RUN conda install -y uwsgi \
&& conda clean -a -y -f \
&& rm /opt/conda/pkgs/* -rf \
&& find /opt/conda/ -follow -type f -name '*.a' -delete \
&& find /opt/conda/ -follow -type f -name '*.pyc' -delete

WORKDIR /opt/geospaas-app

Expand Down

0 comments on commit ef7781e

Please sign in to comment.