I am using GitLab CI/CD with Docker to create Docker images, in this case to create a image of my application and publish it to a container registry.
The problem: Gitlab ci tells me the job succeeded but only 1 command was executed “docker build …” and the command “docker push …” was not executed.
build:
variables:
<<: *app-variables
stage: build and push image
before_script:
- docker login $DOCKER_REGISTRY -u $DOCKER_AUTH_USER -p $DOCKER_AUTH_PASSW
- cd $CI_PROJECT_DIR/apps/$DOCKER_APP_FOLDER
script:
- |
docker build --target=buildimage -t $DOCKER_REGISTRY/$DOCKER_REPO/$DOCKER_APP_FOLDER/build:$CI_COMMIT_BRANCH .
docker push $DOCKER_REGISTRY/$DOCKER_REPO/$DOCKER_APP_FOLDER/build:$CI_COMMIT_BRANCH
I already tried to change script command to the bellow code but has the same behaviour.
script:
- docker build --target=buildimage -t $DOCKER_REGISTRY/$DOCKER_REPO/$DOCKER_APP_FOLDER/build:$CI_COMMIT_BRANCH .
- docker push $DOCKER_REGISTRY/$DOCKER_REPO/$DOCKER_APP_FOLDER/build:$CI_COMMIT_BRANCH
I don’t know if it is related but the build of the image can take some time ~30min.
I tried with simpler Dockerfile and the command docker push worked.
I think the problem is related with my Dockerfile somehow.
The result of job:
Any suggestions how to solve?