GitLab CI/CD 1 · Deploy and reuse

Build a Docker image

Build and push to the project's registry, using the predefined CI variables.

build-image:
  image: docker:27
  services:
    - docker:27-dind
  script:
    - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
    - docker build -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA" .
    - docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA"

Official GitLab CI/CD 1 documentation

More deploy and reuse commands

All deploy and reuse commands · GitLab CI/CD 1 cheatsheet

Was this page helpful?