File tree Expand file tree Collapse file tree 4 files changed +34
-14
lines changed
[% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab[% endif %]/workflows Expand file tree Collapse file tree 4 files changed +34
-14
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ ARG PYTHON_VERSION=3.12
6
6
# Dev image is used for development and cicd.
7
7
# #######################################################################################
8
8
9
- FROM python:${PYTHON_VERSION} as dev
9
+ FROM python:${PYTHON_VERSION} AS dev
10
10
11
11
# NOTE: python docker image has env `PYTHON_VERSION` but with patch version.
12
12
# ARG is used here for temporary override without changing the original env.
@@ -67,7 +67,7 @@ WORKDIR /workspace
67
67
# Build image is an intermediate image used for building the project.
68
68
# #######################################################################################
69
69
70
- FROM dev as build
70
+ FROM dev AS build
71
71
72
72
# Install dependencies and project into the local packages directory.
73
73
ARG SCM_VERSION
@@ -81,7 +81,7 @@ RUN --mount=source=README.md,target=README.md \
81
81
# Prod image is used for deployment and distribution.
82
82
# #######################################################################################
83
83
84
- FROM python:${PYTHON_VERSION}-slim as prod
84
+ FROM python:${PYTHON_VERSION}-slim AS prod
85
85
86
86
# NOTE: python docker image has env `PYTHON_VERSION` but with patch version.
87
87
# 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:
44
44
- |
45
45
docker buildx build . \
46
46
--build-arg PYTHON_VERSION=${PYTHON_VERSION} \
47
- --cache-to type=registry,ref=${CI_REGISTRY_IMAGE}/dev-cache:py${PYTHON_VERSION},mode=max \
48
47
--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
52
62
services :
53
63
- docker:27.3.1@sha256:bec82cb05983f12a14d8f169b00748f4ded8573f4da5f1d15d375b6a2470289f
54
64
stage : build
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ ARG PYTHON_VERSION={{ default_py }}
6
6
# Dev image is used for development and cicd.
7
7
########################################################################################
8
8
9
- FROM python:${PYTHON_VERSION} as dev
9
+ FROM python:${PYTHON_VERSION} AS dev
10
10
11
11
# NOTE: python docker image has env `PYTHON_VERSION` but with patch version.
12
12
# ARG is used here for temporary override without changing the original env.
@@ -67,7 +67,7 @@ WORKDIR /workspace
67
67
# Build image is an intermediate image used for building the project.
68
68
########################################################################################
69
69
70
- FROM dev as build
70
+ FROM dev AS build
71
71
72
72
# Install dependencies and project into the local packages directory.
73
73
ARG SCM_VERSION
@@ -81,7 +81,7 @@ RUN --mount=source=README.md,target=README.md \
81
81
# Prod image is used for deployment and distribution.
82
82
########################################################################################
83
83
84
- FROM python:${PYTHON_VERSION}-slim as prod
84
+ FROM python:${PYTHON_VERSION}-slim AS prod
85
85
86
86
# NOTE: python docker image has env `PYTHON_VERSION` but with patch version.
87
87
# 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:
55
55
- |
56
56
docker buildx build . \
57
57
--build-arg PYTHON_VERSION=${PYTHON_VERSION} \
58
- --cache-to type=registry,ref=${CI_REGISTRY_IMAGE}/dev-cache:py${PYTHON_VERSION},mode=max \
59
58
--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
63
73
services:
64
74
- docker:27.3.1@sha256:bec82cb05983f12a14d8f169b00748f4ded8573f4da5f1d15d375b6a2470289f
65
75
stage: build
You can’t perform that action at this time.
0 commit comments