งานการปรับใช้ Gitlab ล้มเหลวด้วยข้อความ : ล้มเหลวเนื่องจากสร้างทรัพยากรที่จำเป็นไม่สำเร็จ

stages:
  - compose
  - test
  - build
  - deploy-prod

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_DRIVER: overley2
  DOCKER_TLS_CERTDIR: "/certs"

composer:
  stage: compose
  image: vincentcau/laravel-docker:latest
  cache:
    key: ${CI_COMMIT_REF_SLUG}-composer
    paths:
      - vendor/
  script:
    - composer install --prefer-dist --no-ansi --no-interaction --no-progress --no-scripts
    - cp .env.example .env
    - php artisan key:generate
  artifacts:
    expire_in: 1 month
    paths:
      - vendor/
      - .env

testing:
  stage: test
  services:
    - mysql:5.7
  image: vincentcau/laravel-docker:latest
  script:
    - ./vendor/phpunit/phpunit/phpunit --no-coverage

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

deploy-prod:
  stage: deploy-prod
  image: alpine:latest
  tags:
    - prod
  environment:
    name: prod
    url: http://18.234.221.39:9000
  script:
    - cat $ID_RSA
    - chmod 400 $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 testcicd || true"
    - ssh -i $ID_RSA -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "docker run -d -p 9000:80 --name testcicd $TAG_COMMIT"
  rules:
    - if: '$CI_COMMIT_REF_NAME == "main"'
      when: manual