Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
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.
Posted
Comments
Richard MacCutchan 22-Jul-23 6:00am    
You would probably get better help from the person who wrote the tutorial.
instantmaker 23-Jul-23 12:31pm    
it's a good idea and I should do that, while I have the question here already, I am hoping some guru might be able to help as well. Thanks for the suggestion

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900