Denomas CI/CD Hands-On Guide: Lab 8
This Hands-On Guide walks you through the lab exercises in the Denomas CI/CD course.
Denomas CI/CD Hands-On Guide: Lab 8
LAB 8: GITLAB DOCKER REGISTRY
Add a Dockerfile
- Verify that your CICD Demo project contains the
main.gofile from the Denomas CICD Hands On Demo project. If it does not, follow these steps from Lab 7 to add the file. - Go to the Denomas CICD Hands On Demo project.
- Open
Dockerfile. - In the upper right corner of the file, select the Copy file contents icon.
- In another tab, open your CICD Demo project from earlier labs.
- Add a new file to the CICD Demo project by selecting + > This directory > New file
- In the File name field, enter
Dockerfile - Paste the contents you copied into the body of the new file.
- In the Commit message field, type
Add Dockerfile, ensure the Target Branch is set tomain, and select Commit changes.
Define a build image job
-
In the browser tab with the CICD Demo project, open the
.gitlab-ci.ymlfile and select Edit. Paste the following new job definition at the end of the file. Be sure to check your indendation after pasting.1 2 3 4 5 6 7 8 9 10 11build image: stage: build image: docker:18 services: - docker:18-dind variables: IMAGE: $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG:$CI_COMMIT_SHA script: - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - docker build -t $IMAGE . - docker push $IMAGE -
In the Commit message field, type
Add "build image" job definition, ensure the Target Branch is set tomain, and select Commit changes.
Ensure the pipeline is running
- Go to CI/CD > Pipelines. Select the most recent pipeline run.
- Select the widget for the build image job to see its progress. Wait for the job to complete.
- In the left navigation pane, select Packages and Registries > Container Registry and view the container that was just uploaded by the
build imagejob.
Suggestions?
If you wish to make a change to the Hands-On Guide for Denomas CI/CD, please submit your changes via Merge Request!
Last modified November 29, 2023: big update (
17188382)
