I'm new to Gitlab and also CI/CD. I have some runtime issue with my CI Pipeline which took approximately 20 minutes to finish the build process. After searching:
https://blog.sparksuite.com/7-ways-to-speed-up-gitlab-ci-cd-times-29f60aab69f9
https://docs.gitlab.com/ee/ci/caching/
I want to use the image at the registry container I pushed up as cache to reduce the build time. The code I wrote at my gitlab-ci.yml is:
build_dev:
stage: build
image: docker:git
services:
- docker:dind
script:
- docker login $CI_REGISTRY -u gitlab-ci-token -p $CI_JOB_TOKEN
# - docker build -f .$DOCKERFILE_PATH/Dockerfile -t $IMAGE_NAME:$CI_COMMIT_REF_SLUG .
- docker build --cache-from $CONTAINER_IMAGE:latest --tag $CONTAINER_IMAGE:$CI_COMMIT_SHA --tag $CONTAINER_IMAGE:latest .
- docker push $IMAGE_NAME:$CI_COMMIT_REF_SLUG
only:
- develop
Please tell me if:
I am approaching my issue in a right way?
Is the code I wrote to the gitlab-ci.yml correct?
After the Pipeline is finished, will a new image is created? If so, can I upload that new image to the registry for the following CI/CDs?