Skip to content
Snippets Groups Projects
.gitlab-ci.yml 3.29 KiB
Newer Older
include:
  - template: Auto-DevOps.gitlab-ci.yml

variables:
Dominik Hebeler's avatar
Dominik Hebeler committed
  POSTGRES_ENABLED: "false"
  CODE_QUALITY_DISABLED: "true"
  CONTAINER_SCANNING_DISABLED: "true"
  DAST_DISABLED: "true"
  DEPENDENCY_SCANNING_DISABLED: "true"
  LICENSE_MANAGEMENT_DISABLED: "true"
  PERFORMANCE_DISABLED: "true"
  SAST_DISABLED: "true"
  TEST_DISABLED: "true"
Dominik Hebeler's avatar
Dominik Hebeler committed
build:
  stage: build
  image: "registry.gitlab.com/gitlab-org/cluster-integration/auto-build-image/master:stable"
  variables:
    DOCKER_TLS_CERTDIR: ""
  services:
    - docker:stable-dind
  script:
    - |
      if [[ -z "$CI_COMMIT_TAG" ]]; then
        export CI_APPLICATION_REPOSITORY=${CI_APPLICATION_REPOSITORY:-$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG}
        export CI_APPLICATION_TAG=${CI_APPLICATION_TAG:-$CI_COMMIT_SHA}
      else
        export CI_APPLICATION_REPOSITORY=${CI_APPLICATION_REPOSITORY:-$CI_REGISTRY_IMAGE}
        export CI_APPLICATION_TAG=${CI_APPLICATION_TAG:-$CI_COMMIT_TAG}
      fi
    - |
      if ! docker info &>/dev/null; then
        if [ -z "$DOCKER_HOST" ] && [ "$KUBERNETES_PORT" ]; then
          export DOCKER_HOST='tcp://localhost:2375'
        fi
      fi

      if [[ -n "$CI_REGISTRY" && -n "$CI_REGISTRY_USER" ]]; then
        echo "Logging to GitLab Container Registry with CI credentials..."
        docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
      fi

      if [[ -f Dockerfile ]]; then
        echo "Building Dockerfile-based application..."
      else
        echo "Building Heroku-based application using gliderlabs/herokuish docker image..."
        cp /build/Dockerfile Dockerfile
      fi
    # Build the dependencies
Dominik Hebeler's avatar
Dominik Hebeler committed
    - docker run --dns=1.1.1.1 --rm -v "$PWD":/usr/src/app -w /usr/src/app node:10 bash -c "npm install prod --verbose && npm run prod"
Dominik Hebeler's avatar
Dominik Hebeler committed
    - docker run --dns=1.1.1.1 --rm -v $(pwd):/app composer/composer:latest install
    - docker pull $CI_APPLICATION_REPOSITORY:latest || true
Dominik Hebeler's avatar
Dominik Hebeler committed
    - |
      docker build \
        --cache-from $CI_APPLICATION_REPOSITORY:latest \
Dominik Hebeler's avatar
Dominik Hebeler committed
        --build-arg BUILDPACK_URL="$BUILDPACK_URL" \
        --build-arg HTTP_PROXY="$HTTP_PROXY" \
        --build-arg http_proxy="$http_proxy" \
        --build-arg HTTPS_PROXY="$HTTPS_PROXY" \
        --build-arg https_proxy="$https_proxy" \
        --build-arg FTP_PROXY="$FTP_PROXY" \
        --build-arg ftp_proxy="$ftp_proxy" \
        --build-arg NO_PROXY="$NO_PROXY" \
        --build-arg no_proxy="$no_proxy" \
        $AUTO_DEVOPS_BUILD_IMAGE_EXTRA_ARGS \
        --tag "$CI_APPLICATION_REPOSITORY:$CI_APPLICATION_TAG" \
        --tag "$CI_APPLICATION_REPOSITORY:latest" .
    - docker push "$CI_APPLICATION_REPOSITORY:latest"
Dominik Hebeler's avatar
Dominik Hebeler committed
    - docker push "$CI_APPLICATION_REPOSITORY:$CI_APPLICATION_TAG"
  only:
    - branches
    - tags


Dominik Hebeler's avatar
Dominik Hebeler committed
    AUTO_DEVOPS_BUILD_IMAGE_EXTRA_ARGS: --cache-from $CI_APPLICATION_REPOSITORY:$CI_APPLICATION_TAG
    HELM_UPGRADE_EXTRA_ARGS: --set service.internalPort=80 --set service.commonName= --set ingress.tls.enabled=false --set ingress.annotations.kubernetes\.io/tls-acme="false" --set ingress.annotations.nginx\.ingress\.kubernetes\.io/ssl-redirect="false"

production:
  variables:
    HELM_UPGRADE_EXTRA_ARGS: --set service.internalPort=80 --set service.commonName= --set ingress.annotations.certmanager\.k8s\.io/cluster-issuer=letsencrypt-prod
  environment:
    url: https://proxy.metager.de