GitLab provides predefined variables for accessing the registry
Images must be named according to the project path, e.g. …
…for project bar
in group foo
: gitlab.seatN.inmylab.de/foo/bar:latest
CI jobs receive environment variables:
CI_REGISTRY
CI_REGISTRY_USER
CI_REGISTRY_PASSWORD
CI_REGISTRY_IMAGE
Upload the previously built container image
Add before_script
to login to registry using docker login
job_name:
before_script:
- docker login -u "${CI_REGISTRY_USER}" -p "${CI_REGISTRY_PASSWORD}" "${CI_REGISTRY}"
Update build command to assign a proper tag
job_name:
script:
- docker build --tag "${CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_NAME}" .
Add push command to upload container image
job_name:
script:
# ...
- docker push "${CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_NAME}"
(See new .gitlab-ci.yml
)