From e35ac2dcaaaee1a4483805496ed1e17972c2e353 Mon Sep 17 00:00:00 2001 From: Paolo Brasolin <paolo.brasolin@eurac.edu> Date: Sat, 26 Feb 2022 14:43:16 +0100 Subject: [PATCH] ci: #fe build and deploy to itch --- .gitlab-ci.yml | 39 +++++++++++++++- backend/kustomize/kustomization.yaml | 8 ++++ .../overlays/staging/deployment.yaml | 14 ++++++ .../kustomize/overlays/staging/ingress.yaml | 23 ++++++++++ .../overlays/staging/kustomization.yaml | 45 +++++++++++++++++++ 5 files changed, 128 insertions(+), 1 deletion(-) create mode 100644 backend/kustomize/kustomization.yaml create mode 100644 backend/kustomize/overlays/staging/deployment.yaml create mode 100644 backend/kustomize/overlays/staging/ingress.yaml create mode 100644 backend/kustomize/overlays/staging/kustomization.yaml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 161c3ea..b68c903 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -27,7 +27,7 @@ stages: only: - main -be-deploy-job: +.be-deploy-job: variables: KUBECTL_VERSION: v1.8.10 IMAGE_NAME: $CI_REGISTRY_IMAGE/backend @@ -82,3 +82,40 @@ be-deploy-job: - cd frontend - npm install - echo Success! + +fe-deploy-job: + variables: + GLIBC_URL: https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.34-r0/glibc-2.34-r0.apk + BUTLER_URL: https://broth.itch.ovh/butler/linux-amd64/LATEST/archive/default + # NOTE: this key is a throwaway, we'll store one in secrets + BUTLER_API_KEY: 0UsKHAvtO2aXBJMPeR6bZHxSv9BRQ0zIvFPdFdRW + image: node:16-alpine + stage: deploy + cache: + - key: + files: + - frontend/package-lock.json + paths: + - frontend/node_modules + before_script: + - "#=[ install tools ]=====================" + # NOTE: Alpine Linux stuff if linked with muslc. Butler is linked with glibc, and this causes an error -- see https://stackoverflow.com/a/66974607/6438061 for details. We need to install a compatibility layer: https://github.com/sgerrand/alpine-pkg-glibc#installing + - "#-[ install glibc ]---------------------" + - wget -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub + - wget -O glibc.apk $GLIBC_URL + - apk add glibc.apk + - rm glibc.apk + - "#-[ install unzip ]---------------------" + - apk add --no-cache unzip + - "#-[ install butler ]--------------------" + - wget -O butler.zip $BUTLER_URL + - unzip butler.zip *.so -d /usr/local/lib + - unzip butler.zip butler -d /usr/local/bin + - chmod +x /usr/local/bin/butler + - rm butler.zip + - butler -V + script: + - cd frontend + - npm install + - npm run build + - butler push dist paolobrasolin/oetzi:html5 \ No newline at end of file diff --git a/backend/kustomize/kustomization.yaml b/backend/kustomize/kustomization.yaml new file mode 100644 index 0000000..d9e5412 --- /dev/null +++ b/backend/kustomize/kustomization.yaml @@ -0,0 +1,8 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: + - deployment.yaml + - service.yaml + - ingress.yaml diff --git a/backend/kustomize/overlays/staging/deployment.yaml b/backend/kustomize/overlays/staging/deployment.yaml new file mode 100644 index 0000000..98e2e6c --- /dev/null +++ b/backend/kustomize/overlays/staging/deployment.yaml @@ -0,0 +1,14 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: deployment +spec: + template: + spec: + containers: + - name: webserver + image: WEBSERVER + ports: + - name: http + containerPort: 80 diff --git a/backend/kustomize/overlays/staging/ingress.yaml b/backend/kustomize/overlays/staging/ingress.yaml new file mode 100644 index 0000000..fb9f3dc --- /dev/null +++ b/backend/kustomize/overlays/staging/ingress.yaml @@ -0,0 +1,23 @@ +--- +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: ingress + annotations: + ingress.kubernetes.io/configuration-snippet: | + rewrite ^(/PATH)$ $1/ permanent; + ingress.kubernetes.io/rewrite-target: / + kubernetes.io/tls-acme: "true" +spec: + rules: + - host: HOST + http: + paths: + - backend: + serviceName: service-http + servicePort: 80 + path: /PATH + tls: + - hosts: + - kommul-dev.eurac.edu + secretName: kommul-dev.eurac.edu-NAME-tls diff --git a/backend/kustomize/overlays/staging/kustomization.yaml b/backend/kustomize/overlays/staging/kustomization.yaml new file mode 100644 index 0000000..e6a6cb5 --- /dev/null +++ b/backend/kustomize/overlays/staging/kustomization.yaml @@ -0,0 +1,45 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +bases: + - ../../base + +patchesStrategicMerge: + - deployment.yaml + - ingress.yaml + +namePrefix: merlin-platform- +# nameSuffix: -v1 +commonLabels: + variant: staging + org: commul + app: merlin-webpage +commonAnnotations: + note: merlin-platform-note +namespace: kommul-dev + +images: + - name: WEBSERVER + newName: gitlab.inf.unibz.it:4567/commul/merlin-platform/www/master:445bc35dde4520cab61a36c793c7c5a626f43e62 + +patchesJSON6902: + - target: + group: extensions + version: v1beta1 + kind: Ingress + name: ingress + patch: |- + - op: replace + path: /metadata/annotations/ingress.kubernetes.io~1configuration-snippet + value: | + rewrite ^(/merlin)$ $1/ permanent; + - op: replace + path: /spec/rules/0/host + value: kommul-dev.eurac.edu + - op: replace + path: /spec/rules/0/http/paths/0/path + value: /merlin + - op: replace + path: /spec/tls/0/secretName + value: kommul-dev.eurac.edu-merlin-tls -- GitLab