Gitlab CI
How to use Nx Container Plugin in your Gitlab CI pipelines
To build your container images with Gitlab CI we provide a set of custom builder images to build your app:
- gperdomor/nx-docker with Node, Docker and Buildx preintalled. Required to use
docker
engine. - gperdomor/nx-podman with Node and Podman preintalled. Required to use
podman
engine.
Examples:
You may want your build result to be available in the Docker client through docker images
to be able to use it in another step of your workflow:
build-with-docker-engine:
image: gperdomor/nx-docker:24.0.0-alpine
services:
- docker:20.10.21-dind
variables:
# Docker config
DOCKER_BUILDKIT: 1
DOCKER_DRIVER: overlay2
# Nx Container
INPUT_PUSH: 'true' # To push your image to the registry
before_script:
- npm i
- NX_HEAD=$CI_COMMIT_SHA
- NX_BASE=${CI_MERGE_REQUEST_DIFF_BASE_SHA:-$CI_COMMIT_BEFORE_SHA}
# Login to registry
- echo "$CI_REGISTRY_PASSWORD" | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY
script:
- docker run --privileged --rm tonistiigi/binfmt --install all # required only for multi-platform build
- npx nx affected --base=$NX_BASE --head=$NX_HEAD --target=container --parallel=2
You may want your build result to be available in the Docker client through docker images
to be able to use it in another step of your workflow:
build-with-podman-engine:
image: gperdomor/nx-podman:24.0.0
variables:
# Nx Container
INPUT_PUSH: 'true' # To push your image to the registry
INPUT_ENGINE: 'podman' # Overriding engine of project.json files
before_script:
- npm i
- NX_HEAD=$CI_COMMIT_SHA
- NX_BASE=${CI_MERGE_REQUEST_DIFF_BASE_SHA:-$CI_COMMIT_BEFORE_SHA}
# Login to registry
- echo "$CI_REGISTRY_PASSWORD" | podman login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY
script:
- npx nx affected --base=$NX_BASE --head=$NX_HEAD --target=container --parallel=2
Last updated on