Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gitlab CI/CD pipeline giving Dockerfile error

Good Evening, I am trying to deploy my nodeJS app to my Digital Ocean Server and its saying it cant find my Dockerfile. I did check and the Dockerfile does not have a .txt extension. Any guidance is appreciated. I have my variables set in my Gitlab project. The pipeline throws the below error: "$ chmod og= $ID_RSA chmod: unrecognized option: ---BEGIN BusyBox v1.31.1 () multi-call binary. Usage: chmod [-Rcvf] MODE[,MODE]... FILE... Each MODE is one or more of the letters ugoa, one of the symbols +-= and one or more of the letters rwxst -R Recurse -c List changed files -v List all files -f Hide errors"

stages:
  - build
  - publish
  - deploy

variables:
  TAG_LATEST: $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_NAME:latest
  TAG_COMMIT: $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_NAME:$CI_COMMIT_SHORT_SHA

build:
  image: node:latest
  stage: build
  script:
    - npm install
    - echo   "ACCOUNT_SID=$ACCOUNT_SID" >> .env
    - echo   "AUTH_TOKEN=$AUTH_TOKEN" >> .env
    - echo   "API_KEY=$API_KEY" >> .env
    - echo   "API_SECRET=$API_SECRET" >> .env
    - echo   "PHONE_NUMBER=$PHONE_NUMBER" >> .env
    - echo    "sengrid_api=$sengrid_api" >> .env

publish:
  image: docker:latest
  stage: publish
  services:
    - docker:dind
  script:
    - docker build . -t $TAG_COMMIT -t $TAG_LATEST 
    - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
    - docker push $TAG_COMMIT
    - docker push $TAG_LATEST

deploy:
  image: alpine:latest
  stage: deploy
  tags:
    - deployment
  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_BUILD_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 my-app || true"
    - ssh -i $ID_RSA -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "docker run -d -p 80:3000 --name my-app $TAG_COMMIT"
  environment:
    name: production
    url: http://167.172.225.124
  only:
    - master
like image 499
augdog97 Avatar asked Mar 24 '26 21:03

augdog97


1 Answers

If you have followed this tutorial as I do (which looks to be the case), It looks the tutorial assumes to run on the master branch, protected.

I was running on another branch not protected. So I had to unprotect all variables to work on unprotected branches. The job succeeds immediately.

like image 182
Romain TAILLANDIER Avatar answered Mar 27 '26 13:03

Romain TAILLANDIER



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!