From 084730c14f1ce972d2304b582b063a2e6d925ac8 Mon Sep 17 00:00:00 2001 From: thenav56 Date: Thu, 31 Oct 2024 14:01:26 +0545 Subject: [PATCH] Add nginx-server helm chart --- .dockerignore | 138 ++++++++++++++++++++ .github/workflows/ci.yml | 16 +++ .github/workflows/publish-nginx-serve.yml | 143 +++++++++++++++++++++ app/env.ts | 7 +- nginx-serve/Dockerfile | 56 ++++++++ nginx-serve/apply-helm-config.sh | 25 ++++ nginx-serve/helm/Chart.yaml | 7 + nginx-serve/helm/templates/_helpers.tpl | 32 +++++ nginx-serve/helm/templates/configmap.yaml | 16 +++ nginx-serve/helm/templates/deployment.yaml | 36 ++++++ nginx-serve/helm/templates/ingress.yaml | 21 +++ nginx-serve/helm/templates/service.yaml | 18 +++ nginx-serve/helm/values-test.yaml | 16 +++ nginx-serve/helm/values.yaml | 24 ++++ nginx-serve/nginx.conf.template | 18 +++ 15 files changed, 571 insertions(+), 2 deletions(-) create mode 100644 .dockerignore create mode 100644 .github/workflows/publish-nginx-serve.yml create mode 100644 nginx-serve/Dockerfile create mode 100755 nginx-serve/apply-helm-config.sh create mode 100644 nginx-serve/helm/Chart.yaml create mode 100644 nginx-serve/helm/templates/_helpers.tpl create mode 100644 nginx-serve/helm/templates/configmap.yaml create mode 100644 nginx-serve/helm/templates/deployment.yaml create mode 100644 nginx-serve/helm/templates/ingress.yaml create mode 100644 nginx-serve/helm/templates/service.yaml create mode 100644 nginx-serve/helm/values-test.yaml create mode 100644 nginx-serve/helm/values.yaml create mode 100644 nginx-serve/nginx.conf.template diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..3971708e1 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,138 @@ +# Swap files +*.swp + +# Byte-compiled / optimized / DLL files +__pycache__ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +env +build +develop-eggs +dist +downloads +eggs +.eggs +lib +lib64 +parts +sdist +var +*.egg-info +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov +.tox +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*,cover +.hypothesis + +# Translations +*.mo +*.pot + +# Django stuff: +*.log + +# Sphinx documentation +docs/_build + +# PyBuilder +target + +#Ipython Notebook +.ipynb_checkpoints + +# SASS cache +.sass-cache +media_test + +# Rope project settings +.ropeproject + +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules +jspm_packages + +# Typescript v1 declaration files +typings + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env +.env* + +# Sensitive Deploy Files +deploy/eb/ + +# tox +./.tox diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f4be726d4..86c44e96a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -217,3 +217,19 @@ jobs: - name: Build run: yarn build working-directory: app + + validate_helm: + name: Validate Helm + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@main + + - name: Install Helm + uses: azure/setup-helm@v4 + + - name: 🐳 Helm lint + run: helm lint ./nginx-serve/helm --values ./nginx-serve/helm/values-test.yaml + + - name: 🐳 Helm template + run: helm template ./nginx-serve/helm --values ./nginx-serve/helm/values-test.yaml diff --git a/.github/workflows/publish-nginx-serve.yml b/.github/workflows/publish-nginx-serve.yml new file mode 100644 index 000000000..5b297c05e --- /dev/null +++ b/.github/workflows/publish-nginx-serve.yml @@ -0,0 +1,143 @@ +name: Publish nginx serve image + +on: + push: + branches: + - develop + - project/* + +jobs: + publish_image: + name: Publish Docker Image + runs-on: ubuntu-latest + + outputs: + docker_image_name: ${{ steps.prep.outputs.tagged_image_name }} + docker_image_tag: ${{ steps.prep.outputs.tag }} + docker_image: ${{ steps.prep.outputs.tagged_image }} + + steps: + - uses: actions/checkout@main + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + if: ${{ inputs.push_docker_image }} + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: 🐳 Prepare Docker + id: prep + env: + IMAGE_NAME: ghcr.io/${{ github.repository }} + run: | + BRANCH_NAME=$(echo $GITHUB_REF_NAME | sed 's|:|-|' | tr '[:upper:]' '[:lower:]' | sed 's/_/-/g' | cut -c1-100 | sed 's/-*$//') + + # XXX: Check if there is a slash in the BRANCH_NAME eg: project/add-docker + if [[ "$BRANCH_NAME" == *"/"* ]]; then + # XXX: Change the docker image package to -alpha + IMAGE_NAME="$IMAGE_NAME-alpha" + TAG="$(echo "$BRANCH_NAME" | sed 's|/|-|g').$(echo $GITHUB_SHA | head -c7)" + else + TAG="$BRANCH_NAME.$(echo $GITHUB_SHA | head -c7)" + fi + + IMAGE_NAME=$(echo $IMAGE_NAME | tr '[:upper:]' '[:lower:]') + echo "tagged_image_name=${IMAGE_NAME}" >> $GITHUB_OUTPUT + echo "tag=${TAG}" >> $GITHUB_OUTPUT + echo "tagged_image=${IMAGE_NAME}:${TAG}" >> $GITHUB_OUTPUT + echo "::notice::Tagged docker image: ${IMAGE_NAME}:${TAG}" + + - name: 🐳 Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v3 + + - name: 🐳 Cache Docker layers + uses: actions/cache@v4 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.ref }} + restore-keys: | + ${{ runner.os }}-buildx-refs/develop + ${{ runner.os }}-buildx- + + - name: 🐳 Docker build + uses: docker/build-push-action@v6 + with: + context: . + builder: ${{ steps.buildx.outputs.name }} + file: Dockerfile + target: nginx-serve + load: true + push: true + tags: ${{ steps.prep.outputs.tagged_image }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new + build-args: | + "APP_SENTRY_TRACES_SAMPLE_RATE=0.8" + "APP_SENTRY_REPLAYS_SESSION_SAMPLE_RATE=0.8" + "APP_SENTRY_REPLAYS_ON_ERROR_SAMPLE_RATE=0.8" + + - name: 🐳 Move docker cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache + + publish_helm: + name: Publish Helm + needs: publish_image + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Install Helm + uses: azure/setup-helm@v3 + + - name: Tag docker image in Helm Chart values.yaml + env: + IMAGE_NAME: ${{ needs.publish_image.outputs.docker_image_name }} + IMAGE_TAG: ${{ needs.publish_image.outputs.docker_image_tag }} + run: | + # Update values.yaml with latest docker image + sed -i "s|SET-BY-CICD-IMAGE|$IMAGE_NAME|" nginx-serve/helm/values.yaml + sed -i "s/SET-BY-CICD-TAG/$IMAGE_TAG/" nginx-serve/helm/values.yaml + + - name: Package Helm Chart + id: set-variables + run: | + # XXX: Check if there is a slash in the BRANCH_NAME eg: project/add-docker + if [[ "$GITHUB_REF_NAME" == *"/"* ]]; then + # XXX: Change the helm chart to -alpha + sed -i 's/^name: \(.*\)/name: \1-alpha/' nginx-serve/helm/Chart.yaml + fi + + SHA_SHORT=$(git rev-parse --short HEAD) + sed -i "s/SET-BY-CICD/$SHA_SHORT/g" nginx-serve/helm/Chart.yaml + helm package ./nginx-serve/helm -d .helm-charts + + - name: Push Helm Chart + env: + IMAGE: ${{ needs.publish_image.outputs.docker_image }} + OCI_REPO: oci://ghcr.io/${{ github.repository }} + run: | + OCI_REPO=$(echo $OCI_REPO | tr '[:upper:]' '[:lower:]') + PACKAGE_FILE=$(ls .helm-charts/*.tgz | head -n 1) + echo "# Helm Chart" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "Tagged Image: **$IMAGE**" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "Helm push output" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo '```bash' >> $GITHUB_STEP_SUMMARY + helm push "$PACKAGE_FILE" $OCI_REPO >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY diff --git a/app/env.ts b/app/env.ts index 94244c489..fe4048ad0 100644 --- a/app/env.ts +++ b/app/env.ts @@ -3,12 +3,15 @@ import { defineConfig, Schema } from '@julr/vite-plugin-validate-env'; export default defineConfig({ APP_TITLE: Schema.string(), APP_ENVIRONMENT: (key, value) => { - const regex = /^production|staging|testing|alpha-\d+|development$/; + const regex = /^production|staging|testing|alpha-\d+|development|APP_ENVIRONMENT_PLACEHOLDER$/; const valid = !!value && (value.match(regex) !== null); if (!valid) { throw new Error(`Value for environment variable "${key}" must match regex "${regex}", instead received "${value}"`); } - return value as ('production' | 'staging' | 'testing' | `alpha-${number}` | 'development'); + if (value === 'APP_ENVIRONMENT_PLACEHOLDER') { + console.warn(`Using ${value} for app environment. Make sure to not use this for builds without helm chart`) + } + return value as ('production' | 'staging' | 'testing' | `alpha-${number}` | 'development' | 'APP_ENVIRONMENT_PLACEHOLDER'); }, APP_API_ENDPOINT: Schema.string({ format: 'url', protocol: true, tld: false }), APP_ADMIN_URL: Schema.string.optional({ format: 'url', protocol: true }), diff --git a/nginx-serve/Dockerfile b/nginx-serve/Dockerfile new file mode 100644 index 000000000..5ee3fc6bb --- /dev/null +++ b/nginx-serve/Dockerfile @@ -0,0 +1,56 @@ +FROM node:18-bullseye AS runtime + +RUN apt-get update -y \ + && apt-get install -y --no-install-recommends \ + git bash g++ make \ + && rm -rf /var/lib/apt/lists/* + +WORKDIR /code + +RUN git config --global --add safe.directory /code + +# ------------------------------------------------------------------------------------ +FROM runtime AS nginx-build + +# TODO: Add cache with packages.json +# This is not working, will need @samshara help to configure this +# COPY package.json yarn.lock /code/ +# COPY app/package.json /code/app/ +COPY . /code + +RUN yarn install + +# Dynamic configs. Can be changed with containers. (Placeholder values) +ENV APP_TITLE=APP_TITLE_PLACEHOLDER +ENV APP_ENVIRONMENT=APP_ENVIRONMENT_PLACEHOLDER +ENV APP_MAPBOX_ACCESS_TOKEN=APP_MAPBOX_ACCESS_TOKEN_PLACEHOLDER +ENV APP_TINY_API_KEY=APP_TINY_API_KEY_PLACEHOLDER +ENV APP_API_ENDPOINT=https://APP-API-ENDPOINT-PLACEHOLDER.COM/ +ENV APP_RISK_API_ENDPOINT=https://APP-RISK-API-ENDPOINT-PLACEHOLDER.COM/ +ENV APP_SENTRY_DSN=https://APP-SENTRY-DSN-PLACEHOLDER.COM + +# Static configs (Configured when building docker image) +ARG APP_SENTRY_TRACES_SAMPLE_RATE= +ENV APP_SENTRY_TRACES_SAMPLE_RATE=${APP_SENTRY_TRACES_SAMPLE_RATE} +ARG APP_SENTRY_REPLAYS_SESSION_SAMPLE_RATE= +ENV APP_SENTRY_REPLAYS_SESSION_SAMPLE_RATE=${APP_SENTRY_REPLAYS_SESSION_SAMPLE_RATE} +ARG APP_SENTRY_REPLAYS_ON_ERROR_SAMPLE_RATE= +ENV APP_SENTRY_REPLAYS_ON_ERROR_SAMPLE_RATE=${APP_SENTRY_REPLAYS_ON_ERROR_SAMPLE_RATE} + + +RUN yarn build \ + && cd app \ + && yarn build + +# ------------------------------------------------------------------------------------ +FROM nginx:1 AS nginx-serve + +LABEL maintainer="IFRC" +LABEL org.opencontainers.image.source="https://github.com/IFRCGo/go-web-app" + +COPY ./nginx-serve/apply-helm-config.sh /docker-entrypoint.d/ +COPY ./nginx-serve/nginx.conf.template /etc/nginx/templates/default.conf.template +COPY --from=nginx-build /code/build /code/build + +ENV SOURCE_DIRECTORY=/code/build/ +ENV DESTINATION_DIRECTORY=/usr/share/nginx/html/ diff --git a/nginx-serve/apply-helm-config.sh b/nginx-serve/apply-helm-config.sh new file mode 100755 index 000000000..cba9646ba --- /dev/null +++ b/nginx-serve/apply-helm-config.sh @@ -0,0 +1,25 @@ +#!/bin/bash -x + +SOURCE_DIRECTORY=${SOURCE_DIRECTORY?Required} +DESTINATION_DIRECTORY=${DESTINATION_DIRECTORY?Required} + +if [ -d "$DESTINATION_DIRECTORY" ]; then + echo "Destination directory <$DESTINATION_DIRECTORY> already exists. Please delete and try again" +fi + +mkdir -p $(dirname "$DESTINATION_DIRECTORY") +cp -r --no-target-directory "$SOURCE_DIRECTORY" "$DESTINATION_DIRECTORY" + +find "$DESTINATION_DIRECTORY" -type f -exec sed -i "s/APP_TITLE_PLACEHOLDER/$APP_TITLE/g" {} + +find "$DESTINATION_DIRECTORY" -type f -exec sed -i "s/APP_ENVIRONMENT_PLACEHOLDER/$APP_ENVIRONMENT/g" {} + +find "$DESTINATION_DIRECTORY" -type f -exec sed -i "s/APP_MAPBOX_ACCESS_TOKEN_PLACEHOLDER/$APP_MAPBOX_ACCESS_TOKEN/g" {} + +find "$DESTINATION_DIRECTORY" -type f -exec sed -i "s/APP_TINY_API_KEY_PLACEHOLDER/$APP_TINY_API_KEY/g" {} + +find "$DESTINATION_DIRECTORY" -type f -exec sed -i "s|https://APP-API-ENDPOINT-PLACEHOLDER.COM/|$APP_API_ENDPOINT|g" {} + +find "$DESTINATION_DIRECTORY" -type f -exec sed -i "s|https://APP-RISK-API-ENDPOINT-PLACEHOLDER.COM/|$APP_RISK_API_ENDPOINT|g" {} + +find "$DESTINATION_DIRECTORY" -type f -exec sed -i "s|https://APP-SENTRY-DSN-PLACEHOLDER.COM|$APP_SENTRY_DSN|g" {} + + +# Show diffs (Useful to debug issues) +set +x +find "$SOURCE_DIRECTORY" -type f -printf '%P\n' | while IFS= read -r file; do + diff -W 100 <(fold -w 100 "$SOURCE_DIRECTORY/$file") <(fold -w 100 "$DESTINATION_DIRECTORY/$file") --suppress-common-lines +done diff --git a/nginx-serve/helm/Chart.yaml b/nginx-serve/helm/Chart.yaml new file mode 100644 index 000000000..91615a52a --- /dev/null +++ b/nginx-serve/helm/Chart.yaml @@ -0,0 +1,7 @@ +apiVersion: v2 +name: ifrcgo-web-app-nginx-serve +description: "Helm Chart to deploy the IFRC Web App" +type: application +version: 0.0.1-SET-BY-CICD +sources: + - https://github.com/IFRCGo/go-web-app diff --git a/nginx-serve/helm/templates/_helpers.tpl b/nginx-serve/helm/templates/_helpers.tpl new file mode 100644 index 000000000..7fbb177a2 --- /dev/null +++ b/nginx-serve/helm/templates/_helpers.tpl @@ -0,0 +1,32 @@ +{{/* + Expand the name of the chart. +*/}} +{{- define "ifrcgo-web-app.name" -}} + {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* + Create a default fully qualified app name. + We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). + If release name contains chart name it will be used as a full name. + https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#dns-label-names +*/}} +{{- define "ifrcgo-web-app.fullname" -}} + {{- if .Values.fullnameOverride -}} + {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} + {{- else -}} + {{- $name := default .Chart.Name .Values.nameOverride -}} + {{- if contains $name .Release.Name -}} + {{- .Release.Name | trunc 63 | trimSuffix "-" -}} + {{- else -}} + {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} + {{- end -}} + {{- end -}} +{{- end -}} + +{{/* + Create chart name and version as used by the chart label. +*/}} +{{- define "ifrcgo-web-app.chart" -}} + {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/nginx-serve/helm/templates/configmap.yaml b/nginx-serve/helm/templates/configmap.yaml new file mode 100644 index 000000000..3b2919be4 --- /dev/null +++ b/nginx-serve/helm/templates/configmap.yaml @@ -0,0 +1,16 @@ +kind: ConfigMap +apiVersion: v1 +metadata: + name: {{ template "ifrcgo-web-app.fullname" . }}-configmap + labels: + component: web-app-deployment + environment: {{ .Values.environment }} + release: {{ .Release.Name }} +data: + APP_ENVIRONMENT: {{ required "env.APP_ENVIRONMENT" .Values.env.APP_ENVIRONMENT | quote }} + APP_TITLE: {{ .Values.env.APP_ENVIRONMENT | quote }} + APP_API_ENDPOINT: {{ required "env.APP_API_ENDPOINT" .Values.env.APP_API_ENDPOINT | quote }} + APP_MAPBOX_ACCESS_TOKEN: {{ required "env.APP_MAPBOX_ACCESS_TOKEN" .Values.env.APP_MAPBOX_ACCESS_TOKEN | quote }} + APP_TINY_API_KEY: {{ required "env.APP_TINY_API_KEY" .Values.env.APP_TINY_API_KEY | quote }} + APP_RISK_API_ENDPOINT: {{ required "env.APP_RISK_API_ENDPOINT" .Values.env.APP_RISK_API_ENDPOINT | quote }} + APP_SENTRY_DSN: {{ required "env.APP_SENTRY_DSN" .Values.env.APP_SENTRY_DSN | quote }} diff --git a/nginx-serve/helm/templates/deployment.yaml b/nginx-serve/helm/templates/deployment.yaml new file mode 100644 index 000000000..d7720c044 --- /dev/null +++ b/nginx-serve/helm/templates/deployment.yaml @@ -0,0 +1,36 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ template "ifrcgo-web-app.fullname" . }} + labels: + environment: {{ .Values.environment }} + release: {{ .Release.Name }} +spec: + replicas: 1 + selector: + matchLabels: + app: {{ template "ifrcgo-web-app.name" . }} + release: {{ .Release.Name }} + template: + metadata: + labels: + app: {{ template "ifrcgo-web-app.name" . }} + release: {{ .Release.Name }} + spec: + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.name }}:{{ .Values.image.tag }}" + ports: + - name: http + containerPort: 80 + protocol: TCP + resources: + requests: + cpu: {{ .Values.resources.requests.cpu }} + memory: {{ .Values.resources.requests.memory }} + limits: + cpu: {{ .Values.resources.limits.cpu }} + memory: {{ .Values.resources.limits.memory }} + envFrom: + - configMapRef: + name: {{ template "ifrcgo-web-app.fullname" . }}-configmap diff --git a/nginx-serve/helm/templates/ingress.yaml b/nginx-serve/helm/templates/ingress.yaml new file mode 100644 index 000000000..eb55551fe --- /dev/null +++ b/nginx-serve/helm/templates/ingress.yaml @@ -0,0 +1,21 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ template "ifrcgo-web-app.fullname" . }}-ingress + labels: + app: {{ template "ifrcgo-web-app.name" . }} + environment: {{ .Values.environment }} + release: {{ .Release.Name }} +spec: + ingressClassName: nginx + rules: + - host: {{ required "ingress.host" .Values.ingress.host | quote }} + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: {{ template "ifrcgo-web-app.fullname" . }}-svc + port: + number: 80 diff --git a/nginx-serve/helm/templates/service.yaml b/nginx-serve/helm/templates/service.yaml new file mode 100644 index 000000000..1cf04941f --- /dev/null +++ b/nginx-serve/helm/templates/service.yaml @@ -0,0 +1,18 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ template "ifrcgo-web-app.fullname" . }}-svc + labels: + app: {{ template "ifrcgo-web-app.name" . }} + environment: {{ .Values.environment }} + release: {{ .Release.Name }} +spec: + type: ClusterIP + selector: + app: {{ template "ifrcgo-web-app.name" . }} + release: {{ .Release.Name }} + run: {{ .Release.Name }} + ports: + - protocol: TCP + port: 80 + targetPort: 80 diff --git a/nginx-serve/helm/values-test.yaml b/nginx-serve/helm/values-test.yaml new file mode 100644 index 000000000..0831ad757 --- /dev/null +++ b/nginx-serve/helm/values-test.yaml @@ -0,0 +1,16 @@ +environment: prod + +image: + name: test-image + tag: test-tag + +ingress: + host: web-app.test.com + +env: + APP_ENVIRONMENT: alpha-1 + APP_API_ENDPOINT: https://alpha-1-api.test.com + APP_MAPBOX_ACCESS_TOKEN: RANDOM_DUMMY_TOKEN + APP_TINY_API_KEY: RANDOM_DUMMY_TOKEN + APP_RISK_API_ENDPOINT: https://risk-1-api.test.com + APP_SENTRY_DSN: https://random-token@random-user@sentry-test.io/10000 diff --git a/nginx-serve/helm/values.yaml b/nginx-serve/helm/values.yaml new file mode 100644 index 000000000..76bc163ea --- /dev/null +++ b/nginx-serve/helm/values.yaml @@ -0,0 +1,24 @@ +environment: prod + +image: + name: SET-BY-CICD-IMAGE + tag: SET-BY-CICD-TAG + +resources: + requests: + cpu: "0.5" + memory: "100Mi" + limits: + cpu: "1" + memory: "100Mi" + +ingress: + host: + +env: + APP_ENVIRONMENT: + APP_API_ENDPOINT: + APP_MAPBOX_ACCESS_TOKEN: + APP_TINY_API_KEY: + APP_RISK_API_ENDPOINT: + APP_SENTRY_DSN: diff --git a/nginx-serve/nginx.conf.template b/nginx-serve/nginx.conf.template new file mode 100644 index 000000000..c1f5b41ab --- /dev/null +++ b/nginx-serve/nginx.conf.template @@ -0,0 +1,18 @@ +# vim: filetype=nginx + +server { + listen 80; + server_name _; + + gzip on; + gzip_comp_level 4; + + gzip_types text/plain text/css application/json + application/x-javascript text/xml application/xml + application/xml+rss text/javascript; + + location / { + alias $DESTINATION_DIRECTORY; + try_files $uri /index.html; + } +}