Skip to content

Commit f321573

Browse files
authored
Merge pull request #857 from RS-PYTHON/feat/rspy570-empty-dpr-processor
feat: build dask-gateway + rs-server-staging image
2 parents 44be64f + 281c12c commit f321573

File tree

18 files changed

+1053
-892
lines changed

18 files changed

+1053
-892
lines changed

.github/actions/publish-docker/action.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ inputs:
2222
build_context_path:
2323
description: "'docker build' context path"
2424
required: true
25+
image_basename:
26+
description: Docker image base name
27+
default: ${{ github.repository }} # = owner/repository-name
2528
image_suffix:
2629
description: Docker image name suffix e.g. _services-cadip
2730
required: true
@@ -46,6 +49,9 @@ inputs:
4649
debug_mode:
4750
description: Add debug tools to the docker image
4851
required: false
52+
build_args:
53+
description: List of build-time variables
54+
required: false
4955

5056
outputs:
5157
docker_image:
@@ -78,7 +84,7 @@ runs:
7884
# Full Docker image name:tag as ghcr.io/RS-PYTHON/rs-server<suffix>:<version> in lowercase
7985
- id: docker_image
8086
run: |
81-
docker_image=${{ env.DOCKER_REGISTRY }}/${{ github.repository }}${{ inputs.image_suffix }}:${{ env.docker_version_name }}
87+
docker_image=${{ env.DOCKER_REGISTRY }}/${{ inputs.image_basename }}${{ inputs.image_suffix }}:${{ env.docker_version_name }}
8288
docker_image=${docker_image,,} # lowercase
8389
echo docker_image=${docker_image} >> $GITHUB_ENV
8490
echo docker_image=${docker_image} >> $GITHUB_OUTPUT
@@ -130,6 +136,7 @@ runs:
130136
tags: ${{ env.docker_image }}
131137
labels: ${{ steps.meta.outputs.labels }}
132138
push: false # push after the security scans below
139+
build-args: ${{ inputs.build_args }}
133140

134141
- name: Run Trivy vulnerability scanner
135142
uses: aquasecurity/trivy-action@master

.github/workflows/publish-binaries.yml

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -261,15 +261,6 @@ jobs:
261261
fetch-depth: 0 # so that Dunamai produce the correct version
262262
- uses: ./.github/actions/install-python
263263

264-
# To pull ghcr.io/rs-python/apikey-manager
265-
# TODO: to be changed when the apikey manager will have its own container registry.
266-
- name: Log into Docker registry
267-
uses: docker/login-action@v3
268-
with:
269-
registry: ${{ env.DOCKER_REGISTRY }}
270-
username: ${{ github.actor }}
271-
password: ${{ secrets.GITHUB_TOKEN }}
272-
273264
- name: Generate the aggregated openapi.json/swagger
274265
run: |
275266
set -x
@@ -524,6 +515,50 @@ jobs:
524515
branch_name: ${{ needs.set-env.outputs.branch_name }}
525516
debug_mode: ${{ needs.set-env.outputs.debug_mode }}
526517

518+
dask-staging-local-img:
519+
if: github.actor != 'dependabot[bot]'
520+
runs-on: ubuntu-latest
521+
name: "'dask-gateway-server/staging/local' Docker image"
522+
# TODO: this has to be activated when the pydantic conflict is solved
523+
#needs: [set-env, services-common-whl, services-staging-whl]
524+
# TODO: this has to be deleted when the pydantic conflict is solved
525+
needs: [set-env, services-staging-whl]
526+
permissions: write-all
527+
outputs:
528+
docker_image: ${{ steps.publish-docker.outputs.docker_image}}
529+
steps:
530+
- uses: actions/checkout@v4
531+
532+
# Download .whl files into a local dir
533+
# TODO: the next 5 commented lines must be reactivated when the pydantic conflict is solved
534+
#- name: Download .whl dependencies
535+
# uses: actions/download-artifact@v4
536+
# with:
537+
# name: ${{ needs.services-common-whl.outputs.package_name }}
538+
# path: ./whl
539+
- name: Download .whl dependencies
540+
uses: actions/download-artifact@v4
541+
with:
542+
name: ${{ needs.services-staging-whl.outputs.package_name }}
543+
path: ./build_context_path
544+
545+
- id: publish-docker
546+
uses: ./.github/actions/publish-docker
547+
with:
548+
dockerfile: ./services/staging/.github/Dockerfile.dask-staging-local
549+
build_context_path: ./build_context_path
550+
image_basename: "${{ github.repository_owner }}/dask-gateway-server"
551+
image_suffix: /staging/local
552+
version_name: ${{ needs.services-staging-whl.outputs.version_name }}
553+
dockerhub_username: ${{ vars.DOCKERHUB_USERNAME }}
554+
dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }}
555+
github_token: ${{ secrets.GITHUB_TOKEN }}
556+
docker_tag: ${{ needs.set-env.outputs.docker_tag }}
557+
branch_name: ${{ needs.set-env.outputs.branch_name }}
558+
debug_mode: false
559+
build_args: |
560+
DASK_GATEWAY_TAG=2024.1.0
561+
527562
###########
528563
# TESTING #
529564
###########

poetry.lock

Lines changed: 112 additions & 104 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/apt_upgrade_images.sh

Lines changed: 51 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ images=\
2323
"jupyter/minimal-notebook:latest "\
2424
"quay.io/jupyter/base-notebook:hub-4.1.5"\
2525

26+
# Target images will be:
27+
# ghcr.io/rs-python/python:3.11.7-slim-bookworm
28+
# ghcr.io/rs-python/jupyter/minimal-notebook:latest
29+
# ghcr.io/rs-python/quay.io/jupyter/base-notebook:hub-4.1.5
30+
2631
dockerdir="/tmp/dockerfile"
2732
dockerfile="$dockerdir/Dockerfile"
2833
mkdir -p "$dockerdir"
@@ -34,23 +39,64 @@ for image in $images; do
3439
# Save the default user in the image
3540
user=$(docker run --rm --entrypoint whoami "$image")
3641

42+
# Add our hosting github organization to the docker image
43+
target="ghcr.io/rs-python/$image"
44+
3745
# Create a tmp Dockerfile that pulls and update the image.
3846
cat << EOF > "$dockerfile"
3947
FROM $image
4048
USER root
4149
RUN apt update && apt upgrade -y
4250
USER $user
4351
52+
# Upgrade pip version
53+
RUN pip install -U pip
54+
55+
# Set labels based on the Open Containers Initiative (OCI):
56+
# https://github.com/opencontainers/image-spec/blob/main/annotations.md#pre-defined-annotation-keys
57+
#
58+
LABEL org.opencontainers.image.source="https://github.com/RS-PYTHON/rs-server"
59+
LABEL org.opencontainers.image.ref.name="$target"
60+
LABEL dockerfile.url="https://github.com/RS-PYTHON/rs-server/blob/develop/resources/apt_upgrade_images.sh"
61+
4462
# Note: don't remove cache so the child images that use this one as a base will build faster
45-
# RUN rm -rf /var/cache/apt/archives /var/lib/apt/lists/*
63+
# RUN rm -rf /var/cache/apt/archives /var/lib/apt/lists/*
4664
EOF
4765

48-
cat "$dockerfile"
66+
# For the jupyter images
67+
if [[ $image == *"jupyter"* ]]; then
4968

50-
# Add our hosting github organization to the docker image
51-
target="ghcr.io/rs-python/$image"
69+
DASK_TAG=2024.5.2
70+
DASK_GATEWAY_TAG=2024.1.0
71+
PREFECT_TAG=3.1.4
72+
73+
cat << EOF >> "$dockerfile"
74+
75+
# Install python 3.11.7 using conda then prefect and dask and other packages.
76+
# The versions must be the same than the cluster images.
77+
RUN conda install --yes conda-forge::python="3.11.7"
78+
79+
# Note: put s3fs before boto3 to have a recent version
80+
RUN pip install \
81+
dask[complete]=="${DASK_TAG}" \
82+
distributed=="${DASK_TAG}" \
83+
dask-gateway=="${DASK_GATEWAY_TAG}" \
84+
prefect[dask,aws]=="${PREFECT_TAG}" \
85+
ipywidgets \
86+
s3fs \
87+
boto3
88+
89+
# Install dot and clean conda
90+
USER root
91+
RUN apt install -y python3-pydot graphviz
92+
RUN conda clean --all --yes
93+
USER jovyan
94+
EOF
95+
fi
96+
97+
cat "$dockerfile"
5298

5399
# Build and publish the image
54-
docker build -f "$dockerfile" -t "$target" "$dockerdir"
100+
docker build --progress plain -f "$dockerfile" -t "$target" "$dockerdir"
55101
docker push "$target"
56102
done

resources/deploy_stac_browser.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,20 @@ else
3838
cd "stac-browser"
3939
fi
4040

41+
registry="ghcr.io/rs-python/stac-browser"
42+
43+
# Set labels based on the Open Containers Initiative (OCI):
44+
# https://github.com/opencontainers/image-spec/blob/main/annotations.md#pre-defined-annotation-keys
45+
cat << EOF >> "Dockerfile"
46+
LABEL org.opencontainers.image.source="https://github.com/RS-PYTHON/rs-server"
47+
LABEL org.opencontainers.image.ref.name="$registry"
48+
LABEL dockerfile.url="https://github.com/RS-PYTHON/rs-server/blob/develop/resources/deploy_stac_browser.sh"
49+
EOF
50+
4151
# Docker image tag = 'last commit hash'.'last commit date'
4252
tag="$(git rev-parse --short HEAD).$(git log -1 --format="%at" | xargs -I{} date -d @{} +%Y-%m-%d)"
4353

4454
# Build Docker image with tag + latest. It will be pushed to the rs-server registry.
45-
registry="ghcr.io/rs-python/stac-browser"
4655
docker build -t "${registry}:latest" -t "${registry}:${tag}" .
4756

4857
# Push the images

services/adgs/.github/Dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,10 @@ USER user
6464
ENTRYPOINT [ \
6565
"python", "-m", "uvicorn", "rs_server_adgs.fastapi.adgs_app:app", \
6666
"--host", "0.0.0.0", "--port", "8000", "[DEBUG_MODE_RELOAD]" ]
67+
68+
# Set labels based on the Open Containers Initiative (OCI):
69+
# https://github.com/opencontainers/image-spec/blob/main/annotations.md#pre-defined-annotation-keys
70+
#
71+
LABEL org.opencontainers.image.source="https://github.com/RS-PYTHON/rs-server"
72+
LABEL org.opencontainers.image.ref.name="ghcr.io/rs-python/rs-server-adgs"
73+
LABEL dockerfile.url="https://github.com/RS-PYTHON/rs-server/blob/develop/services/adgs/.github/Dockerfile"

0 commit comments

Comments
 (0)