I am currently attempting to build my go binary in one stage and then build a docker image with the binary and deploy it in another to docker hub.
I am attempting to use the built binary in my deploy stage using this.
artifacts: paths: - ./recs-api
However, when my Dockerfile is run and I try and build the image it can’t find the binary that was built in the build stage.
Here is my gitlab yml file:
image: golang:1.13 stages: - build - test - release - deploy build: stage: build script: # Compile and name the binary as `hello` - go build -o recs-api test: stage: test script: - make test release: stage: release only: refs: - tags script: - export GITHUB_TOKEN="$GITHUB_GORELEASER" - curl -sL https://git.io/goreleaser | bash tags: - docker deploy: image: docker:stable stage: deploy services: - docker:19.03.0-dind variables: DOCKER_DRIVER: overlay2 DOCKER_TLS_CERTDIR: "/certs" artifacts: paths: - ./recs-api script: - export VERSION=$(cat ./VERSION) - docker login -u $DOCKER_USER -p $DOCKER_PASS - docker build -t pococknick91/recs-api:$VERSION . - docker tag pococknick91/recs-api:$VERSION pococknick91/recs-api:latest - echo "=> Pushing pococknick91/recs-api:$VERSION to docker" - docker push pococknick91/recs-api tags: - docker
And here is my Dockerfile:
FROM vidsyhq/go-base:latest LABEL maintainer="TEST" ARG VERSION LABEL version=$VERSION ADD recs-api / ADD config /config ENTRYPOINT ["/recs-api"]
And the error is:
step 5/7 : ADD recs-api /
70 ADD failed: stat /var/lib/docker/tmp/docker-builder026699228/recs-api: no such file or directory
Can anyone see where I am going wrong?