Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ARG PYTHON_VERSION=3.12
# Dev image is used for development and cicd.
########################################################################################

FROM python:${PYTHON_VERSION} as dev
FROM python:${PYTHON_VERSION} AS dev

# NOTE: python docker image has env `PYTHON_VERSION` but with patch version.
# ARG is used here for temporary override without changing the original env.
Expand Down Expand Up @@ -67,7 +67,7 @@ WORKDIR /workspace
# Build image is an intermediate image used for building the project.
########################################################################################

FROM dev as build
FROM dev AS build

# Install dependencies and project into the local packages directory.
ARG SCM_VERSION
Expand All @@ -81,7 +81,7 @@ RUN --mount=source=README.md,target=README.md \
# Prod image is used for deployment and distribution.
########################################################################################

FROM python:${PYTHON_VERSION}-slim as prod
FROM python:${PYTHON_VERSION}-slim AS prod

# NOTE: python docker image has env `PYTHON_VERSION` but with patch version.
# ARG is used here for temporary override without changing the original env.
Expand Down
18 changes: 14 additions & 4 deletions .gitlab/workflows/devcontainer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,21 @@ dev-container-publish:
- |
docker buildx build . \
--build-arg PYTHON_VERSION=${PYTHON_VERSION} \
--cache-to type=registry,ref=${CI_REGISTRY_IMAGE}/dev-cache:py${PYTHON_VERSION},mode=max \
--file .devcontainer/Dockerfile \
--push \
--tag ${CI_REGISTRY_IMAGE}/dev:py${PYTHON_VERSION} \
--target dev
--load \
--tag ${CI_REGISTRY_IMAGE}:py${PYTHON_VERSION} \
--target prod
- docker run --rm ${CI_REGISTRY_IMAGE}:py${PYTHON_VERSION}
- |
if [ "$CI_PIPELINE_SOURCE" != "merge_request_event" ]; then
docker buildx build . \
--build-arg PYTHON_VERSION=${PYTHON_VERSION} \
--cache-to type=registry,ref=${CI_REGISTRY_IMAGE}/dev-cache:py${PYTHON_VERSION},mode=max \
--file .devcontainer/Dockerfile \
--push \
--tag ${CI_REGISTRY_IMAGE}/dev:py${PYTHON_VERSION} \
--target dev
fi
services:
- docker:27.3.1@sha256:bec82cb05983f12a14d8f169b00748f4ded8573f4da5f1d15d375b6a2470289f
stage: build
Expand Down
6 changes: 3 additions & 3 deletions template/.devcontainer/Dockerfile.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ARG PYTHON_VERSION={{ default_py }}
# Dev image is used for development and cicd.
########################################################################################

FROM python:${PYTHON_VERSION} as dev
FROM python:${PYTHON_VERSION} AS dev

# NOTE: python docker image has env `PYTHON_VERSION` but with patch version.
# ARG is used here for temporary override without changing the original env.
Expand Down Expand Up @@ -67,7 +67,7 @@ WORKDIR /workspace
# Build image is an intermediate image used for building the project.
########################################################################################

FROM dev as build
FROM dev AS build

# Install dependencies and project into the local packages directory.
ARG SCM_VERSION
Expand All @@ -81,7 +81,7 @@ RUN --mount=source=README.md,target=README.md \
# Prod image is used for deployment and distribution.
########################################################################################

FROM python:${PYTHON_VERSION}-slim as prod
FROM python:${PYTHON_VERSION}-slim AS prod

# NOTE: python docker image has env `PYTHON_VERSION` but with patch version.
# ARG is used here for temporary override without changing the original env.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,21 @@ dev-container-publish:
- |
docker buildx build . \
--build-arg PYTHON_VERSION=${PYTHON_VERSION} \
--cache-to type=registry,ref=${CI_REGISTRY_IMAGE}/dev-cache:py${PYTHON_VERSION},mode=max \
--file .devcontainer/Dockerfile \
--push \
--tag ${CI_REGISTRY_IMAGE}/dev:py${PYTHON_VERSION} \
--target dev
--load \
--tag ${CI_REGISTRY_IMAGE}:py${PYTHON_VERSION} \
--target prod
- docker run --rm ${CI_REGISTRY_IMAGE}:py${PYTHON_VERSION}
- |
if [ "$CI_PIPELINE_SOURCE" != "merge_request_event" ]; then
docker buildx build . \
--build-arg PYTHON_VERSION=${PYTHON_VERSION} \
--cache-to type=registry,ref=${CI_REGISTRY_IMAGE}/dev-cache:py${PYTHON_VERSION},mode=max \
--file .devcontainer/Dockerfile \
--push \
--tag ${CI_REGISTRY_IMAGE}/dev:py${PYTHON_VERSION} \
--target dev
fi
services:
- docker:27.3.1@sha256:bec82cb05983f12a14d8f169b00748f4ded8573f4da5f1d15d375b6a2470289f
stage: build
Expand Down