My .gitlab-ci.yml
specifies three stages. First stage builds a docker image and saves it an as artifact to image/img
.
Other stages reuse the image in order to not build it again.
Here’s the file:
image: docker:latest
services:
- docker:dind
variables:
DOCKER_DRIVER: overlay
GIT_SUBMODULE_STRATEGY: recursive
PIP_CACHE_DIR: "$CI_PROJECT_DIR/pip-cache"
cache:
paths:
- "/var/cache/apt/archives/"
- "$CI_PROJECT_DIR/builds"
- "$CI_PROJECT_DIR/pip-cache"
key: "$CI_PROJECT_ID"
stages:
- docker_build
- test
- docker_push
docker_build:
before_script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- docker info
- apk update
- apk upgrade
- apk add curl python python-dev py-pip build-base
- curl -L https://github.com/docker/compose/releases/download/1.8.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
- chmod +x /usr/local/bin/docker-compose
- pip install docker-compose
- docker-compose version
script:
- export TAG=$CI_COMMIT_REF_NAME
- docker-compose build
- mkdir image
- docker save registry.gitlab.com/wroomonline/$CI_PROJECT_NAME:$CI_COMMIT_REF_NAME > image/img.tar
artifacts:
paths:
- image
expire_in: 1 hour
stage: docker_build
allow_failure: false
unit_test:
before_script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- docker info
- apk update
- apk upgrade
- apk add curl python python-dev py-pip build-base
- curl -L https://github.com/docker/compose/releases/download/1.8.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
- chmod +x /usr/local/bin/docker-compose
- pip install docker-compose
- docker-compose version
script:
- export TAG=$CI_COMMIT_REF_NAME
- export FLASK_CONFIGURATION=testing
- docker load -i image/img.tar
- docker-compose run api pytest tests
stage: test
allow_failure: false
docker_push:
before_script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- docker info
- apk update
- apk upgrade
- apk add curl python python-dev py-pip build-base
- curl -L https://github.com/docker/compose/releases/download/1.8.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
- chmod +x /usr/local/bin/docker-compose
- pip install docker-compose
- docker-compose version
script:
- export TAG=$CI_COMMIT_REF_NAME
- docker load -i image/img.tar
- docker-compose push
stage: docker_push
allow_failure: false
only:
refs:
- master
- dev
Everything was working fine, but now all my pipelines, even old ones are failing.
Stages 2 and 3 can’t find the artifact file.
Screenshots:
https://screenshots.firefox.com/yJQISidRpObUrkaE/gitlab.com
https://screenshots.firefox.com/0j1wrv4JdtHKYE0h/gitlab.com
The first stage states that it built and uploaded the artifact successfully:
https://screenshots.firefox.com/sbvT2CDOkxJTNCk3/gitlab.com
I also get the “download artifact” button, but it leads to a 404 page:
https://screenshots.firefox.com/u2OMmsnXFa6XvXXJ/gitlab.com
Please help! My work is still because of this.