variables:
  REGISTRY: registry.sc07.dev
  IMAGE_NAME: sc07/canvas:edge

publish:
  stage: build
  tags:
    - red
  interruptible: true
  before_script:
    - echo $PAT | docker login $REGISTRY -u $GITLAB_USER_LOGIN --password-stdin
  script:
    - |
      docker build --tag $REGISTRY/$IMAGE_NAME \
      --build-arg SENTRY_URL=$SENTRY_URL \
      --build-arg SENTRY_ORG=$SENTRY_ORG \
      --build-arg CLIENT_SENTRY_PROJECT=$CLIENT_SENTRY_PROJECT \
      --build-arg CLIENT_SENTRY_DSN=$CLIENT_SENTRY_DSN \
      --build-arg SERVER_SENTRY_PROJECT=$SERVER_SENTRY_PROJECT \
      --build-arg SERVER_SENTRY_DSN=$SERVER_SENTRY_DSN \
      --build-arg SENTRY_AUTH_TOKEN=$SENTRY_AUTH_TOKEN .
    - docker push $REGISTRY/$IMAGE_NAME

deploy:
  stage: deploy
  tags:
    - red
  interruptible: true
  script:
    - cd $WORK_DIR
    - docker compose pull
    - docker compose up -d
