GitLab CI deployment stage not resolving

My CI used to run right through to completion a couple of a month or so ago & now when I attempt to re-run my deployment stage, the stage never resolves/rejects & is stuck in a loop until I cancel it.

CI steps:

  • Build; install dependencies (PASSING)
  • Release; build docker image & push to repo (PASSING)
  • Deploy; SSH into DO droplet, pull down docker image & run (FAILING - not completing)

gitlab-ci.yml

cache:
  key: "${CI_BUILD_REF_NAME} node:latest"
  paths:
    - node_modules/

stages:
  - build
  - release
  - deploy

build:
  stage: build
  image: node:latest
  script:
    - npm install
  artifacts:
    paths:
      - node_modules/

release:
  stage: release
  image: docker:latest
  only:
    - master
  services:
    - docker:dind
  variables:
    DOCKER_TLS_CERTDIR: ""
    DOCKER_DRIVER: overlay
  before_script:
    - apk update && apk add bash
    - docker version
    - docker info
    - docker login -u ${CI_REGISTRY_USER} -p ${CI_BUILD_TOKEN} ${CI_REGISTRY}
  script:
    - dckstart=$(cat dockerfile-start)
    - export > custom_vars
    - chmod +x scripts/format-variables.sh
    - bash scripts/format-variables.sh
    - dckenv=$(cat custom_vars)
    - dckfin=$(cat dockerfile-finish)
    - echo -e "$dckstart\n$dckenv\n$dckfin" >> Dockerfile
    - rm dockerfile-start dockerfile-finish custom_vars
    - docker build -t ${CI_REGISTRY}/${CI_PROJECT_PATH}:latest --pull .
    - docker push ${CI_REGISTRY}/${CI_PROJECT_PATH}:latest
  after_script:
    - docker logout ${CI_REGISTRY}

deploy:
  stage: deploy
  image: gitlab/dind:latest
  only:
    - master
  variables:
    DOCKER_TLS_CERTDIR: ""
  environment:
    name: production
  when: manual
  before_script:
    - mkdir -p ~/.ssh
    - echo "${DEPLOY_SERVER_PRIVATE_KEY}" | tr -d '\r' > ~/.ssh/id_rsa
    - chmod 600 ~/.ssh/id_rsa
    - eval "$(ssh-agent -s)"
    - ssh-add ~/.ssh/id_rsa
    - ssh-keyscan -H ${DEPLOYMENT_SERVER_IP} >> ~/.ssh/known_hosts
  script:
    - ssh gitlab@${DEPLOYMENT_SERVER_IP}
      "docker ps -aq --filter='name=${CI_PROJECT_NAME}';
      docker container prune -f;
      docker rmi $(docker images | grep '${CI_REGISTRY}/${CI_PROJECT_PATH}');
      docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY};
      docker pull ${CI_REGISTRY}/${CI_PROJECT_PATH}:latest;
      docker run -d -p ${PORT}:${PORT} --restart=always -m 800m --init --name ${CI_PROJECT_NAME} ${CI_REGISTRY}/${CI_PROJECT_PATH}:latest;"

The output in the console for the deploy step is:

The is no output regarding the script or even the before_script so is it failing in the docker-in-docker image?

The variables I have set in that stage where a workaround I found in this answer but to no avail.

Can someone please shed some light onto why the deployment stage is not working :slight_smile: