diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml new file mode 100644 index 0000000..0143fba --- /dev/null +++ b/.github/workflows/workflow.yml @@ -0,0 +1,22 @@ +name: Slovensko.Digital CI + +on: + push: + branches: '**' + +jobs: + gitlab-push: + if: ${{github.ref == 'refs/heads/master'}} + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - uses: dokku/github-action@master + with: + git_push_flags: '--force' + git_remote_url: ssh://git@${{secrets.GITLAB_DEPLOY_HOST}}/${{github.event.repository.name}}.git + ssh_private_key: ${{secrets.GITLAB_DEPLOY_KEY}} diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..ba40404 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,44 @@ +image: alpine:latest + +variables: + DOCKER_DRIVER: overlay2 + DOCKER_BUILDKIT: 0 + AUTO_DEVOPS_BUILD_CACHE: registry + AUTO_DEPLOY_IMAGE_VERSION: 'v2.47.0' + +stages: + - build + - deploy + +include: + - template: Jobs/Build.gitlab-ci.yml + +production: + extends: .auto-deploy + stage: deploy + script: + - auto-deploy check_kube_domain + - auto-deploy download_chart + - auto-deploy use_kube_context || true + - auto-deploy ensure_namespace + - auto-deploy create_secret + - auto-deploy deploy + - auto-deploy persist_environment_url + environment: + name: production + url: http://$CI_PROJECT_PATH_SLUG.$KUBE_INGRESS_BASE_DOMAIN + artifacts: + paths: [environment_url.txt] + when: always + allow_failure: false + rules: + - if: '($CI_KUBERNETES_ACTIVE == null || $CI_KUBERNETES_ACTIVE == "") && ($KUBECONFIG == null || $KUBECONFIG == "")' + when: never + - when: on_success + +# The latest build job generates a dotenv report artifact with a CI_APPLICATION_TAG +# that also includes the image digest. This configures Auto Deploy to receive +# this artifact and use the updated CI_APPLICATION_TAG for deployments. +.auto-deploy: + image: "registry.gitlab.com/gitlab-org/cluster-integration/auto-deploy-image:${AUTO_DEPLOY_IMAGE_VERSION}" + dependencies: [build] diff --git a/.gitlab/auto-deploy-values.yaml b/.gitlab/auto-deploy-values.yaml new file mode 100644 index 0000000..7bd651c --- /dev/null +++ b/.gitlab/auto-deploy-values.yaml @@ -0,0 +1,22 @@ +timeout: 120 +service: + externalPort: 5000 + internalPort: 80 +image: + secrets: + - name: skdigital-bonet-registry +livenessProbe: + path: "/test/ping" + initialDelaySeconds: 10 + timeoutSeconds: 10 + scheme: "HTTP" + probeType: "httpGet" + httpHeaders: [] +readinessProbe: + initialDelaySeconds: 15 + probeType: "exec" + command: + - "true" +resources: + requests: + memory: 64Mi diff --git a/10-php.conf b/10-php.conf new file mode 100644 index 0000000..4a44a4b --- /dev/null +++ b/10-php.conf @@ -0,0 +1,10 @@ +location ~ \.php$ { + fastcgi_split_path_info ^(.+\.php)(/.+)$; + fastcgi_pass php; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $request_filename; + fastcgi_read_timeout 600; + fastcgi_buffer_size 128k; + fastcgi_buffers 4 256k; + fastcgi_busy_buffers_size 256k; +} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..68531ec --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM webdevops/php-nginx:8.0-alpine + +ENV WEB_DOCUMENT_ROOT=/app/public +ENV PHP_DATE_TIMEZONE=Europe/Bratislava + +WORKDIR /app/ + +RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer + +COPY 10-php.conf /opt/docker/etc/nginx/vhost.common.d/10-php.conf +COPY application /app + +RUN composer install --no-dev --optimize-autoloader --no-interaction --no-progress --no-suggest --no-scripts + +EXPOSE 80/tcp + +CMD ["supervisord"]