Hi Everyone,
I have been trying many things that I am not sure what went wrong as I am not a Linux expert (as I have been a windows guy myself)
I have the .gitlab-ci.yml file based on the tutorial from here:
How To Set Up a Continuous Deployment Pipeline with GitLab CI/CD on Ubuntu 18.04 | DigitalOcean[
^]
and here is my version of the file:
variables:
TAG_LATEST: $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_NAME:latest
TAG_COMMIT: $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_NAME:$CI_COMMIT_SHORT_SHA
DOCKER_IMAGE: 'docker:18.09.8'
stages:
- build
- publish
- deploy
#publish job for dev build - webapi
publish_job_webapi_dev:
image: $DOCKER_IMAGE
stage: publish
services:
- docker:dind
script:
- docker build --build-arg BUILD_CONFIGURATION=DEBUG -t $TAG_COMMIT -t $TAG_LATEST -f ./{the project}/Dockerfile .
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- docker push $TAG_COMMIT
- docker push $TAG_LATEST
tags:
- webapi
- develop
only:
- develop
- test
#deploy job for dev build - webapi
deploy_job_webapi_dev:
image: alpine:latest
stage: deploy
script:
#deploy script
- chmod og= $ID_RSA
- apk update && apk add openssh-client
- ssh -i $ID_RSA -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY"
- ssh -i $ID_RSA -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "docker pull $TAG_COMMIT"
- ssh -i $ID_RSA -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "docker container rm -f laewebapi || true"
- ssh -i $ID_RSA -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "docker run -d -p 80:80 -p 443:443 --name laewebapi $TAG_COMMIT"
needs:
- publish_job_webapi_dev
tags:
- webapi
- develop
only:
- test
- develop
Everything is working fine, and now I want to use, instead of using
docker run
, I want to use
docker-compose instead
. However, I am not sure how to get the file to send over to the remote host so I can run the docker compose there.
here is the docker-compose.yml file content:
version: '3.4'
services:
aeswebapi:
image: {$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_NAME:$CI_COMMIT_SHORT_SHA} # the actual of the path to the docker image generated in the publish job
ports:
- 80
any help is greatly appreciated. Thanks in advance
What I have tried:
I have tried scp, but it also says that the file is not found, which when I used echo and the file is there downloaded from the artifact from the previous stage.