File tree Expand file tree Collapse file tree
[% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab[% endif %]/workflows Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ ARG PYTHON_VERSION=3.12
66# Dev image is used for development and cicd.
77# #######################################################################################
88
9- FROM python:${PYTHON_VERSION} as dev
9+ FROM python:${PYTHON_VERSION} AS dev
1010
1111# NOTE: python docker image has env `PYTHON_VERSION` but with patch version.
1212# ARG is used here for temporary override without changing the original env.
@@ -67,7 +67,7 @@ WORKDIR /workspace
6767# Build image is an intermediate image used for building the project.
6868# #######################################################################################
6969
70- FROM dev as build
70+ FROM dev AS build
7171
7272# Install dependencies and project into the local packages directory.
7373ARG SCM_VERSION
@@ -81,7 +81,7 @@ RUN --mount=source=README.md,target=README.md \
8181# Prod image is used for deployment and distribution.
8282# #######################################################################################
8383
84- FROM python:${PYTHON_VERSION}-slim as prod
84+ FROM python:${PYTHON_VERSION}-slim AS prod
8585
8686# NOTE: python docker image has env `PYTHON_VERSION` but with patch version.
8787# ARG is used here for temporary override without changing the original env.
Original file line number Diff line number Diff line change @@ -44,11 +44,21 @@ dev-container-publish:
4444 - |
4545 docker buildx build . \
4646 --build-arg PYTHON_VERSION=${PYTHON_VERSION} \
47- --cache-to type=registry,ref=${CI_REGISTRY_IMAGE}/dev-cache:py${PYTHON_VERSION},mode=max \
4847 --file .devcontainer/Dockerfile \
49- --push \
50- --tag ${CI_REGISTRY_IMAGE}/dev:py${PYTHON_VERSION} \
51- --target dev
48+ --load \
49+ --tag ${CI_REGISTRY_IMAGE}:py${PYTHON_VERSION} \
50+ --target prod
51+ - docker run --rm ${CI_REGISTRY_IMAGE}:py${PYTHON_VERSION}
52+ - |
53+ if [ "$CI_PIPELINE_SOURCE" != "merge_request_event" ]; then
54+ docker buildx build . \
55+ --build-arg PYTHON_VERSION=${PYTHON_VERSION} \
56+ --cache-to type=registry,ref=${CI_REGISTRY_IMAGE}/dev-cache:py${PYTHON_VERSION},mode=max \
57+ --file .devcontainer/Dockerfile \
58+ --push \
59+ --tag ${CI_REGISTRY_IMAGE}/dev:py${PYTHON_VERSION} \
60+ --target dev
61+ fi
5262 services :
5363 - docker:27.3.1@sha256:bec82cb05983f12a14d8f169b00748f4ded8573f4da5f1d15d375b6a2470289f
5464 stage : build
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ ARG PYTHON_VERSION={{ default_py }}
66# Dev image is used for development and cicd.
77########################################################################################
88
9- FROM python:${PYTHON_VERSION} as dev
9+ FROM python:${PYTHON_VERSION} AS dev
1010
1111# NOTE: python docker image has env `PYTHON_VERSION` but with patch version.
1212# ARG is used here for temporary override without changing the original env.
@@ -67,7 +67,7 @@ WORKDIR /workspace
6767# Build image is an intermediate image used for building the project.
6868########################################################################################
6969
70- FROM dev as build
70+ FROM dev AS build
7171
7272# Install dependencies and project into the local packages directory.
7373ARG SCM_VERSION
@@ -81,7 +81,7 @@ RUN --mount=source=README.md,target=README.md \
8181# Prod image is used for deployment and distribution.
8282########################################################################################
8383
84- FROM python:${PYTHON_VERSION}-slim as prod
84+ FROM python:${PYTHON_VERSION}-slim AS prod
8585
8686# NOTE: python docker image has env `PYTHON_VERSION` but with patch version.
8787# ARG is used here for temporary override without changing the original env.
Original file line number Diff line number Diff line change @@ -55,11 +55,21 @@ dev-container-publish:
5555 - |
5656 docker buildx build . \
5757 --build-arg PYTHON_VERSION=${PYTHON_VERSION} \
58- --cache-to type=registry,ref=${CI_REGISTRY_IMAGE}/dev-cache:py${PYTHON_VERSION},mode=max \
5958 --file .devcontainer/Dockerfile \
60- --push \
61- --tag ${CI_REGISTRY_IMAGE}/dev:py${PYTHON_VERSION} \
62- --target dev
59+ --load \
60+ --tag ${CI_REGISTRY_IMAGE}:py${PYTHON_VERSION} \
61+ --target prod
62+ - docker run --rm ${CI_REGISTRY_IMAGE}:py${PYTHON_VERSION}
63+ - |
64+ if [ "$CI_PIPELINE_SOURCE" != "merge_request_event" ]; then
65+ docker buildx build . \
66+ --build-arg PYTHON_VERSION=${PYTHON_VERSION} \
67+ --cache-to type=registry,ref=${CI_REGISTRY_IMAGE}/dev-cache:py${PYTHON_VERSION},mode=max \
68+ --file .devcontainer/Dockerfile \
69+ --push \
70+ --tag ${CI_REGISTRY_IMAGE}/dev:py${PYTHON_VERSION} \
71+ --target dev
72+ fi
6373 services:
6474 - docker:27.3.1@sha256:bec82cb05983f12a14d8f169b00748f4ded8573f4da5f1d15d375b6a2470289f
6575 stage: build
You can’t perform that action at this time.
0 commit comments