@catladder/cli 0.0.0-next-1cd29c1f → 0.0.0-next-f0ea63b5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/dist/bundles/catenv/index.js +4 -2
  2. package/dist/bundles/cli/index.js +4 -2
  3. package/dist/bundles/runner-images/agent-claude/Dockerfile +5 -0
  4. package/dist/bundles/runner-images/docker-build/Dockerfile +26 -0
  5. package/dist/bundles/runner-images/docker-build/scripts/ensureMeteorDockerfile +55 -0
  6. package/dist/bundles/runner-images/docker-build/scripts/ensureNginxDockerfile +85 -0
  7. package/dist/bundles/runner-images/docker-build/scripts/ensureNodeDockerfile +50 -0
  8. package/dist/bundles/runner-images/gcloud/Dockerfile +3 -0
  9. package/dist/bundles/runner-images/jobs-default/Dockerfile +22 -0
  10. package/dist/bundles/runner-images/jobs-meteor/Dockerfile +7 -0
  11. package/dist/bundles/runner-images/jobs-testing-chrome/Dockerfile +15 -0
  12. package/dist/bundles/runner-images/kubernetes/Dockerfile +26 -0
  13. package/dist/bundles/runner-images/kubernetes/helm-charts/the-panter-chart/Chart.lock +9 -0
  14. package/dist/bundles/runner-images/kubernetes/helm-charts/the-panter-chart/Chart.yaml +14 -0
  15. package/dist/bundles/runner-images/kubernetes/helm-charts/the-panter-chart/README.md +24 -0
  16. package/dist/bundles/runner-images/kubernetes/helm-charts/the-panter-chart/charts/mailhog-5.0.1.tgz +0 -0
  17. package/dist/bundles/runner-images/kubernetes/helm-charts/the-panter-chart/charts/mongodb-12.1.27.tgz +0 -0
  18. package/dist/bundles/runner-images/kubernetes/helm-charts/the-panter-chart/myvalues.yaml +15 -0
  19. package/dist/bundles/runner-images/kubernetes/helm-charts/the-panter-chart/templates/_helpers.tpl +202 -0
  20. package/dist/bundles/runner-images/kubernetes/helm-charts/the-panter-chart/templates/app.cloudsql-proxy-credentials.yml +10 -0
  21. package/dist/bundles/runner-images/kubernetes/helm-charts/the-panter-chart/templates/app.cronjobs.yml +69 -0
  22. package/dist/bundles/runner-images/kubernetes/helm-charts/the-panter-chart/templates/app.deployment.autoscaler.yml +19 -0
  23. package/dist/bundles/runner-images/kubernetes/helm-charts/the-panter-chart/templates/app.deployment.yml +103 -0
  24. package/dist/bundles/runner-images/kubernetes/helm-charts/the-panter-chart/templates/app.env.configmap.yml +27 -0
  25. package/dist/bundles/runner-images/kubernetes/helm-charts/the-panter-chart/templates/app.env.secrets.yml +10 -0
  26. package/dist/bundles/runner-images/kubernetes/helm-charts/the-panter-chart/templates/app.ingress.redirects.yaml +91 -0
  27. package/dist/bundles/runner-images/kubernetes/helm-charts/the-panter-chart/templates/app.ingress.yaml +48 -0
  28. package/dist/bundles/runner-images/kubernetes/helm-charts/the-panter-chart/templates/app.jobs.yml +70 -0
  29. package/dist/bundles/runner-images/kubernetes/helm-charts/the-panter-chart/templates/app.service.yaml +31 -0
  30. package/dist/bundles/runner-images/kubernetes/helm-charts/the-panter-chart/templates/app.volumes.yml +20 -0
  31. package/dist/bundles/runner-images/kubernetes/helm-charts/the-panter-chart/templates/app.worker.deployment.yml +104 -0
  32. package/dist/bundles/runner-images/kubernetes/helm-charts/the-panter-chart/templates/app.worker.service.yaml +34 -0
  33. package/dist/bundles/runner-images/kubernetes/helm-charts/the-panter-chart/templates/mailhog.ingress.yaml +35 -0
  34. package/dist/bundles/runner-images/kubernetes/helm-charts/the-panter-chart/templates/maintenance.deployment.yml +45 -0
  35. package/dist/bundles/runner-images/kubernetes/helm-charts/the-panter-chart/templates/maintenance.service.yml +24 -0
  36. package/dist/bundles/runner-images/kubernetes/helm-charts/the-panter-chart/templates/mongodb.backup.cronjob.yml +120 -0
  37. package/dist/bundles/runner-images/kubernetes/helm-charts/the-panter-chart/values.yaml +154 -0
  38. package/dist/bundles/runner-images/kubernetes/scripts/kubernetesCreateSecret +11 -0
  39. package/dist/bundles/runner-images/kubernetes/scripts/kubernetesDelete +5 -0
  40. package/dist/bundles/runner-images/kubernetes/scripts/kubernetesDeploy +57 -0
  41. package/dist/bundles/runner-images/kubernetes/scripts/kubernetesRollback +5 -0
  42. package/dist/bundles/runner-images/semantic-release/Dockerfile +24 -0
  43. package/dist/bundles/runner-images/semantic-release/scripts/semanticRelease +67 -0
  44. package/dist/pipeline/src/constants.js +1 -1
  45. package/dist/pipeline/src/customImages/shippedImages.js +3 -1
  46. package/dist/pipeline/src/customImages/shippedImages.js.map +1 -1
  47. package/dist/tsconfig.tsbuildinfo +1 -1
  48. package/package.json +3 -2
@@ -5136,7 +5136,7 @@ Object.defineProperty(exports, "__esModule", ({
5136
5136
  value: true
5137
5137
  }));
5138
5138
  exports.DOCKER_REGISTRY = exports.PIPELINE_IMAGE_TAG = void 0;
5139
- exports.PIPELINE_IMAGE_TAG = "next-1cd29c1f" || 0;
5139
+ exports.PIPELINE_IMAGE_TAG = "next-f0ea63b5" || 0;
5140
5140
  exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || 0;
5141
5141
 
5142
5142
  /***/ }),
@@ -6151,7 +6151,9 @@ exports.RUNNER_IMAGE_BUILD_CONTEXT = {
6151
6151
  */
6152
6152
  const getShippedImagesDir = () => {
6153
6153
  const candidates = [
6154
- // built package: dist/customImages -> dist/runner-images
6154
+ // built pipeline package: dist/customImages -> dist/runner-images
6155
+ // bundled cli package (what consumers install): the ncc bundles live
6156
+ // in dist/bundles/<name>, so both resolve to dist/bundles/runner-images
6155
6157
  (0, path_1.join)(__dirname, "..", "runner-images"),
6156
6158
  // repository: pipeline/src/customImages -> <root>/runner-images
6157
6159
  (0, path_1.join)(__dirname, "..", "..", "..", "runner-images")];
@@ -10309,7 +10309,7 @@ Object.defineProperty(exports, "__esModule", ({
10309
10309
  value: true
10310
10310
  }));
10311
10311
  exports.DOCKER_REGISTRY = exports.PIPELINE_IMAGE_TAG = void 0;
10312
- exports.PIPELINE_IMAGE_TAG = "next-1cd29c1f" || 0;
10312
+ exports.PIPELINE_IMAGE_TAG = "next-f0ea63b5" || 0;
10313
10313
  exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || 0;
10314
10314
 
10315
10315
  /***/ }),
@@ -11324,7 +11324,9 @@ exports.RUNNER_IMAGE_BUILD_CONTEXT = {
11324
11324
  */
11325
11325
  const getShippedImagesDir = () => {
11326
11326
  const candidates = [
11327
- // built package: dist/customImages -> dist/runner-images
11327
+ // built pipeline package: dist/customImages -> dist/runner-images
11328
+ // bundled cli package (what consumers install): the ncc bundles live
11329
+ // in dist/bundles/<name>, so both resolve to dist/bundles/runner-images
11328
11330
  (0, path_1.join)(__dirname, "..", "runner-images"),
11329
11331
  // repository: pipeline/src/customImages -> <root>/runner-images
11330
11332
  (0, path_1.join)(__dirname, "..", "..", "..", "runner-images")];
@@ -0,0 +1,5 @@
1
+ FROM node:24-alpine3.21
2
+
3
+ RUN apk update && apk add --no-cache git curl bash
4
+
5
+ RUN npm install -g @anthropic-ai/claude-code@2.1.139 @zereight/mcp-gitlab@2.1.10
@@ -0,0 +1,26 @@
1
+
2
+ FROM docker:29.5.1
3
+
4
+ # add bash
5
+ RUN apk add --no-cache bash
6
+
7
+ # for glcoud
8
+ ARG GCLOUD_SDK_VERSION=525.0.0
9
+
10
+ RUN apk --update add curl python3 py3-crcmod libc6-compat
11
+ RUN curl -O https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-${GCLOUD_SDK_VERSION}-linux-x86_64.tar.gz && \
12
+ tar zxvf google-cloud-sdk-${GCLOUD_SDK_VERSION}-linux-x86_64.tar.gz && \
13
+ rm google-cloud-sdk-${GCLOUD_SDK_VERSION}-linux-x86_64.tar.gz && \
14
+ ./google-cloud-sdk/install.sh
15
+ ENV PATH="/google-cloud-sdk/bin:${PATH}"
16
+
17
+ # end gcloud
18
+
19
+ # for scripts
20
+
21
+ RUN mkdir p /scripts
22
+ COPY ./scripts/* /scripts/
23
+ RUN chmod +x /scripts/*
24
+
25
+ ENV PATH="/scripts:${PATH}"
26
+
@@ -0,0 +1,55 @@
1
+ #!/bin/bash
2
+
3
+ if [ ! -f $APP_DIR/.dockerignore ]; then
4
+
5
+ cat >$APP_DIR/.dockerignore <<EOF
6
+ $APP_DIR/node_modules
7
+ **/__snapshots__/**
8
+ .git
9
+
10
+ EOF
11
+ fi
12
+
13
+ if [ ! -f $APP_DIR/Dockerfile ]; then
14
+ echo "Creating Dockerfile"
15
+ if [[ ! -z "$METEOR_OVERRIDE_NODE_VERSION" ]]; then
16
+ NODE_VERSION=$METEOR_OVERRIDE_NODE_VERSION
17
+ else
18
+ NODE_VERSION_FULL=$(cat $APP_DIR/dist/bundle/.node_version.txt)
19
+ NODE_VERSION=${NODE_VERSION_FULL/v/} # remove v
20
+ fi
21
+ if [ "$NODE_VERSION" = "14.21.4" ]; then
22
+ DOCKER_IMAGE="meteor/node:$NODE_VERSION" # meteor maintenance for because of fibers
23
+ else
24
+ DOCKER_IMAGE="node:$NODE_VERSION"
25
+ fi
26
+ cat >$APP_DIR/Dockerfile <<EOF
27
+ FROM $DOCKER_IMAGE
28
+
29
+ # install yarn. new meteor image has no yarn installed
30
+ # only install if it does not exist
31
+ RUN command -v yarn || npm install --global yarn
32
+
33
+
34
+ $DOCKERFILE_ADDITIONS
35
+
36
+ # we copy also source code and scripts for commands
37
+ # This is technically not required for meteor, but useful if we have additional scripts
38
+ WORKDIR /src
39
+ $METEOR_INSTALL_SCRIPTS
40
+
41
+
42
+ # copy the bundle
43
+ COPY $APP_DIR/dist /src/dist
44
+
45
+ # now install meteor deps
46
+ RUN cd /src/dist/bundle/programs/server && npm install
47
+
48
+ $DOCKERFILE_ADDITIONS_END
49
+
50
+ WORKDIR /src/dist/bundle
51
+
52
+ CMD ["node", "main.js"]
53
+ EOF
54
+
55
+ fi
@@ -0,0 +1,85 @@
1
+ #!/bin/bash
2
+
3
+ # ensure nginx config
4
+ echo "ensureNginxDockerfile in $APP_DIR"
5
+
6
+ if [ ! -f $APP_DIR/nginx.conf ]; then
7
+ echo "Creating nginx.conf"
8
+
9
+ cat >$APP_DIR/nginx.conf <<NGINX
10
+
11
+ server {
12
+ listen 8080;
13
+ server_name localhost;
14
+ error_page 404 =200 /index.html;
15
+
16
+ charset utf-8;
17
+
18
+ add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload";
19
+ add_header Referrer-Policy "strict-origin-when-cross-origin";
20
+ add_header X-Content-Type-Options "nosniff";
21
+ add_header X-Frame-Options "SAMEORIGIN";
22
+
23
+ location / {
24
+ root /usr/share/nginx/html;
25
+ index index.html index.htm;
26
+ }
27
+
28
+ location /__health {
29
+ access_log off;
30
+ types { } default_type "text/html; charset=utf-8";
31
+ return 200 "ok\n";
32
+ }
33
+
34
+ # https://trac.nginx.org/nginx/ticket/2216
35
+ include mime.types;
36
+ types
37
+ {
38
+ application/javascript mjs;
39
+ }
40
+ }
41
+
42
+ NGINX
43
+
44
+ fi
45
+ # ensure docker ignore
46
+ if [ ! -f $APP_DIR/.dockerignore ]; then
47
+
48
+ cat >.dockerignore <<EOF
49
+ **/node_modules
50
+ **/__snapshots__/**
51
+ .git
52
+
53
+ EOF
54
+
55
+ fi
56
+
57
+ if [ ! -f $APP_DIR/Dockerfile ]; then
58
+ echo "Creating Dockerfile"
59
+
60
+ cat >$APP_DIR/Dockerfile <<EOF
61
+
62
+ $DOCKERFILE_ADDITIONS
63
+
64
+ FROM nginx:stable
65
+ WORKDIR /app
66
+
67
+ RUN sed --in-place "s/^\s*user .*//" /etc/nginx/nginx.conf && \
68
+ chown -R nginx:nginx /app && \
69
+ chmod -R 755 /app && \
70
+ chown -R nginx:nginx /var/cache/nginx && \
71
+ chown -R nginx:nginx /var/log/nginx && \
72
+ chown -R nginx:nginx /etc/nginx/conf.d && \
73
+ touch /var/run/nginx.pid && \
74
+ chown -R nginx:nginx /var/run/nginx.pid
75
+
76
+ COPY $APP_DIR/nginx.conf /etc/nginx/conf.d/default.conf
77
+ COPY $APP_DIR/dist/ /usr/share/nginx/html/
78
+
79
+ $DOCKERFILE_ADDITIONS_END
80
+
81
+ USER nginx
82
+ EXPOSE 8080
83
+
84
+ EOF
85
+ fi
@@ -0,0 +1,50 @@
1
+ #!/bin/bash
2
+
3
+ # the default dockerfile includes node alpine
4
+
5
+ # the dockerignore ignores node_modules as these have to be rebuilt anyway
6
+ # as well as __snapshots__ are used for unitests (if any)
7
+
8
+ if [ ! -f $APP_DIR/.dockerignore ]; then
9
+
10
+ cat >$APP_DIR/.dockerignore <<EOF
11
+ **/node_modules
12
+ **/__snapshots__/**
13
+ .git
14
+
15
+ EOF
16
+
17
+ fi
18
+
19
+ if [ -f $APP_DIR/.nvmrc ]; then
20
+ NODE_VERSION="$(cat $APP_DIR/.nvmrc | sed '/^$/d' | sed 's/[a-z-]//g')"
21
+ elif [ -f .nvmrc ]; then
22
+ NODE_VERSION="$(cat .nvmrc | sed '/^$/d' | sed 's/[a-z-]//g')"
23
+ else
24
+ NODE_VERSION=14
25
+ fi
26
+
27
+ if [ ! -f $APP_DIR/Dockerfile ]; then
28
+ echo "Creating Dockerfile"
29
+
30
+ cat >$APP_DIR/Dockerfile <<EOF
31
+ FROM node:$NODE_VERSION-alpine
32
+
33
+
34
+
35
+ $DOCKERFILE_ADDITIONS
36
+
37
+ RUN apk add --no-cache git curl
38
+ USER node
39
+
40
+ $DOCKER_COPY_WORKSPACE_FILES
41
+
42
+ WORKDIR /app/$APP_DIR
43
+
44
+ $DOCKER_COPY_AND_INSTALL_APP
45
+
46
+
47
+ $DOCKERFILE_ADDITIONS_END
48
+
49
+ EOF
50
+ fi
@@ -0,0 +1,3 @@
1
+
2
+ FROM google/cloud-sdk:latest
3
+
@@ -0,0 +1,22 @@
1
+
2
+
3
+ FROM node:18
4
+
5
+ RUN rm /bin/sh && \
6
+ ln -s /bin/bash /bin/sh && \
7
+ mkdir -p /root/.nvm
8
+
9
+ # set high timeout for yarn, see https://github.com/dhis2/notes/issues/29
10
+ RUN yarn config set network-timeout 600000 -g
11
+
12
+ # install nvm && some common node versions
13
+ RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash && \
14
+ source /root/.nvm/nvm.sh && \
15
+ chmod +x /root/.nvm/nvm.sh && \
16
+ /root/.nvm/nvm.sh install 12 && \
17
+ /root/.nvm/nvm.sh install 14 && \
18
+ /root/.nvm/nvm.sh install 16 && \
19
+ /root/.nvm/nvm.sh install 18 && \
20
+ /root/.nvm/nvm.sh install 20 && \
21
+ /root/.nvm/nvm.sh install 22 && \
22
+ /root/.nvm/nvm.sh install 24
@@ -0,0 +1,7 @@
1
+ # syntax = docker.io/devthefuture/dockerfile-x
2
+
3
+
4
+ INCLUDE ./jobs-default/Dockerfile
5
+
6
+ # add meteor (used by some apps)
7
+ RUN curl https://install.meteor.com/?release=2.13.3 | sh
@@ -0,0 +1,15 @@
1
+ # syntax = docker.io/devthefuture/dockerfile-x
2
+
3
+ INCLUDE ./jobs-default/Dockerfile
4
+
5
+ # add sources
6
+ # Google Chrome (for testing purposes)
7
+ RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \
8
+ sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
9
+
10
+ # install some sources
11
+ # not sure if libxss1 is required
12
+ RUN apt-get update && apt-get install -y \
13
+ libxss1 \
14
+ google-chrome-stable
15
+
@@ -0,0 +1,26 @@
1
+
2
+ FROM alpine:3.15
3
+
4
+ # add bash curl and git
5
+ RUN apk add --no-cache bash curl git
6
+
7
+
8
+ # kubernetes & helm
9
+ ENV KUBERNETES_VERSION 1.19.14
10
+ RUN curl -L -o /usr/bin/kubectl "https://storage.googleapis.com/kubernetes-release/release/v${KUBERNETES_VERSION}/bin/linux/amd64/kubectl" ;\
11
+ chmod +x /usr/bin/kubectl ;\
12
+ kubectl version --client
13
+
14
+ # helm 3
15
+ ENV HELM_VERSION 3.10.0
16
+ RUN curl "https://get.helm.sh/helm-v${HELM_VERSION}-linux-amd64.tar.gz" | tar zx ;\
17
+ mv linux-amd64/helm /usr/bin/helm ;\
18
+ helm version --client
19
+
20
+
21
+ COPY ./scripts/* /scripts/
22
+ RUN chmod +x /scripts/*
23
+
24
+ ENV PATH="/scripts:${PATH}"
25
+
26
+ COPY ./helm-charts /helm-charts
@@ -0,0 +1,9 @@
1
+ dependencies:
2
+ - name: mongodb
3
+ repository: https://charts.bitnami.com/bitnami
4
+ version: 12.1.27
5
+ - name: mailhog
6
+ repository: https://codecentric.github.io/helm-charts
7
+ version: 5.0.1
8
+ digest: sha256:8963e4182d88c519cf73b6c1e18f9993827b7bf7b54432f56b7b8c5d758bcf8e
9
+ generated: "2022-07-25T19:15:40.334548+02:00"
@@ -0,0 +1,14 @@
1
+ apiVersion: v2
2
+ description: a chart to rule them all
3
+ name: the-panter-chart
4
+ version: 1.0.0 # should not matter
5
+
6
+ dependencies:
7
+ - name: mongodb
8
+ version: 12.1.27
9
+ condition: mongodb.enabled
10
+ repository: https://charts.bitnami.com/bitnami
11
+ - name: mailhog
12
+ version: 5.0.1
13
+ condition: mailhog.enabled
14
+ repository: https://codecentric.github.io/helm-charts
@@ -0,0 +1,24 @@
1
+ # The panter chart
2
+
3
+ **Main chart used in https://git.panter.ch/catladder/gitlab-ci/ **
4
+
5
+ Developing helm charts can be complex and they tend to be very verbose.
6
+ Our goal is therefore to provide a common chart that provides all functionalities that you might need
7
+ and make it configurable by values.yml files in your project.
8
+
9
+ This way we avoid having complexity in the projects and make it easier to share innovations and improvements.
10
+
11
+ ## Features
12
+
13
+ - scalable stateless webapplications, supports any technology
14
+ - ready-to-use but configurable ingress with optional redirects
15
+ - 1 optional worker pod (uses same image as webapp) for continuous background jobs
16
+ - configurable cronjobs
17
+ - configurable helm-hooks (post-install, post-uninstall, etc.)
18
+ - optional in-namespace mongodb. _kindof deprecated, We recommend to use google cloud dbs if possible._
19
+ - optional cloud-sql proxy that is available in webapp, worker, cronjobs and helm-hooks
20
+ - a lot of useful predefined env-vars in all pods.
21
+ - support for namespace secrets and custom env-vars (using catladder-shell and gitlab-ci)
22
+ - optional prisam1 (_deprecated, prisma2 does not need a separate instance anymore_)
23
+
24
+ See https://git.panter.ch/catladder/catladder/ for usage information
@@ -0,0 +1,15 @@
1
+ application:
2
+ command: main foo.js
3
+
4
+ env:
5
+ public:
6
+ FOO: bar
7
+ fromComponents:
8
+ api:
9
+ API_URL: ROOT_URL
10
+
11
+ cloudsql:
12
+ enabled: true
13
+
14
+ mailhog:
15
+ enabled: true
@@ -0,0 +1,202 @@
1
+ {{/* vim: set filetype=mustache: */}}
2
+ {{/*
3
+ Expand the name of the chart.
4
+ */}}
5
+ {{- define "name" -}}
6
+ {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
7
+ {{- end -}}
8
+
9
+
10
+ {{- define "appImage" -}}
11
+ {{ .Values.image.repository }}/{{ .Values.image.name }}:{{ .Values.image.tag }}
12
+ {{- end -}}
13
+
14
+
15
+ {{/*
16
+ Create a default fully qualified app name.
17
+ We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
18
+ */}}
19
+ {{- define "fullname" -}}
20
+ {{- default .Release.Name .Values.global.appName | trunc 63 | trimSuffix "-" -}}
21
+ {{- end -}}
22
+
23
+
24
+
25
+ {{/*
26
+ create a prefix for variable names, this is useful in service discovery in review apps
27
+ */}}
28
+ {{- define "serviceVarPrefix" -}}
29
+ {{ include "fullname" . | snakecase | upper }}
30
+ {{- end -}}
31
+
32
+
33
+ {{/*
34
+ Create chart name and version as used by the chart label.
35
+ */}}
36
+ {{- define "chart" -}}
37
+ {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
38
+ {{- end -}}
39
+
40
+
41
+ {{/*
42
+ get the right host
43
+ */}}
44
+ {{- define "host" -}}
45
+ {{- default .Values.application.hostCanonical .Values.application.host -}}
46
+ {{- end -}}
47
+
48
+ {{- define "MAILHOG_SMTP_URL" -}}
49
+ {{- $namespace := .Release.Namespace -}}
50
+ {{- printf "smtp://%s.%s.svc.cluster.local:1025" .Values.mailhog.fullnameOverride $namespace -}}
51
+ {{- end -}}
52
+
53
+ {{- define "DB_NAME" -}}
54
+ {{ .Values.cloudsql.fullDbName }}
55
+ {{- end -}}
56
+
57
+ {{- define "POSTGRESQL_URL" -}}
58
+ postgresql://{{ .Values.cloudsql.dbUser }}:$(POSTGRESQL_PASSWORD)@localhost/{{ .Values.cloudsql.fullDbName }}?schema=public
59
+ {{- end -}}
60
+
61
+ {{- define "POSTGRESQL_HOST" -}}
62
+ localhost
63
+ {{- end -}}
64
+
65
+ {{- define "DB_USERNAME" -}}
66
+ {{ .Values.cloudsql.dbUser }}
67
+ {{- end -}}
68
+
69
+
70
+ {{- define "DB_PASSWORD" -}}
71
+ $(POSTGRESQL_PASSWORD)
72
+ {{- end -}}
73
+
74
+
75
+ {{- define "cloudSqlContainer" -}}
76
+ name: cloudsql-proxy
77
+ image: eu.gcr.io/cloud-sql-connectors/cloud-sql-proxy:2.18.0-alpine
78
+ # see https://github.com/kubernetes/kubernetes/issues/25908#issuecomment-308569672
79
+ # and https://github.com/kubernetes/enhancements/tree/master/keps/sig-node/753-sidecar-containers
80
+ command: ["/bin/sh", "-c"]
81
+ args:
82
+ - |
83
+ /cloud-sql-proxy --auto-ip --credentials-file /secrets/cloudsql/credentials.json "{{ .Values.cloudsql.instanceConnectionName }}" &
84
+ CHILD_PID=$!
85
+ (while true; do if [[ -f "/tmp/pod/main-terminated" ]]; then kill $CHILD_PID; fi; sleep 1; done) &
86
+ wait $CHILD_PID
87
+ if [[ -f "/tmp/pod/main-terminated" ]]; then exit 0; fi
88
+ securityContext:
89
+ runAsUser: 2 # non-root user
90
+ allowPrivilegeEscalation: false
91
+ resources: # each container needs requests, or the auto load balancer does not work
92
+ requests:
93
+ cpu: 50m
94
+ memory: 150Mi
95
+ volumeMounts:
96
+ - name: cloudsql-proxy-credentials
97
+ mountPath: /secrets/cloudsql
98
+ readOnly: true
99
+
100
+ - mountPath: /tmp/pod
101
+ name: tmp-pod
102
+ readOnly: true
103
+ {{- end -}}
104
+
105
+ {{- define "cloudSqlCredentialsVolume" -}}
106
+ name: cloudsql-proxy-credentials
107
+ secret:
108
+ secretName: {{ template "fullname" $ }}-cloudsql-proxy-credentials
109
+ {{- end -}}
110
+ {{/*
111
+ Generate prisma-URL
112
+ */}}
113
+ {{- define "PRISMA_ENDPOINT" -}}
114
+ {{- $appName := default .Release.Name .Values.global.appName -}}
115
+ {{- $namespace := .Release.Namespace -}}
116
+ {{- printf "http://%s-prisma.%s:4466/default/default" $appName $namespace -}}
117
+ {{- end -}}
118
+
119
+
120
+
121
+
122
+ {{/*
123
+ convert value to json-string if its an object
124
+ */}}
125
+ {{- define "envValue" -}}
126
+ {{- if (kindIs "map" .) -}}
127
+ {{ toJson . | quote}}
128
+ {{- else -}}
129
+ {{ quote . }}
130
+ {{- end -}}
131
+ {{- end -}}
132
+
133
+
134
+ {{- define "env" -}}
135
+ {{ $context := . }}
136
+
137
+
138
+
139
+ envFrom:
140
+ - configMapRef:
141
+ name: {{ template "fullname" $ }}-app-env
142
+ env:
143
+ {{- range $key, $val := .Values.env.secret }}
144
+ - name: {{ $key }}
145
+ valueFrom:
146
+ secretKeyRef:
147
+ name: {{ template "fullname" $ }}-app-secrets
148
+ key: {{ $key }}
149
+ {{- end }}
150
+
151
+ {{- range $key, $val := .Values.secretsFromOtherComponent }}
152
+
153
+ - name: {{ $key }}
154
+ valueFrom:
155
+ secretKeyRef:
156
+ name: {{ $.Values.global.appPrefix}}{{ $val }}-app-secrets
157
+ key: {{ $key }}
158
+ optional: true
159
+ {{- end }}
160
+
161
+ {{- range $key, $val := .Values.mapServiceUrlToEnv }}
162
+ {{- $otherServiceFullName := (printf "%s%s" $.Values.global.appPrefix $val) }}
163
+ {{- $variablePrefix := $otherServiceFullName | snakecase | upper }}
164
+ - name: {{ $key }}
165
+ value: "http://$({{ $variablePrefix }}_SERVICE_HOST):$({{ $variablePrefix }}_SERVICE_PORT)"
166
+ {{- end }}
167
+
168
+ # can't have these in app.env.configmap as some values contain $(OTHER_ENV_VAR)
169
+ {{ if .Values.cloudsql.enabled }}
170
+ - name: POSTGRESQL_URL
171
+ value: "{{- template "POSTGRESQL_URL" . -}}"
172
+ - name: DATABASE_URL
173
+ value: "{{- template "POSTGRESQL_URL" . -}}"
174
+
175
+ - name: POSTGRESQL_HOST
176
+ value: "{{- template "POSTGRESQL_HOST" . -}}"
177
+ - name: DB_HOST # alias
178
+ value: "{{- template "POSTGRESQL_HOST" . -}}"
179
+ - name: DB_NAME
180
+ value: "{{- template "DB_NAME" . -}}"
181
+ - name: DB_USERNAME #alias
182
+ value: "{{- template "DB_USERNAME" . -}}"
183
+ - name: DB_PASSWORD #alias
184
+ value: "{{- template "DB_PASSWORD" . -}}"
185
+ - name: POSTGRESQL_DBNAME # alias
186
+ value: "{{- template "DB_NAME" . -}}"
187
+ {{- end -}}
188
+
189
+ {{- end -}}
190
+
191
+
192
+
193
+ {{- define "visualReviewSnippet" -}}
194
+ <script
195
+ data-project-id='{{.Values.gitlab.projectId}}'
196
+ data-merge-request-id='{{.Values.gitlab.mergeRequestId}}'
197
+ data-mr-url='https://git.panter.ch'
198
+ data-project-path='{{.Values.gitlab.projectPath}}'
199
+ id='review-app-toolbar-script'
200
+ src='https://git.panter.ch/assets/webpack/visual_review_toolbar.js'>
201
+ </script>
202
+ {{- end -}}
@@ -0,0 +1,10 @@
1
+ {{- if .Values.cloudsql.enabled -}}
2
+ apiVersion: v1
3
+ kind: Secret
4
+ metadata:
5
+ name: {{ template "fullname" . }}-cloudsql-proxy-credentials
6
+ labels:
7
+ app: {{ .Release.Name }}
8
+ data:
9
+ credentials.json: {{ .Values.cloudsql.proxyCredentials | b64enc}}
10
+ {{- end }}