From 9d7643fcdc11034157b0599d40d4b5201a261bfb Mon Sep 17 00:00:00 2001 From: Tim Riedl Date: Fri, 1 Mar 2024 20:10:13 +0100 Subject: [PATCH 01/31] add basic helmcharts --- devops/deployments/hetzner-microk8s/.gitkeep | 0 devops/deployments/infrastructure/.gitkeep | 0 .../deployments/services/backend/.helmignore | 23 +++++++++++++++++++ .../deployments/services/backend/Chart.yaml | 7 ++++++ .../deployments/services/backend/values.yaml | 0 .../deployments/services/frontend/.helmignore | 23 +++++++++++++++++++ .../deployments/services/frontend/Chart.yaml | 7 ++++++ .../deployments/services/frontend/values.yaml | 0 .../services/standalone/.helmignore | 23 +++++++++++++++++++ .../services/standalone/Chart.yaml | 7 ++++++ .../services/standalone/values.yaml | 0 11 files changed, 90 insertions(+) create mode 100644 devops/deployments/hetzner-microk8s/.gitkeep create mode 100644 devops/deployments/infrastructure/.gitkeep create mode 100644 devops/deployments/services/backend/.helmignore create mode 100644 devops/deployments/services/backend/Chart.yaml create mode 100644 devops/deployments/services/backend/values.yaml create mode 100644 devops/deployments/services/frontend/.helmignore create mode 100644 devops/deployments/services/frontend/Chart.yaml create mode 100644 devops/deployments/services/frontend/values.yaml create mode 100644 devops/deployments/services/standalone/.helmignore create mode 100644 devops/deployments/services/standalone/Chart.yaml create mode 100644 devops/deployments/services/standalone/values.yaml diff --git a/devops/deployments/hetzner-microk8s/.gitkeep b/devops/deployments/hetzner-microk8s/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/devops/deployments/infrastructure/.gitkeep b/devops/deployments/infrastructure/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/devops/deployments/services/backend/.helmignore b/devops/deployments/services/backend/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/devops/deployments/services/backend/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/devops/deployments/services/backend/Chart.yaml b/devops/deployments/services/backend/Chart.yaml new file mode 100644 index 00000000..c5d4bdee --- /dev/null +++ b/devops/deployments/services/backend/Chart.yaml @@ -0,0 +1,7 @@ +apiVersion: v2 +name: backend +description: A Helm chart for Kubernetes + +type: application +version: 0.1.0 +appVersion: "1.16.0" diff --git a/devops/deployments/services/backend/values.yaml b/devops/deployments/services/backend/values.yaml new file mode 100644 index 00000000..e69de29b diff --git a/devops/deployments/services/frontend/.helmignore b/devops/deployments/services/frontend/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/devops/deployments/services/frontend/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/devops/deployments/services/frontend/Chart.yaml b/devops/deployments/services/frontend/Chart.yaml new file mode 100644 index 00000000..b6d9df81 --- /dev/null +++ b/devops/deployments/services/frontend/Chart.yaml @@ -0,0 +1,7 @@ +apiVersion: v2 +name: frontend +description: A Helm chart for Kubernetes + +type: application +version: 0.1.0 +appVersion: "1.16.0" diff --git a/devops/deployments/services/frontend/values.yaml b/devops/deployments/services/frontend/values.yaml new file mode 100644 index 00000000..e69de29b diff --git a/devops/deployments/services/standalone/.helmignore b/devops/deployments/services/standalone/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/devops/deployments/services/standalone/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/devops/deployments/services/standalone/Chart.yaml b/devops/deployments/services/standalone/Chart.yaml new file mode 100644 index 00000000..e7aa0fbc --- /dev/null +++ b/devops/deployments/services/standalone/Chart.yaml @@ -0,0 +1,7 @@ +apiVersion: v2 +name: standalone +description: A Helm chart for Kubernetes + +type: application +version: 0.1.0 +appVersion: "1.16.0" diff --git a/devops/deployments/services/standalone/values.yaml b/devops/deployments/services/standalone/values.yaml new file mode 100644 index 00000000..e69de29b From 03b03af099e3f5ede601c86554d0d9af28d66e6e Mon Sep 17 00:00:00 2001 From: Tim Riedl Date: Sun, 3 Mar 2024 13:04:15 +0100 Subject: [PATCH 02/31] commit --- .gitignore | 3 ++- devops/deployments/Readme.md | 9 ++++++++ .../azure-aks}/.gitkeep | 0 .../hetzner-microk8s}/.gitkeep | 0 .../deployments/core-infrastructure/.gitkeep | 0 .../core-infrastructure/ingress/.helmignore | 23 +++++++++++++++++++ .../core-infrastructure/ingress/Chart.lock | 6 +++++ .../core-infrastructure/ingress/Chart.yaml | 12 ++++++++++ .../core-infrastructure/ingress/values.yaml | 0 .../core-infrastructure/postgres/.helmignore | 23 +++++++++++++++++++ .../core-infrastructure/postgres/Chart.yaml | 12 ++++++++++ .../core-infrastructure/postgres/values.yaml | 0 12 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 devops/deployments/Readme.md rename devops/deployments/{hetzner-microk8s => cluster-deployment/azure-aks}/.gitkeep (100%) rename devops/deployments/{infrastructure => cluster-deployment/hetzner-microk8s}/.gitkeep (100%) create mode 100644 devops/deployments/core-infrastructure/.gitkeep create mode 100644 devops/deployments/core-infrastructure/ingress/.helmignore create mode 100644 devops/deployments/core-infrastructure/ingress/Chart.lock create mode 100644 devops/deployments/core-infrastructure/ingress/Chart.yaml create mode 100644 devops/deployments/core-infrastructure/ingress/values.yaml create mode 100644 devops/deployments/core-infrastructure/postgres/.helmignore create mode 100644 devops/deployments/core-infrastructure/postgres/Chart.yaml create mode 100644 devops/deployments/core-infrastructure/postgres/values.yaml diff --git a/.gitignore b/.gitignore index c9b0b4a8..fdccfd97 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ services/frontend/.svelte-kit services/frontend/node_modules services/backend/src/assets/frontend -.DS_Store \ No newline at end of file +.DS_Store +*.tgz \ No newline at end of file diff --git a/devops/deployments/Readme.md b/devops/deployments/Readme.md new file mode 100644 index 00000000..de9fe9e5 --- /dev/null +++ b/devops/deployments/Readme.md @@ -0,0 +1,9 @@ +# Application Deployment + +here you can find all needed IaC Code to deploy your application to your kubernetes cluster + +| Folder | Purpose | +| --------------------- | -------------------------------------------------------------------------------- | +| `cluster-deployment` | Uses Terraform + Ansible to setup the K8s cluster | +| `core-infrastructure` | Deploys application dependencies via Helm as an ingress controller or a database | +| `services` | Deploys the application services via Helm | diff --git a/devops/deployments/hetzner-microk8s/.gitkeep b/devops/deployments/cluster-deployment/azure-aks/.gitkeep similarity index 100% rename from devops/deployments/hetzner-microk8s/.gitkeep rename to devops/deployments/cluster-deployment/azure-aks/.gitkeep diff --git a/devops/deployments/infrastructure/.gitkeep b/devops/deployments/cluster-deployment/hetzner-microk8s/.gitkeep similarity index 100% rename from devops/deployments/infrastructure/.gitkeep rename to devops/deployments/cluster-deployment/hetzner-microk8s/.gitkeep diff --git a/devops/deployments/core-infrastructure/.gitkeep b/devops/deployments/core-infrastructure/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/devops/deployments/core-infrastructure/ingress/.helmignore b/devops/deployments/core-infrastructure/ingress/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/devops/deployments/core-infrastructure/ingress/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/devops/deployments/core-infrastructure/ingress/Chart.lock b/devops/deployments/core-infrastructure/ingress/Chart.lock new file mode 100644 index 00000000..e1434aa7 --- /dev/null +++ b/devops/deployments/core-infrastructure/ingress/Chart.lock @@ -0,0 +1,6 @@ +dependencies: +- name: traefik + repository: https://traefik.github.io/charts + version: 21.1.0 +digest: sha256:492ba42ae9661dc23a72b22f7757b53ccbab44c051e82e876e083bc28caf9630 +generated: "2024-03-01T22:43:04.634726+01:00" diff --git a/devops/deployments/core-infrastructure/ingress/Chart.yaml b/devops/deployments/core-infrastructure/ingress/Chart.yaml new file mode 100644 index 00000000..83d7a9e2 --- /dev/null +++ b/devops/deployments/core-infrastructure/ingress/Chart.yaml @@ -0,0 +1,12 @@ +apiVersion: v2 +name: ingress +description: A Helm chart for Kubernetes + +type: application +version: 0.1.0 +appVersion: "1.16.0" + +dependencies: + - name: traefik + version: 21.1.0 + repository: https://traefik.github.io/charts diff --git a/devops/deployments/core-infrastructure/ingress/values.yaml b/devops/deployments/core-infrastructure/ingress/values.yaml new file mode 100644 index 00000000..e69de29b diff --git a/devops/deployments/core-infrastructure/postgres/.helmignore b/devops/deployments/core-infrastructure/postgres/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/devops/deployments/core-infrastructure/postgres/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/devops/deployments/core-infrastructure/postgres/Chart.yaml b/devops/deployments/core-infrastructure/postgres/Chart.yaml new file mode 100644 index 00000000..b2b65b06 --- /dev/null +++ b/devops/deployments/core-infrastructure/postgres/Chart.yaml @@ -0,0 +1,12 @@ +apiVersion: v2 +name: postgres +description: A Helm chart for Kubernetes + +type: application +version: 0.1.0 +appVersion: "1.16.0" + +dependencies: + - name: + version: + repository: diff --git a/devops/deployments/core-infrastructure/postgres/values.yaml b/devops/deployments/core-infrastructure/postgres/values.yaml new file mode 100644 index 00000000..e69de29b From a5f3691cb53a9086184a979994de8a89660fe0d1 Mon Sep 17 00:00:00 2001 From: Tim Riedl Date: Fri, 8 Mar 2024 23:49:19 +0100 Subject: [PATCH 03/31] add basic helmfile --- .../{.gitkeep => helmfile.yaml} | 0 devops/deployments/services/Readme.md | 3 +++ .../services/helmfile-microservices.yaml | 15 +++++++++++++++ .../deployments/services/helmfile-standalone.yaml | 9 +++++++++ .../services/values/microservices/values-dev.yaml | 2 ++ .../values/microservices/values-prod.yaml | 2 ++ .../services/values/standalone/values-dev.yaml | 2 ++ .../services/values/standalone/values-prod.yaml | 2 ++ services/frontend/.gitignore | 2 +- 9 files changed, 36 insertions(+), 1 deletion(-) rename devops/deployments/core-infrastructure/{.gitkeep => helmfile.yaml} (100%) create mode 100644 devops/deployments/services/Readme.md create mode 100644 devops/deployments/services/helmfile-microservices.yaml create mode 100644 devops/deployments/services/helmfile-standalone.yaml create mode 100644 devops/deployments/services/values/microservices/values-dev.yaml create mode 100644 devops/deployments/services/values/microservices/values-prod.yaml create mode 100644 devops/deployments/services/values/standalone/values-dev.yaml create mode 100644 devops/deployments/services/values/standalone/values-prod.yaml diff --git a/devops/deployments/core-infrastructure/.gitkeep b/devops/deployments/core-infrastructure/helmfile.yaml similarity index 100% rename from devops/deployments/core-infrastructure/.gitkeep rename to devops/deployments/core-infrastructure/helmfile.yaml diff --git a/devops/deployments/services/Readme.md b/devops/deployments/services/Readme.md new file mode 100644 index 00000000..c304e211 --- /dev/null +++ b/devops/deployments/services/Readme.md @@ -0,0 +1,3 @@ +# Deploy Services + +Just having a frontend and backend service might be an easy thing to deploy just with helm and a little bash automation script, but when an application grows this can get nasty pretty quick. Helmfile is an enhancement to this so you can automate migrating multiple helm charts. Feel free to use it or just use the helm install / upgrade command instead. Whatever you prefer 🙂 diff --git a/devops/deployments/services/helmfile-microservices.yaml b/devops/deployments/services/helmfile-microservices.yaml new file mode 100644 index 00000000..c78a040f --- /dev/null +++ b/devops/deployments/services/helmfile-microservices.yaml @@ -0,0 +1,15 @@ +environments: + default: values.yaml +--- +releases: + - name: frontend + chart: ./frontend + version: ~0.0.1 + namespace: application + installed: true + + - name: backend + chart: ./backend + version: ~0.0.1 + namespace: application + installed: true diff --git a/devops/deployments/services/helmfile-standalone.yaml b/devops/deployments/services/helmfile-standalone.yaml new file mode 100644 index 00000000..e70ad0f5 --- /dev/null +++ b/devops/deployments/services/helmfile-standalone.yaml @@ -0,0 +1,9 @@ +environments: + default: ./values/standalone/values-dev.yaml +--- +releases: + - name: app + chart: ./standalone + version: ~0.0.1 + namespace: application + installed: true diff --git a/devops/deployments/services/values/microservices/values-dev.yaml b/devops/deployments/services/values/microservices/values-dev.yaml new file mode 100644 index 00000000..143b706f --- /dev/null +++ b/devops/deployments/services/values/microservices/values-dev.yaml @@ -0,0 +1,2 @@ +appStage: "dev-stage" +appVersion: "2024-03-01" diff --git a/devops/deployments/services/values/microservices/values-prod.yaml b/devops/deployments/services/values/microservices/values-prod.yaml new file mode 100644 index 00000000..e8546b30 --- /dev/null +++ b/devops/deployments/services/values/microservices/values-prod.yaml @@ -0,0 +1,2 @@ +appStage: "prod-stage" +appVersion: "2024-03-01" diff --git a/devops/deployments/services/values/standalone/values-dev.yaml b/devops/deployments/services/values/standalone/values-dev.yaml new file mode 100644 index 00000000..143b706f --- /dev/null +++ b/devops/deployments/services/values/standalone/values-dev.yaml @@ -0,0 +1,2 @@ +appStage: "dev-stage" +appVersion: "2024-03-01" diff --git a/devops/deployments/services/values/standalone/values-prod.yaml b/devops/deployments/services/values/standalone/values-prod.yaml new file mode 100644 index 00000000..e8546b30 --- /dev/null +++ b/devops/deployments/services/values/standalone/values-prod.yaml @@ -0,0 +1,2 @@ +appStage: "prod-stage" +appVersion: "2024-03-01" diff --git a/services/frontend/.gitignore b/services/frontend/.gitignore index 2cda9b0a..395bf4d2 100644 --- a/services/frontend/.gitignore +++ b/services/frontend/.gitignore @@ -8,4 +8,4 @@ node_modules !.env.example vite.config.js.timestamp-* vite.config.ts.timestamp-* -dist/ +dist From b905632bd670be433ca10fc090efb219c8b078df Mon Sep 17 00:00:00 2001 From: Tim Riedl Date: Sun, 24 Mar 2024 23:10:42 +0100 Subject: [PATCH 04/31] add civo k3s iac provider and helmfile for ingress + longhorn --- devops/deployments/.ci-pipeline/.gitignore | 1 + devops/deployments/Readme.md | 9 ----- .../core-infrastructure/ingress/.helmignore | 23 ------------ .../core-infrastructure/ingress/Chart.lock | 6 --- .../core-infrastructure/ingress/Chart.yaml | 12 ------ .../core-infrastructure/postgres/.helmignore | 23 ------------ .../core-infrastructure/postgres/Chart.yaml | 12 ------ .../helm-infrastructure/helmfile.yaml | 35 ++++++++++++++++++ .../values/authentik-identity-provider.yaml | 37 +++++++++++++++++++ .../values/ingress-nginx.yaml | 8 ++++ .../values/storage-longhorn.yaml} | 0 .../server-infrastructure/.gitignore | 34 +++++++++++++++++ .../azure-aks}/.gitkeep | 0 .../civo-k3s/.terraform.lock.hcl | 23 ++++++++++++ .../server-infrastructure/civo-k3s/main.tf | 37 +++++++++++++++++++ .../server-infrastructure/civo-k3s/makefile | 6 +++ .../civo-k3s/packages.tf | 16 ++++++++ .../civo-k3s/terraform.tfvars.copy.txt | 7 ++++ .../hetzner-microk8s/.gitkeep} | 0 devops/deployments/services/Readme.md | 3 -- .../backend/charts/.gitkeep} | 0 .../backend/templates/.gitkeep} | 0 .../services/frontend/charts/.gitkeep | 0 .../services/frontend/templates/.gitkeep | 0 .../services/helmfile-microservices.yaml | 15 -------- .../services/helmfile-standalone.yaml | 9 ----- devops/deployments/services/helmfile.yaml | 25 +++++++++++++ .../services/standalone/charts/.gitkeep | 0 .../services/standalone/templates/.gitkeep | 0 .../services/values/backend-develop.yaml | 3 ++ .../services/values/backend-prod.yaml | 3 ++ .../services/values/frontend-develop.yaml | 3 ++ .../services/values/frontend-prod.yaml | 3 ++ .../values/microservices/values-dev.yaml | 2 - .../values/microservices/values-prod.yaml | 2 - .../values/standalone/values-dev.yaml | 2 - .../values/standalone/values-prod.yaml | 2 - 37 files changed, 241 insertions(+), 120 deletions(-) create mode 100644 devops/deployments/.ci-pipeline/.gitignore delete mode 100644 devops/deployments/Readme.md delete mode 100644 devops/deployments/core-infrastructure/ingress/.helmignore delete mode 100644 devops/deployments/core-infrastructure/ingress/Chart.lock delete mode 100644 devops/deployments/core-infrastructure/ingress/Chart.yaml delete mode 100644 devops/deployments/core-infrastructure/postgres/.helmignore delete mode 100644 devops/deployments/core-infrastructure/postgres/Chart.yaml create mode 100644 devops/deployments/helm-infrastructure/helmfile.yaml create mode 100644 devops/deployments/helm-infrastructure/values/authentik-identity-provider.yaml create mode 100644 devops/deployments/helm-infrastructure/values/ingress-nginx.yaml rename devops/deployments/{cluster-deployment/azure-aks/.gitkeep => helm-infrastructure/values/storage-longhorn.yaml} (100%) create mode 100644 devops/deployments/server-infrastructure/.gitignore rename devops/deployments/{cluster-deployment/hetzner-microk8s => server-infrastructure/azure-aks}/.gitkeep (100%) create mode 100644 devops/deployments/server-infrastructure/civo-k3s/.terraform.lock.hcl create mode 100644 devops/deployments/server-infrastructure/civo-k3s/main.tf create mode 100644 devops/deployments/server-infrastructure/civo-k3s/makefile create mode 100644 devops/deployments/server-infrastructure/civo-k3s/packages.tf create mode 100644 devops/deployments/server-infrastructure/civo-k3s/terraform.tfvars.copy.txt rename devops/deployments/{core-infrastructure/helmfile.yaml => server-infrastructure/hetzner-microk8s/.gitkeep} (100%) delete mode 100644 devops/deployments/services/Readme.md rename devops/deployments/{core-infrastructure/ingress/values.yaml => services/backend/charts/.gitkeep} (100%) rename devops/deployments/{core-infrastructure/postgres/values.yaml => services/backend/templates/.gitkeep} (100%) create mode 100644 devops/deployments/services/frontend/charts/.gitkeep create mode 100644 devops/deployments/services/frontend/templates/.gitkeep delete mode 100644 devops/deployments/services/helmfile-microservices.yaml delete mode 100644 devops/deployments/services/helmfile-standalone.yaml create mode 100644 devops/deployments/services/helmfile.yaml create mode 100644 devops/deployments/services/standalone/charts/.gitkeep create mode 100644 devops/deployments/services/standalone/templates/.gitkeep create mode 100644 devops/deployments/services/values/backend-develop.yaml create mode 100644 devops/deployments/services/values/backend-prod.yaml create mode 100644 devops/deployments/services/values/frontend-develop.yaml create mode 100644 devops/deployments/services/values/frontend-prod.yaml delete mode 100644 devops/deployments/services/values/microservices/values-dev.yaml delete mode 100644 devops/deployments/services/values/microservices/values-prod.yaml delete mode 100644 devops/deployments/services/values/standalone/values-dev.yaml delete mode 100644 devops/deployments/services/values/standalone/values-prod.yaml diff --git a/devops/deployments/.ci-pipeline/.gitignore b/devops/deployments/.ci-pipeline/.gitignore new file mode 100644 index 00000000..30fa1cea --- /dev/null +++ b/devops/deployments/.ci-pipeline/.gitignore @@ -0,0 +1 @@ +config \ No newline at end of file diff --git a/devops/deployments/Readme.md b/devops/deployments/Readme.md deleted file mode 100644 index de9fe9e5..00000000 --- a/devops/deployments/Readme.md +++ /dev/null @@ -1,9 +0,0 @@ -# Application Deployment - -here you can find all needed IaC Code to deploy your application to your kubernetes cluster - -| Folder | Purpose | -| --------------------- | -------------------------------------------------------------------------------- | -| `cluster-deployment` | Uses Terraform + Ansible to setup the K8s cluster | -| `core-infrastructure` | Deploys application dependencies via Helm as an ingress controller or a database | -| `services` | Deploys the application services via Helm | diff --git a/devops/deployments/core-infrastructure/ingress/.helmignore b/devops/deployments/core-infrastructure/ingress/.helmignore deleted file mode 100644 index 0e8a0eb3..00000000 --- a/devops/deployments/core-infrastructure/ingress/.helmignore +++ /dev/null @@ -1,23 +0,0 @@ -# Patterns to ignore when building packages. -# This supports shell glob matching, relative path matching, and -# negation (prefixed with !). Only one pattern per line. -.DS_Store -# Common VCS dirs -.git/ -.gitignore -.bzr/ -.bzrignore -.hg/ -.hgignore -.svn/ -# Common backup files -*.swp -*.bak -*.tmp -*.orig -*~ -# Various IDEs -.project -.idea/ -*.tmproj -.vscode/ diff --git a/devops/deployments/core-infrastructure/ingress/Chart.lock b/devops/deployments/core-infrastructure/ingress/Chart.lock deleted file mode 100644 index e1434aa7..00000000 --- a/devops/deployments/core-infrastructure/ingress/Chart.lock +++ /dev/null @@ -1,6 +0,0 @@ -dependencies: -- name: traefik - repository: https://traefik.github.io/charts - version: 21.1.0 -digest: sha256:492ba42ae9661dc23a72b22f7757b53ccbab44c051e82e876e083bc28caf9630 -generated: "2024-03-01T22:43:04.634726+01:00" diff --git a/devops/deployments/core-infrastructure/ingress/Chart.yaml b/devops/deployments/core-infrastructure/ingress/Chart.yaml deleted file mode 100644 index 83d7a9e2..00000000 --- a/devops/deployments/core-infrastructure/ingress/Chart.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: v2 -name: ingress -description: A Helm chart for Kubernetes - -type: application -version: 0.1.0 -appVersion: "1.16.0" - -dependencies: - - name: traefik - version: 21.1.0 - repository: https://traefik.github.io/charts diff --git a/devops/deployments/core-infrastructure/postgres/.helmignore b/devops/deployments/core-infrastructure/postgres/.helmignore deleted file mode 100644 index 0e8a0eb3..00000000 --- a/devops/deployments/core-infrastructure/postgres/.helmignore +++ /dev/null @@ -1,23 +0,0 @@ -# Patterns to ignore when building packages. -# This supports shell glob matching, relative path matching, and -# negation (prefixed with !). Only one pattern per line. -.DS_Store -# Common VCS dirs -.git/ -.gitignore -.bzr/ -.bzrignore -.hg/ -.hgignore -.svn/ -# Common backup files -*.swp -*.bak -*.tmp -*.orig -*~ -# Various IDEs -.project -.idea/ -*.tmproj -.vscode/ diff --git a/devops/deployments/core-infrastructure/postgres/Chart.yaml b/devops/deployments/core-infrastructure/postgres/Chart.yaml deleted file mode 100644 index b2b65b06..00000000 --- a/devops/deployments/core-infrastructure/postgres/Chart.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: v2 -name: postgres -description: A Helm chart for Kubernetes - -type: application -version: 0.1.0 -appVersion: "1.16.0" - -dependencies: - - name: - version: - repository: diff --git a/devops/deployments/helm-infrastructure/helmfile.yaml b/devops/deployments/helm-infrastructure/helmfile.yaml new file mode 100644 index 00000000..aed29b0b --- /dev/null +++ b/devops/deployments/helm-infrastructure/helmfile.yaml @@ -0,0 +1,35 @@ +repositories: + - name: ingress-nginx + url: https://kubernetes.github.io/ingress-nginx + - name: goauthentik + url: https://charts.goauthentik.io/ + - name: longhorn + url: https://charts.longhorn.io + +releases: + - name: ingress + chart: ingress-nginx/ingress-nginx + namespace: ingress + createNamespace: true + values: + - "./values/ingress-nginx.yaml" + + - name: longhorn + chart: longhorn/longhorn + version: 1.6.0 + namespace: longhorn + createNamespace: true + values: + - "./values/storage-longhorn.yaml" + + # - name: authentik + # chart: goauthentik/authentik + # version: 2024.2.2 + # namespace: identityprovider + # createNamespace: true + # needs: + # - ingress + # - longhorn + # values: + # - "./values/authentik-identity-provider.yaml" + \ No newline at end of file diff --git a/devops/deployments/helm-infrastructure/values/authentik-identity-provider.yaml b/devops/deployments/helm-infrastructure/values/authentik-identity-provider.yaml new file mode 100644 index 00000000..f801e6c5 --- /dev/null +++ b/devops/deployments/helm-infrastructure/values/authentik-identity-provider.yaml @@ -0,0 +1,37 @@ +authentik: + secret_key: "PleaseGenerateA50CharKey" + # This sends anonymous usage-data, stack traces on errors and + # performance data to authentik.error-reporting.a7k.io, and is fully opt-in + error_reporting: + enabled: true + postgresql: + host: postgres.domain.tld + user: file:///postgres-creds/username + password: file:///postgres-creds/password + +server: + volumes: + - name: postgres-creds + secret: + secretName: authentik-postgres-credentials + volumeMounts: + - name: postgres-creds + mountPath: /postgres-creds + readOnly: true +worker: + volumes: + - name: postgres-creds + secret: + secretName: authentik-postgres-credentials + volumeMounts: + - name: postgres-creds + mountPath: /postgres-creds + readOnly: true + +postgresql: + enabled: true + auth: + password: "ThisIsNotASecurePassword" + +redis: + enabled: true \ No newline at end of file diff --git a/devops/deployments/helm-infrastructure/values/ingress-nginx.yaml b/devops/deployments/helm-infrastructure/values/ingress-nginx.yaml new file mode 100644 index 00000000..6bb3e1f3 --- /dev/null +++ b/devops/deployments/helm-infrastructure/values/ingress-nginx.yaml @@ -0,0 +1,8 @@ +appName: ingress + +container: + imagename: nginx:latest + pod: + webserverPort: 80 + service: + webserverPort: 80 \ No newline at end of file diff --git a/devops/deployments/cluster-deployment/azure-aks/.gitkeep b/devops/deployments/helm-infrastructure/values/storage-longhorn.yaml similarity index 100% rename from devops/deployments/cluster-deployment/azure-aks/.gitkeep rename to devops/deployments/helm-infrastructure/values/storage-longhorn.yaml diff --git a/devops/deployments/server-infrastructure/.gitignore b/devops/deployments/server-infrastructure/.gitignore new file mode 100644 index 00000000..dc825268 --- /dev/null +++ b/devops/deployments/server-infrastructure/.gitignore @@ -0,0 +1,34 @@ +# Local .terraform directories +**/.terraform/* + +# .tfstate files +*.tfstate +*.tfstate.* + +# Crash log files +crash.log +crash.*.log + +# Exclude all .tfvars files, which are likely to contain sensitive data, such as +# password, private keys, and other secrets. These should not be part of version +# control as they are data points which are potentially sensitive and subject +# to change depending on the environment. +*.tfvars +*.tfvars.json + +# Ignore override files as they are usually used to override resources locally and so +# are not checked in +override.tf +override.tf.json +*_override.tf +*_override.tf.json + +# Include override files you do wish to add to version control using negated pattern +# !example_override.tf + +# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan +# example: *tfplan* + +# Ignore CLI configuration files +.terraformrc +terraform.rc \ No newline at end of file diff --git a/devops/deployments/cluster-deployment/hetzner-microk8s/.gitkeep b/devops/deployments/server-infrastructure/azure-aks/.gitkeep similarity index 100% rename from devops/deployments/cluster-deployment/hetzner-microk8s/.gitkeep rename to devops/deployments/server-infrastructure/azure-aks/.gitkeep diff --git a/devops/deployments/server-infrastructure/civo-k3s/.terraform.lock.hcl b/devops/deployments/server-infrastructure/civo-k3s/.terraform.lock.hcl new file mode 100644 index 00000000..4deff345 --- /dev/null +++ b/devops/deployments/server-infrastructure/civo-k3s/.terraform.lock.hcl @@ -0,0 +1,23 @@ +# This file is maintained automatically by "terraform init". +# Manual edits may be lost in future updates. + +provider "registry.terraform.io/civo/civo" { + version = "1.0.39" + constraints = "1.0.39" + hashes = [ + "h1:q9Q9sgU/rz/i6LSrC1UIIe09ho7RIhuQy4PwONMK6aM=", + "zh:31be8b548cd947e295d36f15d06aa8639b341b4a5ab6d510b2d8ad3cdad5fd80", + "zh:487703dacda66ac26191995fb3de7a81f40e693811df4a4c4bbb5749683e3858", + "zh:581b7137edc725675ad6e5f3a793009a00426eadbaaad0998ce42b32762e46af", + "zh:67f3b8deacd0c8bed1a19f384d9b67870cb7e4c7264ce231de9fd4034722ca47", + "zh:6875b743ab015d6dc54a1f2188848cd2ac37e5fcc5fcf469cff68a5ae41defa4", + "zh:68f0d2a86ad23f7c413862de83630f5cada77bd24d93f47f3739e2a6c0892303", + "zh:8b7f7aa8a53ebe94b75a37966dd9f4553ae3c6beb27e239a55f480eb7e85bda8", + "zh:9f6b944dcfcc2bc492930025dd57544afabdbfb3aed2b56c1e2f898be8aa291f", + "zh:b4f8c6a9478ab53c399d75bb7b8c0d5c72ff66f74d8d6423f93d6f9caca1b04b", + "zh:b72e6856d9e4bc5d6ffba996d542aef96973011fd58fe464fda628477839634c", + "zh:bdbafdcb2bf07625a39c88cba465fd16b211a74a22d62341bd488d445784b840", + "zh:e027b42063702a470ba2d8f9e7af22edb0997051ab9deb7c4775c13e9aebe89f", + "zh:e16f7731c9f65a2467538ea4ac7b8f241cec0a4e4db04198f19f238d7e507b82", + ] +} diff --git a/devops/deployments/server-infrastructure/civo-k3s/main.tf b/devops/deployments/server-infrastructure/civo-k3s/main.tf new file mode 100644 index 00000000..c5d88966 --- /dev/null +++ b/devops/deployments/server-infrastructure/civo-k3s/main.tf @@ -0,0 +1,37 @@ +variable "civo_kubernetes_size" {} +variable "civo_kubernetes_count" {} + +# Create a firewall +resource "civo_firewall" "my-firewall" { + name = "application-firewall" +} + +# Create a firewall rule +resource "civo_firewall_rule" "kubernetes" { + firewall_id = civo_firewall.my-firewall.id + protocol = "tcp" + start_port = "6443" + end_port = "6443" + cidr = ["0.0.0.0/0"] + direction = "ingress" + label = "kubernetes-api-server" + action = "allow" +} + +# Create a cluster with k3s +resource "civo_kubernetes_cluster" "my-cluster" { + name = "my-cluster" + # applications = "Portainer,Linkerd:Linkerd & Jaeger" + firewall_id = civo_firewall.my-firewall.id + cluster_type = "k3s" + pools { + label = "myapplication" // Optional + size = var.civo_kubernetes_size + node_count = var.civo_kubernetes_count + } +} + +output "k8skubeconfig" { + sensitive = true + value = civo_kubernetes_cluster.my-cluster.kubeconfig +} diff --git a/devops/deployments/server-infrastructure/civo-k3s/makefile b/devops/deployments/server-infrastructure/civo-k3s/makefile new file mode 100644 index 00000000..e1fb1cd2 --- /dev/null +++ b/devops/deployments/server-infrastructure/civo-k3s/makefile @@ -0,0 +1,6 @@ +run: + @terraform apply + @terraform output -raw k8skubeconfig > ../../.ci-pipeline/config + +destroy: + @terraform destroy \ No newline at end of file diff --git a/devops/deployments/server-infrastructure/civo-k3s/packages.tf b/devops/deployments/server-infrastructure/civo-k3s/packages.tf new file mode 100644 index 00000000..41deb664 --- /dev/null +++ b/devops/deployments/server-infrastructure/civo-k3s/packages.tf @@ -0,0 +1,16 @@ +variable "civo_token" {} +variable "civo_region" {} + +terraform { + required_providers { + civo = { + source = "civo/civo" + version = "1.0.39" + } + } +} + +provider "civo" { + token = var.civo_token + region = var.civo_region +} diff --git a/devops/deployments/server-infrastructure/civo-k3s/terraform.tfvars.copy.txt b/devops/deployments/server-infrastructure/civo-k3s/terraform.tfvars.copy.txt new file mode 100644 index 00000000..932a7dc7 --- /dev/null +++ b/devops/deployments/server-infrastructure/civo-k3s/terraform.tfvars.copy.txt @@ -0,0 +1,7 @@ +# civo settings +civo_token = "" +civo_region = "FRA1" + +# civo cluster +civo_kubernetes_size = "g4s.kube.medium" +civo_kubernetes_count = 3 diff --git a/devops/deployments/core-infrastructure/helmfile.yaml b/devops/deployments/server-infrastructure/hetzner-microk8s/.gitkeep similarity index 100% rename from devops/deployments/core-infrastructure/helmfile.yaml rename to devops/deployments/server-infrastructure/hetzner-microk8s/.gitkeep diff --git a/devops/deployments/services/Readme.md b/devops/deployments/services/Readme.md deleted file mode 100644 index c304e211..00000000 --- a/devops/deployments/services/Readme.md +++ /dev/null @@ -1,3 +0,0 @@ -# Deploy Services - -Just having a frontend and backend service might be an easy thing to deploy just with helm and a little bash automation script, but when an application grows this can get nasty pretty quick. Helmfile is an enhancement to this so you can automate migrating multiple helm charts. Feel free to use it or just use the helm install / upgrade command instead. Whatever you prefer 🙂 diff --git a/devops/deployments/core-infrastructure/ingress/values.yaml b/devops/deployments/services/backend/charts/.gitkeep similarity index 100% rename from devops/deployments/core-infrastructure/ingress/values.yaml rename to devops/deployments/services/backend/charts/.gitkeep diff --git a/devops/deployments/core-infrastructure/postgres/values.yaml b/devops/deployments/services/backend/templates/.gitkeep similarity index 100% rename from devops/deployments/core-infrastructure/postgres/values.yaml rename to devops/deployments/services/backend/templates/.gitkeep diff --git a/devops/deployments/services/frontend/charts/.gitkeep b/devops/deployments/services/frontend/charts/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/devops/deployments/services/frontend/templates/.gitkeep b/devops/deployments/services/frontend/templates/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/devops/deployments/services/helmfile-microservices.yaml b/devops/deployments/services/helmfile-microservices.yaml deleted file mode 100644 index c78a040f..00000000 --- a/devops/deployments/services/helmfile-microservices.yaml +++ /dev/null @@ -1,15 +0,0 @@ -environments: - default: values.yaml ---- -releases: - - name: frontend - chart: ./frontend - version: ~0.0.1 - namespace: application - installed: true - - - name: backend - chart: ./backend - version: ~0.0.1 - namespace: application - installed: true diff --git a/devops/deployments/services/helmfile-standalone.yaml b/devops/deployments/services/helmfile-standalone.yaml deleted file mode 100644 index e70ad0f5..00000000 --- a/devops/deployments/services/helmfile-standalone.yaml +++ /dev/null @@ -1,9 +0,0 @@ -environments: - default: ./values/standalone/values-dev.yaml ---- -releases: - - name: app - chart: ./standalone - version: ~0.0.1 - namespace: application - installed: true diff --git a/devops/deployments/services/helmfile.yaml b/devops/deployments/services/helmfile.yaml new file mode 100644 index 00000000..1d0b754f --- /dev/null +++ b/devops/deployments/services/helmfile.yaml @@ -0,0 +1,25 @@ +environments: + develop: {} + prod: {} + +--- + +releases: + - name: frontend + chart: ./frontend + namespace: application-{{ .Environment.Name }} + createNamespace: true + installed: true + values: + - "./values/frontend-{{ .Environment.Name }}.yaml" + + - name: backend + chart: ./backend + namespace: application-{{ .Environment.Name }} + createNamespace: true + installed: true + values: + - "./values/backend-{{ .Environment.Name }}.yaml" + # set: + # - name: database.password + # value: {{ requiredEnv "SOMETHING" }} \ No newline at end of file diff --git a/devops/deployments/services/standalone/charts/.gitkeep b/devops/deployments/services/standalone/charts/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/devops/deployments/services/standalone/templates/.gitkeep b/devops/deployments/services/standalone/templates/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/devops/deployments/services/values/backend-develop.yaml b/devops/deployments/services/values/backend-develop.yaml new file mode 100644 index 00000000..b48a35f0 --- /dev/null +++ b/devops/deployments/services/values/backend-develop.yaml @@ -0,0 +1,3 @@ +application: + environment: + name: "develop" diff --git a/devops/deployments/services/values/backend-prod.yaml b/devops/deployments/services/values/backend-prod.yaml new file mode 100644 index 00000000..f202c7d2 --- /dev/null +++ b/devops/deployments/services/values/backend-prod.yaml @@ -0,0 +1,3 @@ +application: + environment: + name: "production" diff --git a/devops/deployments/services/values/frontend-develop.yaml b/devops/deployments/services/values/frontend-develop.yaml new file mode 100644 index 00000000..b48a35f0 --- /dev/null +++ b/devops/deployments/services/values/frontend-develop.yaml @@ -0,0 +1,3 @@ +application: + environment: + name: "develop" diff --git a/devops/deployments/services/values/frontend-prod.yaml b/devops/deployments/services/values/frontend-prod.yaml new file mode 100644 index 00000000..f202c7d2 --- /dev/null +++ b/devops/deployments/services/values/frontend-prod.yaml @@ -0,0 +1,3 @@ +application: + environment: + name: "production" diff --git a/devops/deployments/services/values/microservices/values-dev.yaml b/devops/deployments/services/values/microservices/values-dev.yaml deleted file mode 100644 index 143b706f..00000000 --- a/devops/deployments/services/values/microservices/values-dev.yaml +++ /dev/null @@ -1,2 +0,0 @@ -appStage: "dev-stage" -appVersion: "2024-03-01" diff --git a/devops/deployments/services/values/microservices/values-prod.yaml b/devops/deployments/services/values/microservices/values-prod.yaml deleted file mode 100644 index e8546b30..00000000 --- a/devops/deployments/services/values/microservices/values-prod.yaml +++ /dev/null @@ -1,2 +0,0 @@ -appStage: "prod-stage" -appVersion: "2024-03-01" diff --git a/devops/deployments/services/values/standalone/values-dev.yaml b/devops/deployments/services/values/standalone/values-dev.yaml deleted file mode 100644 index 143b706f..00000000 --- a/devops/deployments/services/values/standalone/values-dev.yaml +++ /dev/null @@ -1,2 +0,0 @@ -appStage: "dev-stage" -appVersion: "2024-03-01" diff --git a/devops/deployments/services/values/standalone/values-prod.yaml b/devops/deployments/services/values/standalone/values-prod.yaml deleted file mode 100644 index e8546b30..00000000 --- a/devops/deployments/services/values/standalone/values-prod.yaml +++ /dev/null @@ -1,2 +0,0 @@ -appStage: "prod-stage" -appVersion: "2024-03-01" From cc582e68368baf7cafd1d456cb193903343ca8ff Mon Sep 17 00:00:00 2001 From: Tim Riedl Date: Wed, 27 Mar 2024 20:35:38 +0100 Subject: [PATCH 05/31] rename folder --- .../backend/.helmignore | 0 .../backend/Chart.yaml | 0 .../backend/charts/.gitkeep | 0 .../backend/templates/.gitkeep | 0 .../backend/values.yaml | 0 .../frontend/.helmignore | 0 .../frontend/Chart.yaml | 0 .../frontend/charts/.gitkeep | 0 .../frontend/templates/.gitkeep | 0 .../frontend/values.yaml | 0 .../helmfile.yaml | 0 .../standalone/.helmignore | 0 .../standalone/Chart.yaml | 0 .../standalone/charts/.gitkeep | 0 .../standalone/templates/.gitkeep | 0 .../standalone/values.yaml | 0 .../values/backend-develop.yaml | 0 .../values/backend-prod.yaml | 0 .../values/frontend-develop.yaml | 0 .../values/frontend-prod.yaml | 0 .../helmfile.yaml | 0 .../values/authentik-identity-provider.yaml | 0 .../values/ingress-nginx.yaml | 0 .../values/storage-longhorn.yaml | 0 .../server-infrastructure/civo-k3s/main.tf | 21 +++++++++++++++++++ 25 files changed, 21 insertions(+) rename devops/deployments/{services => application-services}/backend/.helmignore (100%) rename devops/deployments/{services => application-services}/backend/Chart.yaml (100%) rename devops/deployments/{services => application-services}/backend/charts/.gitkeep (100%) rename devops/deployments/{services => application-services}/backend/templates/.gitkeep (100%) rename devops/deployments/{services => application-services}/backend/values.yaml (100%) rename devops/deployments/{services => application-services}/frontend/.helmignore (100%) rename devops/deployments/{services => application-services}/frontend/Chart.yaml (100%) rename devops/deployments/{services => application-services}/frontend/charts/.gitkeep (100%) rename devops/deployments/{services => application-services}/frontend/templates/.gitkeep (100%) rename devops/deployments/{services => application-services}/frontend/values.yaml (100%) rename devops/deployments/{services => application-services}/helmfile.yaml (100%) rename devops/deployments/{services => application-services}/standalone/.helmignore (100%) rename devops/deployments/{services => application-services}/standalone/Chart.yaml (100%) rename devops/deployments/{services => application-services}/standalone/charts/.gitkeep (100%) rename devops/deployments/{services => application-services}/standalone/templates/.gitkeep (100%) rename devops/deployments/{services => application-services}/standalone/values.yaml (100%) rename devops/deployments/{services => application-services}/values/backend-develop.yaml (100%) rename devops/deployments/{services => application-services}/values/backend-prod.yaml (100%) rename devops/deployments/{services => application-services}/values/frontend-develop.yaml (100%) rename devops/deployments/{services => application-services}/values/frontend-prod.yaml (100%) rename devops/deployments/{helm-infrastructure => required-base-applications}/helmfile.yaml (100%) rename devops/deployments/{helm-infrastructure => required-base-applications}/values/authentik-identity-provider.yaml (100%) rename devops/deployments/{helm-infrastructure => required-base-applications}/values/ingress-nginx.yaml (100%) rename devops/deployments/{helm-infrastructure => required-base-applications}/values/storage-longhorn.yaml (100%) diff --git a/devops/deployments/services/backend/.helmignore b/devops/deployments/application-services/backend/.helmignore similarity index 100% rename from devops/deployments/services/backend/.helmignore rename to devops/deployments/application-services/backend/.helmignore diff --git a/devops/deployments/services/backend/Chart.yaml b/devops/deployments/application-services/backend/Chart.yaml similarity index 100% rename from devops/deployments/services/backend/Chart.yaml rename to devops/deployments/application-services/backend/Chart.yaml diff --git a/devops/deployments/services/backend/charts/.gitkeep b/devops/deployments/application-services/backend/charts/.gitkeep similarity index 100% rename from devops/deployments/services/backend/charts/.gitkeep rename to devops/deployments/application-services/backend/charts/.gitkeep diff --git a/devops/deployments/services/backend/templates/.gitkeep b/devops/deployments/application-services/backend/templates/.gitkeep similarity index 100% rename from devops/deployments/services/backend/templates/.gitkeep rename to devops/deployments/application-services/backend/templates/.gitkeep diff --git a/devops/deployments/services/backend/values.yaml b/devops/deployments/application-services/backend/values.yaml similarity index 100% rename from devops/deployments/services/backend/values.yaml rename to devops/deployments/application-services/backend/values.yaml diff --git a/devops/deployments/services/frontend/.helmignore b/devops/deployments/application-services/frontend/.helmignore similarity index 100% rename from devops/deployments/services/frontend/.helmignore rename to devops/deployments/application-services/frontend/.helmignore diff --git a/devops/deployments/services/frontend/Chart.yaml b/devops/deployments/application-services/frontend/Chart.yaml similarity index 100% rename from devops/deployments/services/frontend/Chart.yaml rename to devops/deployments/application-services/frontend/Chart.yaml diff --git a/devops/deployments/services/frontend/charts/.gitkeep b/devops/deployments/application-services/frontend/charts/.gitkeep similarity index 100% rename from devops/deployments/services/frontend/charts/.gitkeep rename to devops/deployments/application-services/frontend/charts/.gitkeep diff --git a/devops/deployments/services/frontend/templates/.gitkeep b/devops/deployments/application-services/frontend/templates/.gitkeep similarity index 100% rename from devops/deployments/services/frontend/templates/.gitkeep rename to devops/deployments/application-services/frontend/templates/.gitkeep diff --git a/devops/deployments/services/frontend/values.yaml b/devops/deployments/application-services/frontend/values.yaml similarity index 100% rename from devops/deployments/services/frontend/values.yaml rename to devops/deployments/application-services/frontend/values.yaml diff --git a/devops/deployments/services/helmfile.yaml b/devops/deployments/application-services/helmfile.yaml similarity index 100% rename from devops/deployments/services/helmfile.yaml rename to devops/deployments/application-services/helmfile.yaml diff --git a/devops/deployments/services/standalone/.helmignore b/devops/deployments/application-services/standalone/.helmignore similarity index 100% rename from devops/deployments/services/standalone/.helmignore rename to devops/deployments/application-services/standalone/.helmignore diff --git a/devops/deployments/services/standalone/Chart.yaml b/devops/deployments/application-services/standalone/Chart.yaml similarity index 100% rename from devops/deployments/services/standalone/Chart.yaml rename to devops/deployments/application-services/standalone/Chart.yaml diff --git a/devops/deployments/services/standalone/charts/.gitkeep b/devops/deployments/application-services/standalone/charts/.gitkeep similarity index 100% rename from devops/deployments/services/standalone/charts/.gitkeep rename to devops/deployments/application-services/standalone/charts/.gitkeep diff --git a/devops/deployments/services/standalone/templates/.gitkeep b/devops/deployments/application-services/standalone/templates/.gitkeep similarity index 100% rename from devops/deployments/services/standalone/templates/.gitkeep rename to devops/deployments/application-services/standalone/templates/.gitkeep diff --git a/devops/deployments/services/standalone/values.yaml b/devops/deployments/application-services/standalone/values.yaml similarity index 100% rename from devops/deployments/services/standalone/values.yaml rename to devops/deployments/application-services/standalone/values.yaml diff --git a/devops/deployments/services/values/backend-develop.yaml b/devops/deployments/application-services/values/backend-develop.yaml similarity index 100% rename from devops/deployments/services/values/backend-develop.yaml rename to devops/deployments/application-services/values/backend-develop.yaml diff --git a/devops/deployments/services/values/backend-prod.yaml b/devops/deployments/application-services/values/backend-prod.yaml similarity index 100% rename from devops/deployments/services/values/backend-prod.yaml rename to devops/deployments/application-services/values/backend-prod.yaml diff --git a/devops/deployments/services/values/frontend-develop.yaml b/devops/deployments/application-services/values/frontend-develop.yaml similarity index 100% rename from devops/deployments/services/values/frontend-develop.yaml rename to devops/deployments/application-services/values/frontend-develop.yaml diff --git a/devops/deployments/services/values/frontend-prod.yaml b/devops/deployments/application-services/values/frontend-prod.yaml similarity index 100% rename from devops/deployments/services/values/frontend-prod.yaml rename to devops/deployments/application-services/values/frontend-prod.yaml diff --git a/devops/deployments/helm-infrastructure/helmfile.yaml b/devops/deployments/required-base-applications/helmfile.yaml similarity index 100% rename from devops/deployments/helm-infrastructure/helmfile.yaml rename to devops/deployments/required-base-applications/helmfile.yaml diff --git a/devops/deployments/helm-infrastructure/values/authentik-identity-provider.yaml b/devops/deployments/required-base-applications/values/authentik-identity-provider.yaml similarity index 100% rename from devops/deployments/helm-infrastructure/values/authentik-identity-provider.yaml rename to devops/deployments/required-base-applications/values/authentik-identity-provider.yaml diff --git a/devops/deployments/helm-infrastructure/values/ingress-nginx.yaml b/devops/deployments/required-base-applications/values/ingress-nginx.yaml similarity index 100% rename from devops/deployments/helm-infrastructure/values/ingress-nginx.yaml rename to devops/deployments/required-base-applications/values/ingress-nginx.yaml diff --git a/devops/deployments/helm-infrastructure/values/storage-longhorn.yaml b/devops/deployments/required-base-applications/values/storage-longhorn.yaml similarity index 100% rename from devops/deployments/helm-infrastructure/values/storage-longhorn.yaml rename to devops/deployments/required-base-applications/values/storage-longhorn.yaml diff --git a/devops/deployments/server-infrastructure/civo-k3s/main.tf b/devops/deployments/server-infrastructure/civo-k3s/main.tf index c5d88966..ad1cd1fd 100644 --- a/devops/deployments/server-infrastructure/civo-k3s/main.tf +++ b/devops/deployments/server-infrastructure/civo-k3s/main.tf @@ -1,6 +1,27 @@ variable "civo_kubernetes_size" {} variable "civo_kubernetes_count" {} +# # Create Object Storage Credetials for Bucket to store backups +# data "civo_object_store_credential" "backup" { +# name = "application-backup-bucket-credentials" +# } + +# # Create Object Storage for Bucket to store backups +# resource "civo_object_store" "backup" { +# name = "application-backup-bucket" +# max_size_gb = 500 +# access_key_id = civo_object_store_credential.backup.access_key_id +# } + +# # Create a managaed Database +# resource "civo_database" "custom_database" { +# name = "custom_database" +# size = element(data.civo_size.small.sizes, 0).name +# nodes = 2 +# engine = element(data.civo_database_version.mysql.versions, 0).engine +# version = element(data.civo_database_version.mysql.versions, 0).version +# } + # Create a firewall resource "civo_firewall" "my-firewall" { name = "application-firewall" From dc8534ff31123fa12c346e03fe2a0a98a1e98978 Mon Sep 17 00:00:00 2001 From: Tim Riedl Date: Mon, 1 Apr 2024 16:38:38 +0200 Subject: [PATCH 06/31] add iac pipelines --- .../infrastructure-as-code-create.yaml | 34 ++++++++++++++++ .../infrastructure-as-code-destroy.yaml | 34 ++++++++++++++++ .github/workflows/release.yml | 40 ------------------- devops/deployments/.ci-pipeline/.gitignore | 3 +- .../helmfile.yaml | 19 +++++++++ devops/deployments/base-applications/makefile | 2 + .../values/authentik-identity-provider.yaml | 0 .../values/ingress-nginx.yaml | 0 .../values/storage-longhorn.yaml | 0 devops/deployments/makefile | 14 +++++++ .../server-infrastructure/civo-k3s/makefile | 10 +++-- 11 files changed, 111 insertions(+), 45 deletions(-) create mode 100644 .github/workflows/infrastructure-as-code-create.yaml create mode 100644 .github/workflows/infrastructure-as-code-destroy.yaml delete mode 100644 .github/workflows/release.yml rename devops/deployments/{required-base-applications => base-applications}/helmfile.yaml (61%) create mode 100644 devops/deployments/base-applications/makefile rename devops/deployments/{required-base-applications => base-applications}/values/authentik-identity-provider.yaml (100%) rename devops/deployments/{required-base-applications => base-applications}/values/ingress-nginx.yaml (100%) rename devops/deployments/{required-base-applications => base-applications}/values/storage-longhorn.yaml (100%) create mode 100644 devops/deployments/makefile diff --git a/.github/workflows/infrastructure-as-code-create.yaml b/.github/workflows/infrastructure-as-code-create.yaml new file mode 100644 index 00000000..a0a6718b --- /dev/null +++ b/.github/workflows/infrastructure-as-code-create.yaml @@ -0,0 +1,34 @@ +name: iac-create + +on: + workflow_dispatch: + inputs: + cloud_provider: + description: "Wähle einen Cloud Provider aus:" + type: choice + required: true + default: "civo" + options: + - civo + - hetzner + - azure + +jobs: + deploy-infrastructure: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: install terraform + uses: hashicorp/setup-terraform@v3 + + - name: deploy terraform + run: (cd ./devops/deployments ; make infrastructure-${{ inputs.cloud_provider }}) + + - name: store kubeconfig as secret + run: gh secret set KUBECONFIG_${{ inputs.cloud_provider }} --body devops/deployments/.ci-pipeline/k8s.${{ inputs.cloud_provider }}.config --repo ${{ github.repository }} + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/infrastructure-as-code-destroy.yaml b/.github/workflows/infrastructure-as-code-destroy.yaml new file mode 100644 index 00000000..0a1bc048 --- /dev/null +++ b/.github/workflows/infrastructure-as-code-destroy.yaml @@ -0,0 +1,34 @@ +name: iac-destroy + +on: + workflow_dispatch: + inputs: + cloud_provider: + description: "Wähle einen Cloud Provider aus:" + type: choice + required: true + default: "civo" + options: + - civo + - hetzner + - azure + +jobs: + deploy-infrastructure: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: install terraform + uses: hashicorp/setup-terraform@v3 + + - name: deploy terraform + run: (cd ./devops/deployments ; make destroy-infrastructure-${{ inputs.cloud_provider }}) + + - name: store kubeconfig as secret + run: gh secret delete KUBECONFIG_${{ inputs.cloud_provider }} --repo ${{ github.repository }} + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index f264e401..00000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: goreleaser - -on: - push: - tags: - - "*" - -permissions: - contents: write - -jobs: - backendTests: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - run: git fetch --force --tags - - uses: actions/setup-go@v5 - with: - go-version: stable - - goreleaser: - needs: backendTests - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - run: git fetch --force --tags - - uses: actions/setup-go@v5 - with: - go-version: stable - - uses: goreleaser/goreleaser-action@v5 - with: - distribution: goreleaser - version: latest - args: release --clean - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/devops/deployments/.ci-pipeline/.gitignore b/devops/deployments/.ci-pipeline/.gitignore index 30fa1cea..4d3eda31 100644 --- a/devops/deployments/.ci-pipeline/.gitignore +++ b/devops/deployments/.ci-pipeline/.gitignore @@ -1 +1,2 @@ -config \ No newline at end of file +config +k8s.civo.config \ No newline at end of file diff --git a/devops/deployments/required-base-applications/helmfile.yaml b/devops/deployments/base-applications/helmfile.yaml similarity index 61% rename from devops/deployments/required-base-applications/helmfile.yaml rename to devops/deployments/base-applications/helmfile.yaml index aed29b0b..d4d5da27 100644 --- a/devops/deployments/required-base-applications/helmfile.yaml +++ b/devops/deployments/base-applications/helmfile.yaml @@ -5,6 +5,8 @@ repositories: url: https://charts.goauthentik.io/ - name: longhorn url: https://charts.longhorn.io + - name: bitnami + url: https://charts.bitnami.com/bitnami releases: - name: ingress @@ -22,6 +24,22 @@ releases: values: - "./values/storage-longhorn.yaml" + - name: postgres + chart: bitnami/postgresql + namespace: postgres + createNamespace: true + needs: + - longhorn/longhorn + set: + - name: global.storageClass + value: longhorn + - name: global.postgresql.auth.postgresPassword + value: adminpw + - name: global.postgresql.auth.username + value: user + - name: global.postgresql.auth.password + value: userpassword + # - name: authentik # chart: goauthentik/authentik # version: 2024.2.2 @@ -30,6 +48,7 @@ releases: # needs: # - ingress # - longhorn + # - postgres # values: # - "./values/authentik-identity-provider.yaml" \ No newline at end of file diff --git a/devops/deployments/base-applications/makefile b/devops/deployments/base-applications/makefile new file mode 100644 index 00000000..3d0aafa9 --- /dev/null +++ b/devops/deployments/base-applications/makefile @@ -0,0 +1,2 @@ +run: + helmfile sync --kube-context my-cluster --kubeconfig ../.ci-pipeline/k8s.civo.config \ No newline at end of file diff --git a/devops/deployments/required-base-applications/values/authentik-identity-provider.yaml b/devops/deployments/base-applications/values/authentik-identity-provider.yaml similarity index 100% rename from devops/deployments/required-base-applications/values/authentik-identity-provider.yaml rename to devops/deployments/base-applications/values/authentik-identity-provider.yaml diff --git a/devops/deployments/required-base-applications/values/ingress-nginx.yaml b/devops/deployments/base-applications/values/ingress-nginx.yaml similarity index 100% rename from devops/deployments/required-base-applications/values/ingress-nginx.yaml rename to devops/deployments/base-applications/values/ingress-nginx.yaml diff --git a/devops/deployments/required-base-applications/values/storage-longhorn.yaml b/devops/deployments/base-applications/values/storage-longhorn.yaml similarity index 100% rename from devops/deployments/required-base-applications/values/storage-longhorn.yaml rename to devops/deployments/base-applications/values/storage-longhorn.yaml diff --git a/devops/deployments/makefile b/devops/deployments/makefile new file mode 100644 index 00000000..956acb45 --- /dev/null +++ b/devops/deployments/makefile @@ -0,0 +1,14 @@ +.PHONY: base-applications + +base-applications: + @(cd ./base-applications/ ; make run) + +infrastructure-civo: + @(cd server-infrastructure/civo-k3s/ ; make apply) + $(MAKE) base-applications + +destroy-infrastructure-civo: + @(cd server-infrastructure/civo-k3s/ ; make destroy) + +# infrastructure-hetzner: +# infrastructure-azure: diff --git a/devops/deployments/server-infrastructure/civo-k3s/makefile b/devops/deployments/server-infrastructure/civo-k3s/makefile index e1fb1cd2..d149ed4f 100644 --- a/devops/deployments/server-infrastructure/civo-k3s/makefile +++ b/devops/deployments/server-infrastructure/civo-k3s/makefile @@ -1,6 +1,8 @@ -run: - @terraform apply - @terraform output -raw k8skubeconfig > ../../.ci-pipeline/config +apply: + @terraform init + @terraform apply -auto-approve + @terraform output -raw k8skubeconfig > ../../.ci-pipeline/k8s.civo.config + @chmod 600 ../../.ci-pipeline/k8s.civo.config destroy: - @terraform destroy \ No newline at end of file + @terraform destroy -auto-approve \ No newline at end of file From 074fa92828d2e0d17bf0f7e25af52b4d0db7cb01 Mon Sep 17 00:00:00 2001 From: Tim Riedl Date: Mon, 1 Apr 2024 17:43:59 +0200 Subject: [PATCH 07/31] fix issues --- .github/workflows/infrastructure-as-code-create.yaml | 12 ++++++++++++ .gitignore | 5 ++++- devops/deployments/makefile | 7 ++++--- .../{azure-aks => azure}/.gitkeep | 0 .../civo-k3s/terraform.tfvars.copy.txt | 7 ------- .../{civo-k3s => civo}/.terraform.lock.hcl | 0 .../server-infrastructure/{civo-k3s => civo}/main.tf | 0 .../{civo-k3s => civo}/makefile | 0 .../{civo-k3s => civo}/packages.tf | 0 .../civo/terraform.tfvars.copy.txt | 7 +++++++ .../{hetzner-microk8s => hetzner}/.gitkeep | 0 11 files changed, 27 insertions(+), 11 deletions(-) rename devops/deployments/server-infrastructure/{azure-aks => azure}/.gitkeep (100%) delete mode 100644 devops/deployments/server-infrastructure/civo-k3s/terraform.tfvars.copy.txt rename devops/deployments/server-infrastructure/{civo-k3s => civo}/.terraform.lock.hcl (100%) rename devops/deployments/server-infrastructure/{civo-k3s => civo}/main.tf (100%) rename devops/deployments/server-infrastructure/{civo-k3s => civo}/makefile (100%) rename devops/deployments/server-infrastructure/{civo-k3s => civo}/packages.tf (100%) create mode 100644 devops/deployments/server-infrastructure/civo/terraform.tfvars.copy.txt rename devops/deployments/server-infrastructure/{hetzner-microk8s => hetzner}/.gitkeep (100%) diff --git a/.github/workflows/infrastructure-as-code-create.yaml b/.github/workflows/infrastructure-as-code-create.yaml index a0a6718b..e74e7fbe 100644 --- a/.github/workflows/infrastructure-as-code-create.yaml +++ b/.github/workflows/infrastructure-as-code-create.yaml @@ -25,8 +25,20 @@ jobs: - name: install terraform uses: hashicorp/setup-terraform@v3 + - name: copy default terraform config + run: cp devops/deployments/server-infrastructure/${{ inputs.cloud_provider }}/terraform.tfvars.copy.txt devops/deployments/server-infrastructure/${{ inputs.cloud_provider }}/terraform.tfvars + - name: deploy terraform run: (cd ./devops/deployments ; make infrastructure-${{ inputs.cloud_provider }}) + env: + TF_VAR_civo_token: ${{ secrets.civo_token }} + + - name: install base applications + uses: helmfile/helmfile-action@v1.8.0 + with: + helmfile-args: sync --kube-context my-cluster --kubeconfig ../.ci-pipeline/k8s.civo.config + helmfile-auto-init: "true" + helmfile-workdirectory: "devops/deployments/base-applications/" - name: store kubeconfig as secret run: gh secret set KUBECONFIG_${{ inputs.cloud_provider }} --body devops/deployments/.ci-pipeline/k8s.${{ inputs.cloud_provider }}.config --repo ${{ github.repository }} diff --git a/.gitignore b/.gitignore index fdccfd97..e0e823ff 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,7 @@ services/frontend/node_modules services/backend/src/assets/frontend .DS_Store -*.tgz \ No newline at end of file +*.tgz + +.input +.secrets \ No newline at end of file diff --git a/devops/deployments/makefile b/devops/deployments/makefile index 956acb45..18e3b4c3 100644 --- a/devops/deployments/makefile +++ b/devops/deployments/makefile @@ -4,11 +4,12 @@ base-applications: @(cd ./base-applications/ ; make run) infrastructure-civo: - @(cd server-infrastructure/civo-k3s/ ; make apply) - $(MAKE) base-applications + @(cd server-infrastructure/civo/ ; make apply) + +# $(MAKE) base-applications destroy-infrastructure-civo: - @(cd server-infrastructure/civo-k3s/ ; make destroy) + @(cd server-infrastructure/civo/ ; make destroy) # infrastructure-hetzner: # infrastructure-azure: diff --git a/devops/deployments/server-infrastructure/azure-aks/.gitkeep b/devops/deployments/server-infrastructure/azure/.gitkeep similarity index 100% rename from devops/deployments/server-infrastructure/azure-aks/.gitkeep rename to devops/deployments/server-infrastructure/azure/.gitkeep diff --git a/devops/deployments/server-infrastructure/civo-k3s/terraform.tfvars.copy.txt b/devops/deployments/server-infrastructure/civo-k3s/terraform.tfvars.copy.txt deleted file mode 100644 index 932a7dc7..00000000 --- a/devops/deployments/server-infrastructure/civo-k3s/terraform.tfvars.copy.txt +++ /dev/null @@ -1,7 +0,0 @@ -# civo settings -civo_token = "" -civo_region = "FRA1" - -# civo cluster -civo_kubernetes_size = "g4s.kube.medium" -civo_kubernetes_count = 3 diff --git a/devops/deployments/server-infrastructure/civo-k3s/.terraform.lock.hcl b/devops/deployments/server-infrastructure/civo/.terraform.lock.hcl similarity index 100% rename from devops/deployments/server-infrastructure/civo-k3s/.terraform.lock.hcl rename to devops/deployments/server-infrastructure/civo/.terraform.lock.hcl diff --git a/devops/deployments/server-infrastructure/civo-k3s/main.tf b/devops/deployments/server-infrastructure/civo/main.tf similarity index 100% rename from devops/deployments/server-infrastructure/civo-k3s/main.tf rename to devops/deployments/server-infrastructure/civo/main.tf diff --git a/devops/deployments/server-infrastructure/civo-k3s/makefile b/devops/deployments/server-infrastructure/civo/makefile similarity index 100% rename from devops/deployments/server-infrastructure/civo-k3s/makefile rename to devops/deployments/server-infrastructure/civo/makefile diff --git a/devops/deployments/server-infrastructure/civo-k3s/packages.tf b/devops/deployments/server-infrastructure/civo/packages.tf similarity index 100% rename from devops/deployments/server-infrastructure/civo-k3s/packages.tf rename to devops/deployments/server-infrastructure/civo/packages.tf diff --git a/devops/deployments/server-infrastructure/civo/terraform.tfvars.copy.txt b/devops/deployments/server-infrastructure/civo/terraform.tfvars.copy.txt new file mode 100644 index 00000000..fecb8b22 --- /dev/null +++ b/devops/deployments/server-infrastructure/civo/terraform.tfvars.copy.txt @@ -0,0 +1,7 @@ +# civo settings +# civo_token = "" +civo_region = "FRA1" + +# civo cluster +civo_kubernetes_size = "g4s.kube.small" +civo_kubernetes_count = 2 diff --git a/devops/deployments/server-infrastructure/hetzner-microk8s/.gitkeep b/devops/deployments/server-infrastructure/hetzner/.gitkeep similarity index 100% rename from devops/deployments/server-infrastructure/hetzner-microk8s/.gitkeep rename to devops/deployments/server-infrastructure/hetzner/.gitkeep From ac7a2ad3d2eabef4e516625f30098e93dbfe3b7f Mon Sep 17 00:00:00 2001 From: Tim Riedl Date: Mon, 1 Apr 2024 17:45:27 +0200 Subject: [PATCH 08/31] rename files --- .../{infrastructure-as-code-create.yaml => iac-create.yaml} | 0 .../{infrastructure-as-code-destroy.yaml => iac-destroy.yaml} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{infrastructure-as-code-create.yaml => iac-create.yaml} (100%) rename .github/workflows/{infrastructure-as-code-destroy.yaml => iac-destroy.yaml} (100%) diff --git a/.github/workflows/infrastructure-as-code-create.yaml b/.github/workflows/iac-create.yaml similarity index 100% rename from .github/workflows/infrastructure-as-code-create.yaml rename to .github/workflows/iac-create.yaml diff --git a/.github/workflows/infrastructure-as-code-destroy.yaml b/.github/workflows/iac-destroy.yaml similarity index 100% rename from .github/workflows/infrastructure-as-code-destroy.yaml rename to .github/workflows/iac-destroy.yaml From 2a6696ff9e814539f2778b5a41d417934bde4ef5 Mon Sep 17 00:00:00 2001 From: Tim Riedl Date: Mon, 1 Apr 2024 18:17:33 +0200 Subject: [PATCH 09/31] fix --- .github/workflows/iac-destroy.yaml | 2 +- Makefile | 3 +++ devops/deployments/server-infrastructure/civo/makefile | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/iac-destroy.yaml b/.github/workflows/iac-destroy.yaml index 0a1bc048..fa63e166 100644 --- a/.github/workflows/iac-destroy.yaml +++ b/.github/workflows/iac-destroy.yaml @@ -28,7 +28,7 @@ jobs: - name: deploy terraform run: (cd ./devops/deployments ; make destroy-infrastructure-${{ inputs.cloud_provider }}) - - name: store kubeconfig as secret + - name: delete kubeconfig secret run: gh secret delete KUBECONFIG_${{ inputs.cloud_provider }} --repo ${{ github.repository }} env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/Makefile b/Makefile index de8db193..91992922 100644 --- a/Makefile +++ b/Makefile @@ -26,6 +26,9 @@ build-dockerfile-frontend: ## build the frontend microservice build-dockerfile-backend: ## build the backend microservice @bash ./devops/scripts/build-container/backend.sh +act-create: + @act -W .github/workflows/infrastructure-as-code-create.yaml --container-architecture linux/amd64 --secret-file .secrets --input-file .input + help: ## print our all commands to commandline @echo "\033[34m" @echo " SvelteKit + Golang Example" diff --git a/devops/deployments/server-infrastructure/civo/makefile b/devops/deployments/server-infrastructure/civo/makefile index d149ed4f..21636e7f 100644 --- a/devops/deployments/server-infrastructure/civo/makefile +++ b/devops/deployments/server-infrastructure/civo/makefile @@ -5,4 +5,5 @@ apply: @chmod 600 ../../.ci-pipeline/k8s.civo.config destroy: + @terraform init @terraform destroy -auto-approve \ No newline at end of file From 44ca7a8f24e4bcd0009109782b01c91acf0b0d43 Mon Sep 17 00:00:00 2001 From: Tim Riedl Date: Mon, 1 Apr 2024 18:19:30 +0200 Subject: [PATCH 10/31] fix --- .github/workflows/iac-destroy.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/iac-destroy.yaml b/.github/workflows/iac-destroy.yaml index fa63e166..3560accd 100644 --- a/.github/workflows/iac-destroy.yaml +++ b/.github/workflows/iac-destroy.yaml @@ -27,6 +27,8 @@ jobs: - name: deploy terraform run: (cd ./devops/deployments ; make destroy-infrastructure-${{ inputs.cloud_provider }}) + env: + TF_VAR_civo_token: ${{ secrets.civo_token }} - name: delete kubeconfig secret run: gh secret delete KUBECONFIG_${{ inputs.cloud_provider }} --repo ${{ github.repository }} From 8ab386837d53be6a4a10c278ad13ba33c6c548b7 Mon Sep 17 00:00:00 2001 From: Tim Riedl Date: Mon, 1 Apr 2024 22:49:23 +0200 Subject: [PATCH 11/31] fix token permissions --- .github/workflows/iac-create.yaml | 2 +- .github/workflows/iac-destroy.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/iac-create.yaml b/.github/workflows/iac-create.yaml index e74e7fbe..af65fa99 100644 --- a/.github/workflows/iac-create.yaml +++ b/.github/workflows/iac-create.yaml @@ -43,4 +43,4 @@ jobs: - name: store kubeconfig as secret run: gh secret set KUBECONFIG_${{ inputs.cloud_provider }} --body devops/deployments/.ci-pipeline/k8s.${{ inputs.cloud_provider }}.config --repo ${{ github.repository }} env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_TOKEN: ${{ secrets.GH_TOKEN }} diff --git a/.github/workflows/iac-destroy.yaml b/.github/workflows/iac-destroy.yaml index 3560accd..cdcb6b81 100644 --- a/.github/workflows/iac-destroy.yaml +++ b/.github/workflows/iac-destroy.yaml @@ -33,4 +33,4 @@ jobs: - name: delete kubeconfig secret run: gh secret delete KUBECONFIG_${{ inputs.cloud_provider }} --repo ${{ github.repository }} env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_TOKEN: ${{ secrets.GH_TOKEN }} From 68005a7aec752bfce429ebd96130b7b309d3db49 Mon Sep 17 00:00:00 2001 From: Tim Riedl Date: Tue, 16 Apr 2024 18:36:36 +0200 Subject: [PATCH 12/31] wip add terraform backend --- .../base-applications/helmfile.yaml | 6 ++++++ .../server-infrastructure/civo/.gitignore | 1 + .../server-infrastructure/civo/makefile | 10 ++++++++-- .../server-infrastructure/civo/packages.tf | 20 +++++++++++++++++-- .../civo/terraform.tfvars.copy.txt | 7 +++++++ 5 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 devops/deployments/server-infrastructure/civo/.gitignore diff --git a/devops/deployments/base-applications/helmfile.yaml b/devops/deployments/base-applications/helmfile.yaml index d4d5da27..fba56d7f 100644 --- a/devops/deployments/base-applications/helmfile.yaml +++ b/devops/deployments/base-applications/helmfile.yaml @@ -1,3 +1,9 @@ +environments: + civo-k3s: + + hetzner-microk8s: {} + azure-aks: {} + repositories: - name: ingress-nginx url: https://kubernetes.github.io/ingress-nginx diff --git a/devops/deployments/server-infrastructure/civo/.gitignore b/devops/deployments/server-infrastructure/civo/.gitignore new file mode 100644 index 00000000..2eea525d --- /dev/null +++ b/devops/deployments/server-infrastructure/civo/.gitignore @@ -0,0 +1 @@ +.env \ No newline at end of file diff --git a/devops/deployments/server-infrastructure/civo/makefile b/devops/deployments/server-infrastructure/civo/makefile index 21636e7f..7866a1a1 100644 --- a/devops/deployments/server-infrastructure/civo/makefile +++ b/devops/deployments/server-infrastructure/civo/makefile @@ -1,9 +1,15 @@ apply: - @terraform init + terraform init \ + -backend-config='bucket=iac-storage' \ + -backend-config='key=terraform.tfstate' \ + -backend-config='access_key=' \ + -backend-config='secret_key=' @terraform apply -auto-approve @terraform output -raw k8skubeconfig > ../../.ci-pipeline/k8s.civo.config @chmod 600 ../../.ci-pipeline/k8s.civo.config destroy: @terraform init - @terraform destroy -auto-approve \ No newline at end of file + @terraform destroy -auto-approve + + diff --git a/devops/deployments/server-infrastructure/civo/packages.tf b/devops/deployments/server-infrastructure/civo/packages.tf index 41deb664..59337a07 100644 --- a/devops/deployments/server-infrastructure/civo/packages.tf +++ b/devops/deployments/server-infrastructure/civo/packages.tf @@ -1,7 +1,23 @@ -variable "civo_token" {} -variable "civo_region" {} +variable "civo_token" { type = string } +variable "civo_region" { type = string } terraform { + backend "s3" { + endpoints { + s3 = "https://objectstore.fra1.civo.com/" + } + bucket = "" + key = "" + region = "FRA1" + skip_region_validation = true + skip_credentials_validation = true + skip_requesting_account_id = true + skip_metadata_api_check = true + use_path_style = true + # access_key = var.tfbackend_objectstorage_accesskey + # secret_key = var.tfbackend_objectstorage_secretkey + } + required_providers { civo = { source = "civo/civo" diff --git a/devops/deployments/server-infrastructure/civo/terraform.tfvars.copy.txt b/devops/deployments/server-infrastructure/civo/terraform.tfvars.copy.txt index fecb8b22..fe86f064 100644 --- a/devops/deployments/server-infrastructure/civo/terraform.tfvars.copy.txt +++ b/devops/deployments/server-infrastructure/civo/terraform.tfvars.copy.txt @@ -1,3 +1,10 @@ +# terraform backend +tfbackend_objectstorage_bucketurl = "" +tfbackend_objectstorage_bucketkey = "terraform.tfstate" +tfbackend_objectstorage_bucketname = "iac-storage" +tfbackend_objectstorage_accesskey = "" +tfbackend_objectstorage_secretkey = "" + # civo settings # civo_token = "" civo_region = "FRA1" From 7442e8da0e8e0d33ea8c9af629488cdea5589ee1 Mon Sep 17 00:00:00 2001 From: Tim Riedl Date: Fri, 19 Apr 2024 20:52:46 +0200 Subject: [PATCH 13/31] feat: add ci pipeline --- .github/workflows/execute-tests.yaml | 60 ++++++++++++++++++++++++++++ .github/workflows/iac-create.yaml | 46 --------------------- .github/workflows/iac-destroy.yaml | 36 ----------------- Makefile | 6 +++ 4 files changed, 66 insertions(+), 82 deletions(-) create mode 100644 .github/workflows/execute-tests.yaml delete mode 100644 .github/workflows/iac-create.yaml delete mode 100644 .github/workflows/iac-destroy.yaml diff --git a/.github/workflows/execute-tests.yaml b/.github/workflows/execute-tests.yaml new file mode 100644 index 00000000..5fb962ad --- /dev/null +++ b/.github/workflows/execute-tests.yaml @@ -0,0 +1,60 @@ +name: "CI: Test Software" + +on: + push: + pull_request: + +jobs: + test-backend: + runs-on: ubuntu-latest + continue-on-error: true + + services: + postgres: + image: postgis/postgis + env: + POSTGRES_PASSWORD: postgres + ports: + - "5432:5432" + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: run backend tests + if: ${{ always() }} + run: make test-be-ci + + test-frontend: + runs-on: ubuntu-latest + continue-on-error: true + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: run frontend tests + if: ${{ always() }} + run: make test-fe-ci + + test-result: + runs-on: ubuntu-latest + needs: [test-backend, test-frontend] + if: ${{ always() }} + + steps: + - name: Check if any tests failed + run: | + if [ "${{ needs.test-backend.result }}" == "failure" ] || [ "${{ needs.test-frontend.result }}" == "failure" ]; then + echo "One or more tests failed." + exit 1 + else + echo "All tests passed." + fi diff --git a/.github/workflows/iac-create.yaml b/.github/workflows/iac-create.yaml deleted file mode 100644 index af65fa99..00000000 --- a/.github/workflows/iac-create.yaml +++ /dev/null @@ -1,46 +0,0 @@ -name: iac-create - -on: - workflow_dispatch: - inputs: - cloud_provider: - description: "Wähle einen Cloud Provider aus:" - type: choice - required: true - default: "civo" - options: - - civo - - hetzner - - azure - -jobs: - deploy-infrastructure: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: install terraform - uses: hashicorp/setup-terraform@v3 - - - name: copy default terraform config - run: cp devops/deployments/server-infrastructure/${{ inputs.cloud_provider }}/terraform.tfvars.copy.txt devops/deployments/server-infrastructure/${{ inputs.cloud_provider }}/terraform.tfvars - - - name: deploy terraform - run: (cd ./devops/deployments ; make infrastructure-${{ inputs.cloud_provider }}) - env: - TF_VAR_civo_token: ${{ secrets.civo_token }} - - - name: install base applications - uses: helmfile/helmfile-action@v1.8.0 - with: - helmfile-args: sync --kube-context my-cluster --kubeconfig ../.ci-pipeline/k8s.civo.config - helmfile-auto-init: "true" - helmfile-workdirectory: "devops/deployments/base-applications/" - - - name: store kubeconfig as secret - run: gh secret set KUBECONFIG_${{ inputs.cloud_provider }} --body devops/deployments/.ci-pipeline/k8s.${{ inputs.cloud_provider }}.config --repo ${{ github.repository }} - env: - GH_TOKEN: ${{ secrets.GH_TOKEN }} diff --git a/.github/workflows/iac-destroy.yaml b/.github/workflows/iac-destroy.yaml deleted file mode 100644 index cdcb6b81..00000000 --- a/.github/workflows/iac-destroy.yaml +++ /dev/null @@ -1,36 +0,0 @@ -name: iac-destroy - -on: - workflow_dispatch: - inputs: - cloud_provider: - description: "Wähle einen Cloud Provider aus:" - type: choice - required: true - default: "civo" - options: - - civo - - hetzner - - azure - -jobs: - deploy-infrastructure: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: install terraform - uses: hashicorp/setup-terraform@v3 - - - name: deploy terraform - run: (cd ./devops/deployments ; make destroy-infrastructure-${{ inputs.cloud_provider }}) - env: - TF_VAR_civo_token: ${{ secrets.civo_token }} - - - name: delete kubeconfig secret - run: gh secret delete KUBECONFIG_${{ inputs.cloud_provider }} --repo ${{ github.repository }} - env: - GH_TOKEN: ${{ secrets.GH_TOKEN }} diff --git a/Makefile b/Makefile index 91992922..970ae2f1 100644 --- a/Makefile +++ b/Makefile @@ -17,6 +17,12 @@ test-be: ## run golang tests test-fe: ## run sveltekit tests @docker compose -f compose-dev.yaml up fontend-tests +test-be-ci: ## run golang tests in ci pipeline + @docker compose -f compose-dev.yaml up backend-tests + +test-fe-ci: ## run sveltekit tests in ci pipeline + @docker compose -f compose-dev.yaml up fontend-tests + build-dockerfile-binary: ## build one dockerimage that contains everything @bash ./devops/scripts/build-container/binary.sh From 416edaed1def34bab48bcb4a844f9b75a421f9eb Mon Sep 17 00:00:00 2001 From: Tim Riedl Date: Fri, 19 Apr 2024 20:58:04 +0200 Subject: [PATCH 14/31] fix: add postgres test db credentials --- .github/workflows/execute-tests.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/execute-tests.yaml b/.github/workflows/execute-tests.yaml index 5fb962ad..19753f78 100644 --- a/.github/workflows/execute-tests.yaml +++ b/.github/workflows/execute-tests.yaml @@ -2,7 +2,6 @@ name: "CI: Test Software" on: push: - pull_request: jobs: test-backend: @@ -13,7 +12,10 @@ jobs: postgres: image: postgis/postgis env: + POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres + POSTGRES_DB: postgres + PGDATA: /var/lib/postgresql/data/pgdata ports: - "5432:5432" options: >- From 64e4c8e2d30f049993cbb7f612107ec9f87ea44f Mon Sep 17 00:00:00 2001 From: Tim Riedl Date: Fri, 19 Apr 2024 21:03:00 +0200 Subject: [PATCH 15/31] fix: add pg_isready with 20s timeout --- .github/workflows/execute-tests.yaml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/execute-tests.yaml b/.github/workflows/execute-tests.yaml index 19753f78..b71281fe 100644 --- a/.github/workflows/execute-tests.yaml +++ b/.github/workflows/execute-tests.yaml @@ -29,6 +29,18 @@ jobs: with: fetch-depth: 0 + - name: Wait for Postgres to become available (max 20 seconds) + run: | + timeout 20 bash -c 'until pg_isready -h localhost -p 5432 -U postgres; do + echo "Waiting for PostgreSQL to become available..." + sleep 2 + done' + if ! pg_isready -h localhost -p 5432 -U postgres; then + echo "PostgreSQL is not available after 20 seconds." + exit 1 + fi + echo "PostgreSQL is available now." + - name: run backend tests if: ${{ always() }} run: make test-be-ci From c4be2fc67df9881a7d367988574dea875c9db648 Mon Sep 17 00:00:00 2001 From: Tim Riedl Date: Fri, 19 Apr 2024 21:04:13 +0200 Subject: [PATCH 16/31] fix: formatting --- .github/workflows/execute-tests.yaml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/execute-tests.yaml b/.github/workflows/execute-tests.yaml index b71281fe..8c3e2469 100644 --- a/.github/workflows/execute-tests.yaml +++ b/.github/workflows/execute-tests.yaml @@ -29,17 +29,17 @@ jobs: with: fetch-depth: 0 - - name: Wait for Postgres to become available (max 20 seconds) - run: | - timeout 20 bash -c 'until pg_isready -h localhost -p 5432 -U postgres; do - echo "Waiting for PostgreSQL to become available..." - sleep 2 - done' - if ! pg_isready -h localhost -p 5432 -U postgres; then - echo "PostgreSQL is not available after 20 seconds." - exit 1 - fi - echo "PostgreSQL is available now." + - name: Wait for Postgres to become available (max 20 seconds) + run: | + timeout 20 bash -c 'until pg_isready -h localhost -p 5432 -U postgres; do + echo "Waiting for PostgreSQL to become available..." + sleep 2 + done' + if ! pg_isready -h localhost -p 5432 -U postgres; then + echo "PostgreSQL is not available after 20 seconds." + exit 1 + fi + echo "PostgreSQL is available now." - name: run backend tests if: ${{ always() }} From e9be1a2ae1405fef1066c76b09b61cc2e47bae3a Mon Sep 17 00:00:00 2001 From: Tim Riedl Date: Fri, 19 Apr 2024 21:06:56 +0200 Subject: [PATCH 17/31] fix: remove pgready dependency in docker compose --- compose-dev.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/compose-dev.yaml b/compose-dev.yaml index ec7e380f..3a82f43e 100644 --- a/compose-dev.yaml +++ b/compose-dev.yaml @@ -115,6 +115,16 @@ services: - TERM=xterm-256color` command: ["sh", "-c", "cd /app && bash scripts/test-local-docker.sh"] + backend-tests-ci: + image: golang:latest + container_name: web-api-test + volumes: + - ./services/backend:/app + tty: true + environment: + - TERM=xterm-256color` + command: ["sh", "-c", "cd /app && bash scripts/test-local-docker.sh"] + # ----------------------------------------------------------------------------------------------------- # # DATABASE From 19789f8bccf36ad179839289a94a258c25195430 Mon Sep 17 00:00:00 2001 From: Tim Riedl Date: Fri, 19 Apr 2024 21:08:41 +0200 Subject: [PATCH 18/31] fix: name targeted docker compose service right --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 970ae2f1..11589117 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ test-fe: ## run sveltekit tests @docker compose -f compose-dev.yaml up fontend-tests test-be-ci: ## run golang tests in ci pipeline - @docker compose -f compose-dev.yaml up backend-tests + @docker compose -f compose-dev.yaml up backend-tests-ci test-fe-ci: ## run sveltekit tests in ci pipeline @docker compose -f compose-dev.yaml up fontend-tests From 3f1d2d4b9d8dfea25c76048449f7d7c90e11a817 Mon Sep 17 00:00:00 2001 From: Tim Riedl Date: Fri, 19 Apr 2024 21:13:33 +0200 Subject: [PATCH 19/31] fix: add to ci --abort-on-container-exit flag --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 11589117..58c3e163 100644 --- a/Makefile +++ b/Makefile @@ -18,10 +18,10 @@ test-fe: ## run sveltekit tests @docker compose -f compose-dev.yaml up fontend-tests test-be-ci: ## run golang tests in ci pipeline - @docker compose -f compose-dev.yaml up backend-tests-ci + @docker compose -f compose-dev.yaml up --abort-on-container-exit backend-tests-ci test-fe-ci: ## run sveltekit tests in ci pipeline - @docker compose -f compose-dev.yaml up fontend-tests + @docker compose -f compose-dev.yaml up --abort-on-container-exit fontend-tests build-dockerfile-binary: ## build one dockerimage that contains everything @bash ./devops/scripts/build-container/binary.sh From b8911c414e71be3e85decdfb0d680e3d5a5bccf6 Mon Sep 17 00:00:00 2001 From: Tim Riedl Date: Fri, 19 Apr 2024 21:26:03 +0200 Subject: [PATCH 20/31] fix: ci errors --- Makefile | 1 + services/backend/scripts/test-local-docker.sh | 1 + 2 files changed, 2 insertions(+) diff --git a/Makefile b/Makefile index 58c3e163..264760a6 100644 --- a/Makefile +++ b/Makefile @@ -18,6 +18,7 @@ test-fe: ## run sveltekit tests @docker compose -f compose-dev.yaml up fontend-tests test-be-ci: ## run golang tests in ci pipeline + @echo "Hello World" > ./service/backend/src/assets/frontend/test.txt @docker compose -f compose-dev.yaml up --abort-on-container-exit backend-tests-ci test-fe-ci: ## run sveltekit tests in ci pipeline diff --git a/services/backend/scripts/test-local-docker.sh b/services/backend/scripts/test-local-docker.sh index 154bbd6f..42731072 100644 --- a/services/backend/scripts/test-local-docker.sh +++ b/services/backend/scripts/test-local-docker.sh @@ -1,4 +1,5 @@ go mod download +go get github.com/uvulpos/go-svelte/swagger-docs go install golang.org/x/tools/cmd/goimports go install gotest.tools/gotestsum@latest go run src/main.go migrate-db From e957d6b3e55c8884572c5561aeeb2fdd94308bb8 Mon Sep 17 00:00:00 2001 From: Tim Riedl Date: Fri, 19 Apr 2024 21:27:53 +0200 Subject: [PATCH 21/31] fix: create folder first before file --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 264760a6..c038fb13 100644 --- a/Makefile +++ b/Makefile @@ -18,6 +18,7 @@ test-fe: ## run sveltekit tests @docker compose -f compose-dev.yaml up fontend-tests test-be-ci: ## run golang tests in ci pipeline + @mkdir -p ./service/backend/src/assets/frontend @echo "Hello World" > ./service/backend/src/assets/frontend/test.txt @docker compose -f compose-dev.yaml up --abort-on-container-exit backend-tests-ci From d603cc5e9310242c85255af4b9f6e5236d909706 Mon Sep 17 00:00:00 2001 From: Tim Riedl Date: Fri, 19 Apr 2024 22:08:12 +0200 Subject: [PATCH 22/31] fix: add create swagger documentation in testing environment to prevent errors in ci --- Makefile | 4 ++-- services/backend/scripts/test-local-docker.sh | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index c038fb13..d31adda8 100644 --- a/Makefile +++ b/Makefile @@ -12,10 +12,10 @@ local-release: .install-deps ## build all app versions locally (via goreleaser) @bash ./devops/scripts/utils/local-release.sh test-be: ## run golang tests - @docker compose -f compose-dev.yaml up postgres backend-tests + @docker compose -f compose-dev.yaml up --abort-on-container-exit postgres backend-tests test-fe: ## run sveltekit tests - @docker compose -f compose-dev.yaml up fontend-tests + @docker compose -f compose-dev.yaml up --abort-on-container-exit fontend-tests test-be-ci: ## run golang tests in ci pipeline @mkdir -p ./service/backend/src/assets/frontend diff --git a/services/backend/scripts/test-local-docker.sh b/services/backend/scripts/test-local-docker.sh index 42731072..3b151f97 100644 --- a/services/backend/scripts/test-local-docker.sh +++ b/services/backend/scripts/test-local-docker.sh @@ -1,7 +1,9 @@ go mod download -go get github.com/uvulpos/go-svelte/swagger-docs go install golang.org/x/tools/cmd/goimports go install gotest.tools/gotestsum@latest + +swag fmt -g src/web-app/app.go && swag init -g src/web-app/app.go -o swagger-docs + go run src/main.go migrate-db gotestsum --format testname \ No newline at end of file From 51fb40bf6220fd45c481f595c9d880ecf431e269 Mon Sep 17 00:00:00 2001 From: Tim Riedl Date: Fri, 19 Apr 2024 22:11:08 +0200 Subject: [PATCH 23/31] fix: install swag --- services/backend/scripts/test-local-docker.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/services/backend/scripts/test-local-docker.sh b/services/backend/scripts/test-local-docker.sh index 3b151f97..067aa2a7 100644 --- a/services/backend/scripts/test-local-docker.sh +++ b/services/backend/scripts/test-local-docker.sh @@ -1,5 +1,6 @@ go mod download go install golang.org/x/tools/cmd/goimports +go install github.com/swaggo/swag/cmd/swag@latest go install gotest.tools/gotestsum@latest swag fmt -g src/web-app/app.go && swag init -g src/web-app/app.go -o swagger-docs From 0b65c9b720a69865d6121d396c0fd56c1910c103 Mon Sep 17 00:00:00 2001 From: Tim Riedl Date: Fri, 19 Apr 2024 22:11:21 +0200 Subject: [PATCH 24/31] fix: typo --- Makefile | 4 ++-- compose-dev.yaml | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index d31adda8..56b1b0d7 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ test-be: ## run golang tests @docker compose -f compose-dev.yaml up --abort-on-container-exit postgres backend-tests test-fe: ## run sveltekit tests - @docker compose -f compose-dev.yaml up --abort-on-container-exit fontend-tests + @docker compose -f compose-dev.yaml up --abort-on-container-exit frontend-tests test-be-ci: ## run golang tests in ci pipeline @mkdir -p ./service/backend/src/assets/frontend @@ -23,7 +23,7 @@ test-be-ci: ## run golang tests in ci pipeline @docker compose -f compose-dev.yaml up --abort-on-container-exit backend-tests-ci test-fe-ci: ## run sveltekit tests in ci pipeline - @docker compose -f compose-dev.yaml up --abort-on-container-exit fontend-tests + @docker compose -f compose-dev.yaml up --abort-on-container-exit frontend-tests-ci build-dockerfile-binary: ## build one dockerimage that contains everything @bash ./devops/scripts/build-container/binary.sh diff --git a/compose-dev.yaml b/compose-dev.yaml index 3a82f43e..4233a675 100644 --- a/compose-dev.yaml +++ b/compose-dev.yaml @@ -68,6 +68,21 @@ services: - intranet command: ["sh", "-c", "cd /app && npm install && npm run test"] + frontend-tests-ci: + image: node:latest + container_name: web-ui-test + restart: always + volumes: + - ./services/frontend/package.json:/app/package.json + - ./services/frontend/svelte.config.js:/app/svelte.config.js + - ./services/frontend/tsconfig.json:/app/tsconfig.json + - ./services/frontend/vite.config.ts:/app/vite.config.ts + - ./services/frontend/static:/app/static + - ./services/frontend/src:/app/src + networks: + - intranet + command: ["sh", "-c", "cd /app && npm install && npm run test"] + # ----------------------------------------------------------------------------------------------------- # # BACKEND From 6e36db4afd8486b8e648fd73cb10391ebc34b0de Mon Sep 17 00:00:00 2001 From: Tim Riedl Date: Fri, 19 Apr 2024 22:22:39 +0200 Subject: [PATCH 25/31] fix: create temp in frontend asset dir to prevent error in pipeline --- Makefile | 2 -- services/backend/scripts/test-local-docker.sh | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 56b1b0d7..77a28a11 100644 --- a/Makefile +++ b/Makefile @@ -18,8 +18,6 @@ test-fe: ## run sveltekit tests @docker compose -f compose-dev.yaml up --abort-on-container-exit frontend-tests test-be-ci: ## run golang tests in ci pipeline - @mkdir -p ./service/backend/src/assets/frontend - @echo "Hello World" > ./service/backend/src/assets/frontend/test.txt @docker compose -f compose-dev.yaml up --abort-on-container-exit backend-tests-ci test-fe-ci: ## run sveltekit tests in ci pipeline diff --git a/services/backend/scripts/test-local-docker.sh b/services/backend/scripts/test-local-docker.sh index 067aa2a7..ec2c9e32 100644 --- a/services/backend/scripts/test-local-docker.sh +++ b/services/backend/scripts/test-local-docker.sh @@ -3,6 +3,9 @@ go install golang.org/x/tools/cmd/goimports go install github.com/swaggo/swag/cmd/swag@latest go install gotest.tools/gotestsum@latest +mkdir -p src/assets/frontend +echo "Hello World 2" > src/assets/frontend/test.txt + swag fmt -g src/web-app/app.go && swag init -g src/web-app/app.go -o swagger-docs go run src/main.go migrate-db From ff7af34430a4abc248a5977760e1a872a48b32ca Mon Sep 17 00:00:00 2001 From: Tim Riedl Date: Mon, 22 Apr 2024 23:05:17 +0200 Subject: [PATCH 26/31] fix: ci tests, remove passkeys, add config management --- .env | 18 ++- .github/workflows/execute-tests.yaml | 7 ++ .gitignore | 3 +- Makefile | 2 +- compose-dev.yaml | 9 +- services/backend/config.yaml | 17 +++ services/backend/go.mod | 11 +- services/backend/go.sum | 10 -- services/backend/modd.conf | 2 +- services/backend/src/cmd/migrate/migrate.go | 4 +- services/backend/src/cmd/run/run.go | 15 +-- services/backend/src/helper/branding/main.go | 7 +- .../models/configuration_table_model.go | 6 +- .../src/helper/branding/preset_table.go | 8 +- services/backend/src/helper/config/config.go | 118 ++++++++++++++++-- services/backend/src/helper/config/structs.go | 41 +++--- .../src/helper/database/create-database.go | 27 +--- services/backend/src/helper/jwt/create_jwt.go | 5 +- services/backend/src/helper/jwt/verify_jwt.go | 3 +- services/backend/src/helper/webauthn/login.go | 9 -- services/backend/src/helper/webauthn/main.go | 38 ------ .../src/helper/webauthn/registration.go | 24 ---- services/backend/src/helper/webauthn/user.go | 63 ---------- services/backend/src/migrator/migrator.go | 5 +- .../resources/passkeys-fido/http/handler.go | 13 -- .../http/register_fido2_begin.go | 25 ---- .../http/register_fido2_finish.go | 33 ----- .../passkeys-fido/service/handler.go | 29 ----- .../service/register_user_fido_begin.go | 38 ------ .../service/register_user_fido_finish.go | 12 -- .../storage/create_transaction.go | 11 -- .../passkeys-fido/storage/get_session.go | 25 ---- .../passkeys-fido/storage/handler.go | 15 --- .../storage/insert_credential.go | 25 ---- .../passkeys-fido/storage/insert_session.go | 25 ---- services/backend/src/web-app/app.go | 34 ++--- services/backend/src/web-app/handler.go | 5 - services/backend/src/web-app/routes.go | 8 -- services/frontend/package-lock.json | 2 +- services/frontend/static/favicon.ico | Bin 0 -> 15406 bytes 40 files changed, 208 insertions(+), 544 deletions(-) create mode 100644 services/backend/config.yaml delete mode 100644 services/backend/src/helper/webauthn/login.go delete mode 100644 services/backend/src/helper/webauthn/main.go delete mode 100644 services/backend/src/helper/webauthn/registration.go delete mode 100644 services/backend/src/helper/webauthn/user.go delete mode 100644 services/backend/src/resources/passkeys-fido/http/handler.go delete mode 100644 services/backend/src/resources/passkeys-fido/http/register_fido2_begin.go delete mode 100644 services/backend/src/resources/passkeys-fido/http/register_fido2_finish.go delete mode 100644 services/backend/src/resources/passkeys-fido/service/handler.go delete mode 100644 services/backend/src/resources/passkeys-fido/service/register_user_fido_begin.go delete mode 100644 services/backend/src/resources/passkeys-fido/service/register_user_fido_finish.go delete mode 100644 services/backend/src/resources/passkeys-fido/storage/create_transaction.go delete mode 100644 services/backend/src/resources/passkeys-fido/storage/get_session.go delete mode 100644 services/backend/src/resources/passkeys-fido/storage/handler.go delete mode 100644 services/backend/src/resources/passkeys-fido/storage/insert_credential.go delete mode 100644 services/backend/src/resources/passkeys-fido/storage/insert_session.go create mode 100644 services/frontend/static/favicon.ico diff --git a/.env b/.env index 418a240f..8773c627 100644 --- a/.env +++ b/.env @@ -1,3 +1,15 @@ -POSTGRES_USER=postgres -POSTGRES_PASSWORD=postgres -POSTGRES_DB=postgres \ No newline at end of file +APP_DB_ADDR="postgres" +APP_DB_PORT=5432 +APP_DB_USERNAME="postgres" +APP_DB_PASSWORD="postgres" +APP_DB_DATABASE="postgres" +APP_DB_SSL_MODE=0 + +APP_PORT=3000 +APP_SHOW_FRONTEND=1 +APP_SHOW_SWAGGER=1 + + + + + diff --git a/.github/workflows/execute-tests.yaml b/.github/workflows/execute-tests.yaml index 8c3e2469..05b1eaa9 100644 --- a/.github/workflows/execute-tests.yaml +++ b/.github/workflows/execute-tests.yaml @@ -44,6 +44,13 @@ jobs: - name: run backend tests if: ${{ always() }} run: make test-be-ci + env: + APP_DATABASE_HOST: 127.0.0.1 + APP_DATABASE_PORT: 5432 + APP_DATABASE_USERNAME: postgres + APP_DATABASE_PASSWORD: postgres + APP_DATABASE_DATABASE: postgres + APP_DATABASE_SSLMODE: False test-frontend: runs-on: ubuntu-latest diff --git a/.gitignore b/.gitignore index e0e823ff..a2c41f1e 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,5 @@ services/backend/src/assets/frontend *.tgz .input -.secrets \ No newline at end of file +.secrets +node_modules diff --git a/Makefile b/Makefile index 77a28a11..dc686d77 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ @bash ./devops/scripts/utils/install-dependencies.sh dev: .install-deps ## start debugging in docker compose microservices (auto reload) - @docker compose -f compose-dev.yaml up backend frontend reverse-proxy + @docker compose -f compose-dev.yaml up --abort-on-container-exit backend frontend reverse-proxy build-full: .install-deps ## build current plattform @bash ./devops/scripts/build-service/binary.sh diff --git a/compose-dev.yaml b/compose-dev.yaml index 4233a675..66817eb5 100644 --- a/compose-dev.yaml +++ b/compose-dev.yaml @@ -104,7 +104,8 @@ services: condition: service_started # gotify: # condition: service_started - restart: always + env_file: + - "./.env" labels: - "traefik.enable=true" - "traefik.http.routers.backend.rule=Host(`web.localhost`)&&(PathPrefix(`/api`)||PathPrefix(`/swagger`))" @@ -150,9 +151,9 @@ services: image: postgis/postgis restart: always environment: - POSTGRES_USER: ${POSTGRES_USER} - POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} - POSTGRES_DB: ${POSTGRES_DB} + POSTGRES_USER: ${APP_DB_USERNAME} + POSTGRES_PASSWORD: ${APP_DB_PASSWORD} + POSTGRES_DB: ${APP_DB_DATABASE} PGDATA: /var/lib/postgresql/data/pgdata ports: - "5432:5432" diff --git a/services/backend/config.yaml b/services/backend/config.yaml new file mode 100644 index 00000000..604c5a18 --- /dev/null +++ b/services/backend/config.yaml @@ -0,0 +1,17 @@ +database: + host: postgres + port: 5432 + username: postgres + password: postgres + database: postgres + sslmode: 0 + +webserver: + host: 127.0.0.1 + port: 3000 + show_frontend: 1 + show_swagger: 1 + +security: + jwtsecret: loafofbread + secretgreet: "Secret Hello World" \ No newline at end of file diff --git a/services/backend/go.mod b/services/backend/go.mod index 8b516f7d..10d9298a 100644 --- a/services/backend/go.mod +++ b/services/backend/go.mod @@ -6,7 +6,7 @@ require ( github.com/charmbracelet/lipgloss v0.10.0 github.com/google/uuid v1.6.0 github.com/qeesung/image2ascii v1.0.1 - github.com/swaggo/swag v1.16.3 // indirect + github.com/swaggo/swag v1.16.3 ) require ( @@ -15,13 +15,10 @@ require ( github.com/aybabtme/rgbterm v0.0.0-20170906152045-cc83f3b3ce59 // indirect github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect - github.com/fxamacker/cbor/v2 v2.5.0 // indirect github.com/go-openapi/jsonpointer v0.20.0 // indirect github.com/go-openapi/jsonreference v0.20.2 // indirect github.com/go-openapi/spec v0.20.11 // indirect github.com/go-openapi/swag v0.22.4 // indirect - github.com/go-webauthn/x v0.1.8 // indirect - github.com/google/go-tpm v0.9.0 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/hashicorp/hcl v1.0.0 // indirect @@ -51,7 +48,6 @@ require ( github.com/valyala/fasthttp v1.51.0 // indirect github.com/valyala/tcplisten v1.0.0 // indirect github.com/wayneashleyberry/terminal-dimensions v1.1.0 // indirect - github.com/x448/float16 v0.8.4 // indirect go.uber.org/atomic v1.11.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb // indirect @@ -69,10 +65,7 @@ require ( golang.org/x/term v0.18.0 // indirect ) -require ( - github.com/go-sqlx/sqlx v1.3.7 - github.com/go-webauthn/webauthn v0.10.1 -) +require github.com/go-sqlx/sqlx v1.3.7 require ( github.com/gofiber/fiber/v2 v2.52.2 diff --git a/services/backend/go.sum b/services/backend/go.sum index 7d78a818..b10c803b 100644 --- a/services/backend/go.sum +++ b/services/backend/go.sum @@ -39,8 +39,6 @@ github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHk github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= -github.com/fxamacker/cbor/v2 v2.5.0 h1:oHsG0V/Q6E/wqTS2O1Cozzsy69nqCiguo5Q1a1ADivE= -github.com/fxamacker/cbor/v2 v2.5.0/go.mod h1:TA1xS00nchWmaBnEIxPSE5oHLuJBAVvqrtAnWBwBCVo= github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs= @@ -60,10 +58,6 @@ github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrt github.com/go-sql-driver/mysql v1.7.1/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= github.com/go-sqlx/sqlx v1.3.7 h1:C6x4U4wWXtyssy+5IP6WguSjHMJChEbWB6/sw6mu/9E= github.com/go-sqlx/sqlx v1.3.7/go.mod h1:07mPTHP408293M6g7jFbllQW5O428VG2jX5dqYbTHkE= -github.com/go-webauthn/webauthn v0.10.1 h1:+RFKj4yHPy282teiiy5sqTYPfRilzBpJyedrz9KsNFE= -github.com/go-webauthn/webauthn v0.10.1/go.mod h1:a7BwAtrSMkeuJXtIKz433Av99nAv01pdfzB0a9xkDnI= -github.com/go-webauthn/x v0.1.8 h1:f1C6k1AyUlDvnIzWSW+G9rN9nbp1hhLXZagUtyxZ8nc= -github.com/go-webauthn/x v0.1.8/go.mod h1:i8UNlGVt3oy6oAFcP4SZB1djZLx/4pbekCbWowjTaJg= github.com/gofiber/fiber/v2 v2.52.2 h1:b0rYH6b06Df+4NyrbdptQL8ifuxw/Tf2DgfkZkDaxEo= github.com/gofiber/fiber/v2 v2.52.2/go.mod h1:KEOE+cXMhXG0zHc9d8+E38hoX+ZN7bhOtgeF2oT6jrQ= github.com/gofiber/swagger v1.0.0 h1:BzUzDS9ZT6fDUa692kxmfOjc1DZiloLiPK/W5z1H1tc= @@ -76,8 +70,6 @@ github.com/golang-migrate/migrate/v4 v4.17.0 h1:rd40H3QXU0AA4IoLllFcEAEo9dYKRHYN github.com/golang-migrate/migrate/v4 v4.17.0/go.mod h1:+Cp2mtLP4/aXDTKb9wmXYitdrNx2HGs45rbWAo6OsKM= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/go-tpm v0.9.0 h1:sQF6YqWMi+SCXpsmS3fd21oPy/vSddwZry4JnmltHVk= -github.com/google/go-tpm v0.9.0/go.mod h1:FkNVkc6C+IsvDI9Jw1OveJmxGZUUaKxtrpOS47QWKfU= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= @@ -198,8 +190,6 @@ github.com/valyala/tcplisten v1.0.0 h1:rBHj/Xf+E1tRGZyWIWwJDiRY0zc1Js+CV5DqwacVS github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc= github.com/wayneashleyberry/terminal-dimensions v1.1.0 h1:EB7cIzBdsOzAgmhTUtTTQXBByuPheP/Zv1zL2BRPY6g= github.com/wayneashleyberry/terminal-dimensions v1.1.0/go.mod h1:2lc/0eWCObmhRczn2SdGSQtgBooLUzIotkkEGXqghyg= -github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= -github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE= go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= diff --git a/services/backend/modd.conf b/services/backend/modd.conf index 85b21189..ebfde656 100644 --- a/services/backend/modd.conf +++ b/services/backend/modd.conf @@ -2,5 +2,5 @@ src/**/* !src/assets/frontend/**/* { prep: swag fmt -g src/web-app/app.go && swag init -g src/web-app/app.go -o swagger-docs - daemon +sigterm: go run src/main.go run --show-swagger + daemon +sigterm: go run src/main.go run } \ No newline at end of file diff --git a/services/backend/src/cmd/migrate/migrate.go b/services/backend/src/cmd/migrate/migrate.go index 2ee6185d..92551d2b 100644 --- a/services/backend/src/cmd/migrate/migrate.go +++ b/services/backend/src/cmd/migrate/migrate.go @@ -21,9 +21,9 @@ var MigrateCmd = &cobra.Command{ Long: `🚀 Migrate your database to a newer version`, Run: func(cmd *cobra.Command, args []string) { - configuration := config.LoadData() + config.LoadData() branding.PrintBranding() - err := migrator.NewMigrator(configuration).MigrateUp() + err := migrator.NewMigrator().MigrateUp() messageStyle := lipgloss.NewStyle().Bold(true) successMessageStyle := messageStyle.Foreground(lipgloss.Color("#1eb523")) diff --git a/services/backend/src/cmd/run/run.go b/services/backend/src/cmd/run/run.go index d4a817aa..23ef53c9 100644 --- a/services/backend/src/cmd/run/run.go +++ b/services/backend/src/cmd/run/run.go @@ -5,7 +5,6 @@ package cmd import ( "github.com/spf13/cobra" - "github.com/spf13/viper" "github.com/uvulpos/go-svelte/src/helper/branding" "github.com/uvulpos/go-svelte/src/helper/config" webApp "github.com/uvulpos/go-svelte/src/web-app" @@ -23,17 +22,9 @@ var RunAppCmd = &cobra.Command{ Long: `starts the webserver to provide the application`, Run: func(cmd *cobra.Command, args []string) { - configuration := config.LoadData() + config.LoadData() branding.PrintBrandingWithConfig() - webApp.NewApp(configuration).RunApp(configuration) - }, -} -func init() { - RunAppCmd.Flags().BoolVar(&showNoFrontend, "no-frontend", false, "disable the frontend and deliver just an api") - RunAppCmd.Flags().BoolVar(&showSwaggger, "show-swagger", false, "enable the swagger api for developing") - RunAppCmd.Flags().IntVarP(&webserverPort, "port", "p", 3000, "define a port, where the application should listen to") - - flagSet := RunAppCmd.Flags() - viper.BindPFlags(flagSet) + webApp.NewApp().RunApp() + }, } diff --git a/services/backend/src/helper/branding/main.go b/services/backend/src/helper/branding/main.go index 84d43834..1572c40d 100644 --- a/services/backend/src/helper/branding/main.go +++ b/services/backend/src/helper/branding/main.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/uvulpos/go-svelte/src/helper/branding/models" + "github.com/uvulpos/go-svelte/src/helper/config" ) func PrintBranding() { @@ -28,8 +29,10 @@ func PrintBrandingWithConfig() { startupInformation, defaultConfConfiguraton := getAsciiStartupInformation() startupPresetTable := getAsciiConfigurationTable(models.ConfigurationTable{ - Host: "127.0.0.1", - Port: "8080", + Host: config.GetWebserver().Host, + Port: fmt.Sprint(config.GetWebserver().Port), + ShowFrontend: config.GetWebserver().ShowFrontend, + ShowSwagger: config.GetWebserver().ShowSwagger, }, defaultConfConfiguraton) fmt.Println(logo) diff --git a/services/backend/src/helper/branding/models/configuration_table_model.go b/services/backend/src/helper/branding/models/configuration_table_model.go index 4559747d..f2d19cb6 100644 --- a/services/backend/src/helper/branding/models/configuration_table_model.go +++ b/services/backend/src/helper/branding/models/configuration_table_model.go @@ -1,6 +1,8 @@ package models type ConfigurationTable struct { - Host string - Port string + Host string + Port string + ShowFrontend bool + ShowSwagger bool } diff --git a/services/backend/src/helper/branding/preset_table.go b/services/backend/src/helper/branding/preset_table.go index 6af51327..2c97585f 100644 --- a/services/backend/src/helper/branding/preset_table.go +++ b/services/backend/src/helper/branding/preset_table.go @@ -1,6 +1,8 @@ package branding import ( + "fmt" + "github.com/charmbracelet/lipgloss" "github.com/charmbracelet/lipgloss/table" "github.com/uvulpos/go-svelte/src/helper/branding/models" @@ -10,6 +12,8 @@ func getAsciiConfigurationTable(configuration models.ConfigurationTable, presetS configurationRows := [][]string{ {"Host:", configuration.Host}, {"Port:", configuration.Port}, + {"ShowFrontend:", fmt.Sprintf("%t", configuration.ShowFrontend)}, + {"ShowSwagger:", fmt.Sprintf("%t", configuration.ShowSwagger)}, } informationTable := table.New(). @@ -19,8 +23,8 @@ func getAsciiConfigurationTable(configuration models.ConfigurationTable, presetS Rows(configurationRows...) styleInformation := presetStle.Align(lipgloss.Left). - PaddingLeft(5). - PaddingRight(5). + PaddingLeft(3). + PaddingRight(3). Underline(false). Bold(false) diff --git a/services/backend/src/helper/config/config.go b/services/backend/src/helper/config/config.go index 8cb79280..e04096ca 100644 --- a/services/backend/src/helper/config/config.go +++ b/services/backend/src/helper/config/config.go @@ -2,25 +2,119 @@ package config import ( "fmt" + "log" + "reflect" + "strings" "github.com/spf13/viper" ) -func LoadData() *Configuration { +var ( + config Config +) + +/* +* +* I encountered issues by autodetecting the struct from viper so temporary manual +* TODO: autoread struct +* + */ +func LoadData() { + + viperConfig := viper.New() + viperConfig.AddConfigPath(".") + viperConfig.AddConfigPath("$HOME/.my-application") + viperConfig.SetConfigName("config") + viperConfig.SetConfigType("yaml") + + viperConfig.SetEnvPrefix("app") + + replacer := strings.NewReplacer(".", "_") + viperConfig.SetEnvKeyReplacer(replacer) + viperConfig.AllowEmptyEnv(true) + + viperConfig.AutomaticEnv() + bindEnvVariables(reflect.TypeOf(Config{}), "", viperConfig) - config := createDefaultConfiguration() - fmt.Println("---- LOAD CONFIG") + err := viperConfig.ReadInConfig() + if err != nil { + if _, ok := err.(viper.ConfigFileNotFoundError); ok { + fmt.Println("[INFORMATION]: No config file found, relying on environment variables only.") + } else { + log.Fatalf("Fatal error config file: %s", err) + } + } - viperInstance := viper.New() + if err := viperConfig.Unmarshal(&config); err != nil { + log.Fatalf("Unable to decode into struct, %s", err) + } + + fmt.Println("Keys: ", viperConfig.AllKeys()) + fmt.Println("Keys: ", viperConfig.AllSettings()) + fmt.Println("Webserver: ", config.Webserver) + fmt.Println("Database: ", config.Database) + fmt.Println("Security: ", config.Security) +} + +func bindEnvVariables(t reflect.Type, parent string, viperConfig *viper.Viper) { + if t.Kind() == reflect.Struct { + for i := 0; i < t.NumField(); i++ { + field := t.Field(i) + jsonTag := field.Tag.Get("mapstructure") + if jsonTag == "" { + jsonTag = strings.ToLower(field.Name) + } + + fullPath := jsonTag + if parent != "" { + fullPath = parent + "." + jsonTag + } + + viperConfig.BindEnv(fullPath, strings.ToUpper(viperConfig.GetEnvPrefix()+"_"+strings.ReplaceAll(fullPath, ".", "_"))) + bindEnvVariables(field.Type, fullPath, viperConfig) + } + } +} - viperInstance.SetDefault("db-host", "postgres") - viperInstance.SetDefault("db-port", "5432") - viperInstance.SetDefault("db-username", "postgres") - viperInstance.SetDefault("db-password", "postgres") - viperInstance.SetDefault("db-database", "postgres") - viperInstance.SetDefault("db-sslmode", false) +func GetSqlConnectionString() (string, string) { - viperInstance.AutomaticEnv() + var sslMode string = "disable" + if config.Database.SslMode { + + sslMode = "require" + } + + connString := fmt.Sprintf( + "postgres://%s:%s@%s:%d/%s?sslmode=%s", + config.Database.Username, + config.Database.Password, + config.Database.Host, + config.Database.Port, + config.Database.Database, + sslMode, + ) + + humanString := fmt.Sprintf( + "%s:%d", + config.Database.Host, + config.Database.Port, + ) + + return connString, humanString +} + +func GetDatabase() DatabaseConfig { + return config.Database +} + +func GetWebserver() WebserverConfig { + return config.Webserver +} + +func ShowFrontend() bool { + return config.Webserver.ShowFrontend +} - return config +func GetJwtSecret() string { + return config.Security.JwtSecret } diff --git a/services/backend/src/helper/config/structs.go b/services/backend/src/helper/config/structs.go index c595ece9..de705494 100644 --- a/services/backend/src/helper/config/structs.go +++ b/services/backend/src/helper/config/structs.go @@ -1,17 +1,12 @@ package config -type Configuration struct { - Webserver Webserver `mapstructure:"webserver"` - DB DatabaseCredentials `mapstructure:"db"` +type Config struct { + Database DatabaseConfig + Webserver WebserverConfig + Security SecurityConfig } -type Webserver struct { - Port int `mapstructure:"port"` - NoFrontend bool `mapstructure:"nofrontend"` - ShowSwagger bool `mapstructure:"showswagger"` -} - -type DatabaseCredentials struct { +type DatabaseConfig struct { Host string `mapstructure:"host"` Port int `mapstructure:"port"` Username string `mapstructure:"username"` @@ -20,20 +15,14 @@ type DatabaseCredentials struct { SslMode bool `mapstructure:"sslmode"` } -func createDefaultConfiguration() *Configuration { - return &Configuration{ - Webserver: Webserver{ - Port: 3000, - NoFrontend: false, - ShowSwagger: true, - }, - DB: DatabaseCredentials{ - Host: "postgres", - Port: 5432, - Username: "postgres", - Password: "postgres", - Database: "postgres", - SslMode: false, - }, - } +type WebserverConfig struct { + Host string `mapstructure:"host"` + Port int `mapstructure:"port"` + ShowFrontend bool `mapstructure:"show_frontend"` + ShowSwagger bool `mapstructure:"show_swagger"` +} + +type SecurityConfig struct { + JwtSecret string + SecretGreet string } diff --git a/services/backend/src/helper/database/create-database.go b/services/backend/src/helper/database/create-database.go index 83253a29..6915bece 100644 --- a/services/backend/src/helper/database/create-database.go +++ b/services/backend/src/helper/database/create-database.go @@ -1,36 +1,13 @@ package database import ( - "fmt" - "github.com/go-sqlx/sqlx" "github.com/uvulpos/go-svelte/src/helper/config" ) -func CreateDatabase(configuration *config.Configuration) (*Sql, error) { - dbHost := configuration.DB.Host - dbPort := configuration.DB.Port - dbUsername := configuration.DB.Username - dbPassword := configuration.DB.Password - dbDatabase := configuration.DB.Database - - addr := fmt.Sprintf("%s:%d", dbHost, dbPort) - - var sslMode string = "disable" - if configuration.DB.SslMode { - sslMode = "require" - } - - connStr := fmt.Sprintf( - "postgres://%s:%s@%s/%s?sslmode=%s", - dbUsername, - dbPassword, - addr, - dbDatabase, - sslMode, - ) +func CreateDatabase() (*Sql, error) { + connStr, _ := config.GetSqlConnectionString() - fmt.Println("DB CONN: ", connStr) db, dbErr := sqlx.Connect("postgres", connStr) if dbErr != nil { return nil, dbErr diff --git a/services/backend/src/helper/jwt/create_jwt.go b/services/backend/src/helper/jwt/create_jwt.go index 3509cbb8..1525896c 100644 --- a/services/backend/src/helper/jwt/create_jwt.go +++ b/services/backend/src/helper/jwt/create_jwt.go @@ -2,11 +2,10 @@ package jwt import ( "github.com/golang-jwt/jwt/v5" + "github.com/uvulpos/go-svelte/src/helper/config" userService "github.com/uvulpos/go-svelte/src/resources/users/service" ) -const jwtTokenSecret = `loafofbread` - func NewJWT(user *userService.UserWithPermission) (string, error) { var key []byte // *ecdsa.PrivateKey ->> https://golang-jwt.github.io/jwt/usage/create/ var t *jwt.Token @@ -17,7 +16,7 @@ func NewJWT(user *userService.UserWithPermission) (string, error) { roleIndicators = append(roleIndicators, r.Identifier) } - key = []byte("loafofbread") + key = []byte(config.GetJwtSecret()) t = jwt.NewWithClaims(jwt.SigningMethodHS512, jwt.MapClaims{ "user-uuid": user.Id.String(), "username": user.Username, diff --git a/services/backend/src/helper/jwt/verify_jwt.go b/services/backend/src/helper/jwt/verify_jwt.go index d854dd02..67db12a0 100644 --- a/services/backend/src/helper/jwt/verify_jwt.go +++ b/services/backend/src/helper/jwt/verify_jwt.go @@ -5,6 +5,7 @@ import ( "fmt" "github.com/golang-jwt/jwt/v5" + "github.com/uvulpos/go-svelte/src/helper/config" ) type AppJWTClaims struct { @@ -25,7 +26,7 @@ func VerifyJWToken(jwtToken string) (bool, *AppJWTClaims, error) { return nil, fmt.Errorf("unexpected signing method: %v", token.Header["alg"]) } - return []byte(jwtTokenSecret), nil + return []byte(config.GetJwtSecret()), nil }) if tokenErr != nil { fmt.Println("Verify JWT", tokenErr) diff --git a/services/backend/src/helper/webauthn/login.go b/services/backend/src/helper/webauthn/login.go deleted file mode 100644 index 0957c97d..00000000 --- a/services/backend/src/helper/webauthn/login.go +++ /dev/null @@ -1,9 +0,0 @@ -package webauthn - -func (webN *WebAuthN) BeginLogin() { - -} - -func (webN *WebAuthN) FinishLogin() { - -} diff --git a/services/backend/src/helper/webauthn/main.go b/services/backend/src/helper/webauthn/main.go deleted file mode 100644 index e1163d92..00000000 --- a/services/backend/src/helper/webauthn/main.go +++ /dev/null @@ -1,38 +0,0 @@ -package webauthn - -import ( - "fmt" - - "github.com/go-webauthn/webauthn/webauthn" -) - -type WebAuthN struct { - webAuthn *webauthn.WebAuthn -} - -func CreateNewWebAuthN(DisplayName, Domain string, AllowedDomains ...string) *WebAuthN { - - if len(AllowedDomains) == 0 { - AllowedDomains = []string{Domain} - } - - wconfig := &webauthn.Config{ - RPDisplayName: DisplayName, // Display Name for your site - RPID: Domain, // Generally the FQDN for your site - RPOrigins: AllowedDomains, // The origin URLs allowed for WebAuthn requests - } - - webAuthn, err := webauthn.New(wconfig) - if err != nil { - fmt.Println(err) - } - - return &WebAuthN{ - webAuthn, - } -} - -// // get Configuration of WebAuthN Handler -// func (webN *WebAuthN) GetConfig() *webauthn.Config { -// return webN.webAuthn.Config -// } diff --git a/services/backend/src/helper/webauthn/registration.go b/services/backend/src/helper/webauthn/registration.go deleted file mode 100644 index eb8c9c78..00000000 --- a/services/backend/src/helper/webauthn/registration.go +++ /dev/null @@ -1,24 +0,0 @@ -package webauthn - -import ( - "github.com/go-webauthn/webauthn/protocol" - "github.com/go-webauthn/webauthn/webauthn" -) - -func (webN *WebAuthN) BeginRegistration(user *WebAuthNUser) (*protocol.CredentialCreation, *webauthn.SessionData, error) { - options, session, err := webN.webAuthn.BeginRegistration(user) - if err != nil { - return nil, nil, err - } - return options, session, nil -} - -func (webN *WebAuthN) FinishRegistration() { - // _, err := webN.webAuthn.FinishRegistration(user, session, r) - // if err != nil { - // // Handle Error and return. - - // return - // } - -} diff --git a/services/backend/src/helper/webauthn/user.go b/services/backend/src/helper/webauthn/user.go deleted file mode 100644 index b113204d..00000000 --- a/services/backend/src/helper/webauthn/user.go +++ /dev/null @@ -1,63 +0,0 @@ -package webauthn - -import "github.com/go-webauthn/webauthn/webauthn" - -type WebAuthNUser struct { - ID string - Name string - DisplayName string - Icon string - Credentials []webauthn.Credential -} - -func CreateWebAuthNUser( - ID, - Name, - DisplayName string, - Credentials []webauthn.Credential, - CredentialsSignIn []webauthn.Credential, -) *WebAuthNUser { - return &WebAuthNUser{ - ID, - Name, - DisplayName, - "", - Credentials, - } -} - -func CreateWebAuthNUserWithOutCertificates( - ID, - Name, - DisplayName string, -) *WebAuthNUser { - return &WebAuthNUser{ - ID, - Name, - DisplayName, - "", - []webauthn.Credential{}, - } -} - -func (u *WebAuthNUser) WebAuthnID() []byte { - return []byte(u.ID) -} - -func (u *WebAuthNUser) WebAuthnName() string { - return u.Name -} - -func (u *WebAuthNUser) WebAuthnDisplayName() string { - return u.DisplayName -} - -func (u *WebAuthNUser) WebAuthnCredentials() []webauthn.Credential { - return u.Credentials -} - -// WebAuthnIcon is a deprecated option. -// Deprecated: this has been removed from the specification recommendation. Suggest a blank string. -func (u *WebAuthNUser) WebAuthnIcon() string { - return "" -} diff --git a/services/backend/src/migrator/migrator.go b/services/backend/src/migrator/migrator.go index 2e53a89d..e943e2c2 100644 --- a/services/backend/src/migrator/migrator.go +++ b/services/backend/src/migrator/migrator.go @@ -10,7 +10,6 @@ import ( "github.com/golang-migrate/migrate/v4/database/postgres" "github.com/golang-migrate/migrate/v4/source/httpfs" _ "github.com/lib/pq" - "github.com/uvulpos/go-svelte/src/helper/config" dbHelper "github.com/uvulpos/go-svelte/src/helper/database" ) @@ -21,8 +20,8 @@ type Migrator struct { db *sql.DB } -func NewMigrator(configuration *config.Configuration) *Migrator { - dbConn, dbConnErr := dbHelper.CreateDatabase(configuration) +func NewMigrator() *Migrator { + dbConn, dbConnErr := dbHelper.CreateDatabase() if dbConn == nil || dbConn.DB == nil || dbConnErr != nil { err := fmt.Errorf("could not connect to database") if err != nil { diff --git a/services/backend/src/resources/passkeys-fido/http/handler.go b/services/backend/src/resources/passkeys-fido/http/handler.go deleted file mode 100644 index 9bfdffc1..00000000 --- a/services/backend/src/resources/passkeys-fido/http/handler.go +++ /dev/null @@ -1,13 +0,0 @@ -package http - -import "github.com/uvulpos/go-svelte/src/resources/passkeys-fido/service" - -type PasskeyHandler struct { - service *service.PasskeySvc -} - -func NewPasskeyHandler(service *service.PasskeySvc) *PasskeyHandler { - return &PasskeyHandler{ - service, - } -} diff --git a/services/backend/src/resources/passkeys-fido/http/register_fido2_begin.go b/services/backend/src/resources/passkeys-fido/http/register_fido2_begin.go deleted file mode 100644 index d31ad339..00000000 --- a/services/backend/src/resources/passkeys-fido/http/register_fido2_begin.go +++ /dev/null @@ -1,25 +0,0 @@ -package http - -import ( - "net/http" - - "github.com/gofiber/fiber/v2" -) - -func (h *PasskeyHandler) BeginWebAuthNRegistration(c *fiber.Ctx) error { - // requestUser := c.Locals("user-uuid") - // userUuid, ok := requestUser.(string) - // if !ok { - // return c.SendStatus(http.StatusUnauthorized) - // } - - // credential, err := h.service.RegisterUserFidoBegin(userUuid) - // if err != nil { - // fmt.Println(err) - // return err - // } - - // return c.JSON(credential) - - return c.SendStatus(http.StatusOK) -} diff --git a/services/backend/src/resources/passkeys-fido/http/register_fido2_finish.go b/services/backend/src/resources/passkeys-fido/http/register_fido2_finish.go deleted file mode 100644 index 33106606..00000000 --- a/services/backend/src/resources/passkeys-fido/http/register_fido2_finish.go +++ /dev/null @@ -1,33 +0,0 @@ -package http - -import ( - "net/http" - - "github.com/gofiber/fiber/v2" -) - -type FidoRegisterFinishPayload struct { - ID string `json:"id"` - RawID string `json:"rawId"` - Type string `json:"type"` - Response struct { - AttestationObject string `json:"attestationObject"` - ClientDataJSON string `json:"clientDataJSON"` - } `json:"response"` -} - -func (h *PasskeyHandler) FinishWebAuthNRegistration(c *fiber.Ctx) error { - // requestUser := c.Locals("user-uuid") - // userUuid, ok := requestUser.(string) - // if !ok { - // return c.SendStatus(http.StatusUnauthorized) - // } - - // err := h.service.RegisterUserFidoFinish(userUuid) - // if err != nil { - // fmt.Println(err) - // return err - // } - - return c.SendStatus(http.StatusOK) -} diff --git a/services/backend/src/resources/passkeys-fido/service/handler.go b/services/backend/src/resources/passkeys-fido/service/handler.go deleted file mode 100644 index 3dd099f4..00000000 --- a/services/backend/src/resources/passkeys-fido/service/handler.go +++ /dev/null @@ -1,29 +0,0 @@ -package service - -import ( - "time" - - "github.com/go-sqlx/sqlx" - "github.com/uvulpos/go-svelte/src/helper/webauthn" - - userSvc "github.com/uvulpos/go-svelte/src/resources/users/service" -) - -type PasskeySvc struct { - storage PasskeyStorage - userService *userSvc.UserSvc - webAuthN *webauthn.WebAuthN -} - -func NewPasskeySvc(storage PasskeyStorage, user *userSvc.UserSvc, webAuthN *webauthn.WebAuthN) *PasskeySvc { - return &PasskeySvc{ - storage, - user, - webAuthN, - } -} - -type PasskeyStorage interface { - CreateTransaction() (*sqlx.Tx, error) - InsertFidoSession(tx *sqlx.Tx, uuid string, sessionJson []byte, expires time.Time) error -} diff --git a/services/backend/src/resources/passkeys-fido/service/register_user_fido_begin.go b/services/backend/src/resources/passkeys-fido/service/register_user_fido_begin.go deleted file mode 100644 index 90f64181..00000000 --- a/services/backend/src/resources/passkeys-fido/service/register_user_fido_begin.go +++ /dev/null @@ -1,38 +0,0 @@ -package service - -import ( - "encoding/json" - - "github.com/go-webauthn/webauthn/protocol" - "github.com/uvulpos/go-svelte/src/helper/webauthn" -) - -func (h *PasskeySvc) RegisterUserFidoBegin(uuid string) (*protocol.CredentialCreation, error) { - user, userErr := h.userService.GetUserByUUID(nil, uuid) - if userErr != nil { - return nil, userErr - } - - webAuthUser := webauthn.CreateWebAuthNUserWithOutCertificates( - user.Id.String(), - user.Username, - user.Username, - ) - - credential, session, err := h.webAuthN.BeginRegistration(webAuthUser) - if err != nil { - return nil, err - } - - sessionJson, sessionJsonErr := json.Marshal(session) - if sessionJsonErr != nil { - return nil, sessionJsonErr - } - - sessionErr := h.storage.InsertFidoSession(nil, uuid, sessionJson, session.Expires) - if sessionErr != nil { - return nil, sessionErr - } - - return credential, nil -} diff --git a/services/backend/src/resources/passkeys-fido/service/register_user_fido_finish.go b/services/backend/src/resources/passkeys-fido/service/register_user_fido_finish.go deleted file mode 100644 index c054590e..00000000 --- a/services/backend/src/resources/passkeys-fido/service/register_user_fido_finish.go +++ /dev/null @@ -1,12 +0,0 @@ -package service - -func (h *PasskeySvc) RegisterUserFidoFinish(userUuid string) error { - - // get user - - // get session - - // finish registration - - return nil -} diff --git a/services/backend/src/resources/passkeys-fido/storage/create_transaction.go b/services/backend/src/resources/passkeys-fido/storage/create_transaction.go deleted file mode 100644 index 3aeaeb43..00000000 --- a/services/backend/src/resources/passkeys-fido/storage/create_transaction.go +++ /dev/null @@ -1,11 +0,0 @@ -package storage - -import "github.com/go-sqlx/sqlx" - -func (h *PasskeyStore) CreateTransaction() (*sqlx.Tx, error) { - tx, txErr := h.dbstore.DB.Beginx() - if txErr != nil { - return nil, txErr - } - return tx, nil -} diff --git a/services/backend/src/resources/passkeys-fido/storage/get_session.go b/services/backend/src/resources/passkeys-fido/storage/get_session.go deleted file mode 100644 index 02ec2ca3..00000000 --- a/services/backend/src/resources/passkeys-fido/storage/get_session.go +++ /dev/null @@ -1,25 +0,0 @@ -package storage - -import ( - "errors" - "time" - - "github.com/go-sqlx/sqlx" -) - -func (h *PasskeyStore) GetFidoSession(tx *sqlx.Tx, uuid string, sessionJson []byte, expires time.Time) error { - var rowErr error - const sql = `` - - if tx == nil { - _, rowErr = h.dbstore.DB.Exec(sql) - } else { - _, rowErr = tx.Exec(sql) - } - - if rowErr != nil { - return errors.New("could not insert session into database") - } - - return nil -} diff --git a/services/backend/src/resources/passkeys-fido/storage/handler.go b/services/backend/src/resources/passkeys-fido/storage/handler.go deleted file mode 100644 index fdcbce58..00000000 --- a/services/backend/src/resources/passkeys-fido/storage/handler.go +++ /dev/null @@ -1,15 +0,0 @@ -package storage - -import ( - "github.com/uvulpos/go-svelte/src/helper/database" -) - -type PasskeyStore struct { - dbstore database.Sql -} - -func NewUserStore(db database.Sql) *PasskeyStore { - return &PasskeyStore{ - db, - } -} diff --git a/services/backend/src/resources/passkeys-fido/storage/insert_credential.go b/services/backend/src/resources/passkeys-fido/storage/insert_credential.go deleted file mode 100644 index 9b1aabae..00000000 --- a/services/backend/src/resources/passkeys-fido/storage/insert_credential.go +++ /dev/null @@ -1,25 +0,0 @@ -package storage - -import ( - "errors" - "time" - - "github.com/go-sqlx/sqlx" -) - -func (h *PasskeyStore) InsertFidoCredential(tx *sqlx.Tx, uuid string, sessionJson []byte, expires time.Time) error { - var rowErr error - const sql = `` - - if tx == nil { - _, rowErr = h.dbstore.DB.Exec(sql) - } else { - _, rowErr = tx.Exec(sql) - } - - if rowErr != nil { - return errors.New("could not insert session into database") - } - - return nil -} diff --git a/services/backend/src/resources/passkeys-fido/storage/insert_session.go b/services/backend/src/resources/passkeys-fido/storage/insert_session.go deleted file mode 100644 index c7d8742b..00000000 --- a/services/backend/src/resources/passkeys-fido/storage/insert_session.go +++ /dev/null @@ -1,25 +0,0 @@ -package storage - -import ( - "errors" - "time" - - "github.com/go-sqlx/sqlx" -) - -func (h *PasskeyStore) InsertFidoSession(tx *sqlx.Tx, uuid string, sessionJson []byte, expires time.Time) error { - var rowErr error - const sql = `` - - if tx == nil { - _, rowErr = h.dbstore.DB.Exec(sql) - } else { - _, rowErr = tx.Exec(sql) - } - - if rowErr != nil { - return errors.New("could not insert session into database") - } - - return nil -} diff --git a/services/backend/src/web-app/app.go b/services/backend/src/web-app/app.go index 1907e675..e376072e 100644 --- a/services/backend/src/web-app/app.go +++ b/services/backend/src/web-app/app.go @@ -16,25 +16,19 @@ import ( "github.com/uvulpos/go-svelte/src/assets" "github.com/uvulpos/go-svelte/src/helper/config" dbHelper "github.com/uvulpos/go-svelte/src/helper/database" - "github.com/uvulpos/go-svelte/src/helper/webauthn" userHttp "github.com/uvulpos/go-svelte/src/resources/users/http" userService "github.com/uvulpos/go-svelte/src/resources/users/service" userStorage "github.com/uvulpos/go-svelte/src/resources/users/storage" - - passkeyHttp "github.com/uvulpos/go-svelte/src/resources/passkeys-fido/http" - passkeyService "github.com/uvulpos/go-svelte/src/resources/passkeys-fido/service" - passkeyStorage "github.com/uvulpos/go-svelte/src/resources/passkeys-fido/storage" ) type App struct { - UserHandler UserHandler - PasskeyHandler PasskeyHandler + UserHandler UserHandler } -func NewApp(configuration *config.Configuration) *App { +func NewApp() *App { - dbConn, dbConnErr := dbHelper.CreateDatabase(configuration) + dbConn, dbConnErr := dbHelper.CreateDatabase() if dbConn == nil || dbConn.DB == nil || dbConnErr != nil { err := fmt.Errorf("could not connect to database") if err != nil { @@ -43,28 +37,16 @@ func NewApp(configuration *config.Configuration) *App { return nil } - webAuthNHandler := webauthn.CreateNewWebAuthN( - "Go Svelte Binary Localhost", - "web.localhost", - "http://web.localhost/", - ) - userStore := userStorage.NewUserStore(*dbConn) userSvc := userService.NewUserSvc(userStore) userHandler := userHttp.NewUserHandler(userSvc) - passkeyStore := passkeyStorage.NewUserStore(*dbConn) - passkeySvc := passkeyService.NewPasskeySvc(passkeyStore, userSvc, webAuthNHandler) - passkeyHandler := passkeyHttp.NewPasskeyHandler(passkeySvc) - return &App{ - UserHandler: userHandler, - PasskeyHandler: passkeyHandler, + UserHandler: userHandler, } } -func (a *App) RunApp(configuration *config.Configuration) { - +func (a *App) RunApp() { publicFS, err := fs.Sub(assets.SvelteFS, "frontend") if err != nil { log.Fatal(err) @@ -85,7 +67,7 @@ func (a *App) RunApp(configuration *config.Configuration) { router.Get("/swagger/*", swagger.HandlerDefault) } - if !configuration.Webserver.NoFrontend { + if config.ShowFrontend() { router.Use("/", filesystem.New(filesystem.Config{ Root: http.FS(publicFS), NotFoundFile: "index.html", @@ -94,8 +76,8 @@ func (a *App) RunApp(configuration *config.Configuration) { router.Use(Handle404) - serverPort := fmt.Sprintf(":%d", configuration.Webserver.Port) - log.Printf("server listens on %s\n", serverPort) + serverPort := fmt.Sprintf(":%d", config.GetWebserver().Port) + fmt.Println("_") router.Listen(serverPort) } diff --git a/services/backend/src/web-app/handler.go b/services/backend/src/web-app/handler.go index d6181fff..42c28917 100644 --- a/services/backend/src/web-app/handler.go +++ b/services/backend/src/web-app/handler.go @@ -14,8 +14,3 @@ type UserHandler interface { HandleUpdateUserData(c *fiber.Ctx) error HandleJWTRefresh(c *fiber.Ctx) error } - -type PasskeyHandler interface { - BeginWebAuthNRegistration(c *fiber.Ctx) error - FinishWebAuthNRegistration(c *fiber.Ctx) error -} diff --git a/services/backend/src/web-app/routes.go b/services/backend/src/web-app/routes.go index 6507f919..e9517a55 100644 --- a/services/backend/src/web-app/routes.go +++ b/services/backend/src/web-app/routes.go @@ -17,10 +17,6 @@ func (a *App) createRoutes(router *fiber.App) { apiV1 := api.Group("v1") - // FIDO2 - apiV1.Get("u2f/login", a.PasskeyHandler.BeginWebAuthNRegistration) - apiV1.Post("u2f/login", a.PasskeyHandler.FinishWebAuthNRegistration) - apiV1.Post("login", a.UserHandler.HandleLogin) apiV1.Post("logout", a.UserHandler.HandleLogout) @@ -31,10 +27,6 @@ func (a *App) createRoutes(router *fiber.App) { apiV1.Post("login/is-available-username", a.UserHandler.HandleCheckUsername) apiV1.Post("login/change-password", a.UserHandler.HandleChangePassword) - // FIDO2 - apiV1.Get("u2f/register", a.PasskeyHandler.BeginWebAuthNRegistration) - apiV1.Post("u2f/register", a.PasskeyHandler.FinishWebAuthNRegistration) - // own user operations apiV1.Get("self/get-user-data", a.UserHandler.HandleGetProfile) apiV1.Post("self/update-user-data", a.UserHandler.HandleUpdateUserData) diff --git a/services/frontend/package-lock.json b/services/frontend/package-lock.json index 7f80dc60..7a199bd5 100644 --- a/services/frontend/package-lock.json +++ b/services/frontend/package-lock.json @@ -2223,4 +2223,4 @@ "dev": true } } -} \ No newline at end of file +} diff --git a/services/frontend/static/favicon.ico b/services/frontend/static/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..9789f434e4864d0d437002b7621e249d325cf1d0 GIT binary patch literal 15406 zcmeI2*H0B&6vpS4clF`E^K|2*Pxtx$6Ic)x3&j>iNt6V!L}R1dm7-Vx(TEir*g>$y z0*Z=)g<^?sApmK(;H^+FDdpB>eMMYfBwAe+_}>`=eBLzWY?};l9rYx3l}bwy?giS{hmF0(|Tv{rhF#zJ1=gv$L}$DJjW&@AkD>2l|tPI=0J2p%)KX zXF|;RuQ^$t0v(GME&6@r$dL&q?hQXN_6^ANkv$+d900rh?fjWO_m^$&d;i~ReP(@T zG2n-R(W6JpwQJV~%rD6Q^y!mCL`3vihq$;nsjsisJy~sSt*l+UR(9{+Ezh1klgi3U znL2fo8|TE*K+gbP5pi6&K-I5=#gY*X6nA} z@#DvG{rYv8G-=XTdYb=2X=-Yc<;#~#V`HP_=jRJ^viIAvWsA1ckc>g+S=N5TtPvBynp{*X3m`XmHhGJ$IIu>pCu|PN;*0^ zWZbxMa{KmeS+#1F_GQla_;~s7;e$j*MoN2oyZVE<=gyrg>@lA{eJb+va%GX#IY;+zRzaQo~^pG&nEuF(RXj|_C0*~upBsWK=J9ezTU$Fo8Z?pH_y}b2}-Z zqg%O0*C9T-uQOxYdm0}s?bu;XbXLE6>>6zU4ZU@>4ZU@c1U@7xg;hg%9JTnWc&8*$~W-sA6~=dmEb?FT)Cp(`r$X= zyxe~rTU(Vgpbwl6ya#nZ3l=PpWy_Z7IQSd*jcL=S30wnpJUoMISiE?# z;Dgv=cbb+tJ26Uk9?AfzA9-apt}-n@CE^+j+!a4xRTy0U>be9L&a z9CSurY;3Ih9sE+$G-1L7)d3r*RifVN-Me>^oSZDwM!kLeR(U$=rg)y3nyQ$gwuyT< zA>zsW_=XxP_@YCH4#|ueGvvjK7ite24*n;0V2?VfF=NIA^gnG!jvUcEV}9zf@FiRf zF-Ko8<=T$lk%@e4gGWL>Tv|>}j&g;_g`Z>YS+i!TZ6{Bjl!+53sw_A)xHWi3a0Xx5 z+}x}fh9kl!*xb<2pmk#C;>!2GvMvxm_`W4emPl@Hu6+FXQRd8FP*g^dp`2+8X->?}Q$qRqIeecOt zYU{`ae!Cnkc|%^q+ro=db4RWaYy1zs@fVyizc*~ypqN2-I5u(>+;7~tQR9I<#120p zKRi5KmM&eYF(H3lE){5I)Qn7^Xk}u; z9erKBzD4f$>O;)X9Up=rxNGbn_rL+T2qX(^uqMzC9FWU_`u?cr{4Wqg)<>?yko6sG ztz5aX+clY7iH?reb&2(ZdVwFMr=8bwcNPN{0~P}o0~P}o0~Q0pj{&nk4BC2up77(* zy{xBxLEP@vLJXSP2iKSQ-kj8&Py?~f6N|y}Zb9wCI&}A`LBST{5w!W>(T$o1^*g%T K!+M}U9{3L>+p*37 literal 0 HcmV?d00001 From ca17f6f7b6ac4dbd4de6351462b794ed5410c968 Mon Sep 17 00:00:00 2001 From: Tim Riedl Date: Mon, 22 Apr 2024 23:09:00 +0200 Subject: [PATCH 27/31] fix: change host in ci for postgres host --- .github/workflows/execute-tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/execute-tests.yaml b/.github/workflows/execute-tests.yaml index 05b1eaa9..7591f247 100644 --- a/.github/workflows/execute-tests.yaml +++ b/.github/workflows/execute-tests.yaml @@ -45,7 +45,7 @@ jobs: if: ${{ always() }} run: make test-be-ci env: - APP_DATABASE_HOST: 127.0.0.1 + APP_DATABASE_HOST: postgres APP_DATABASE_PORT: 5432 APP_DATABASE_USERNAME: postgres APP_DATABASE_PASSWORD: postgres From d407ea4db823cd1b0f6cd9aae7416bf1276cc6d7 Mon Sep 17 00:00:00 2001 From: Tim Riedl Date: Mon, 22 Apr 2024 23:15:12 +0200 Subject: [PATCH 28/31] use own postgres server in ci --- .github/workflows/execute-tests.yaml | 30 +--------------------------- Makefile | 6 ------ 2 files changed, 1 insertion(+), 35 deletions(-) diff --git a/.github/workflows/execute-tests.yaml b/.github/workflows/execute-tests.yaml index 7591f247..2e443ec8 100644 --- a/.github/workflows/execute-tests.yaml +++ b/.github/workflows/execute-tests.yaml @@ -8,42 +8,14 @@ jobs: runs-on: ubuntu-latest continue-on-error: true - services: - postgres: - image: postgis/postgis - env: - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - POSTGRES_DB: postgres - PGDATA: /var/lib/postgresql/data/pgdata - ports: - - "5432:5432" - options: >- - --health-cmd pg_isready - --health-interval 10s - --health-timeout 5s - --health-retries 5 - steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Wait for Postgres to become available (max 20 seconds) - run: | - timeout 20 bash -c 'until pg_isready -h localhost -p 5432 -U postgres; do - echo "Waiting for PostgreSQL to become available..." - sleep 2 - done' - if ! pg_isready -h localhost -p 5432 -U postgres; then - echo "PostgreSQL is not available after 20 seconds." - exit 1 - fi - echo "PostgreSQL is available now." - - name: run backend tests if: ${{ always() }} - run: make test-be-ci + run: make test-be env: APP_DATABASE_HOST: postgres APP_DATABASE_PORT: 5432 diff --git a/Makefile b/Makefile index dc686d77..ab023d7e 100644 --- a/Makefile +++ b/Makefile @@ -17,12 +17,6 @@ test-be: ## run golang tests test-fe: ## run sveltekit tests @docker compose -f compose-dev.yaml up --abort-on-container-exit frontend-tests -test-be-ci: ## run golang tests in ci pipeline - @docker compose -f compose-dev.yaml up --abort-on-container-exit backend-tests-ci - -test-fe-ci: ## run sveltekit tests in ci pipeline - @docker compose -f compose-dev.yaml up --abort-on-container-exit frontend-tests-ci - build-dockerfile-binary: ## build one dockerimage that contains everything @bash ./devops/scripts/build-container/binary.sh From 3739dcf05e6cd53b704ed3c9a2ca8ab52936b5cf Mon Sep 17 00:00:00 2001 From: Tim Riedl Date: Mon, 22 Apr 2024 23:17:54 +0200 Subject: [PATCH 29/31] fix db migration file --- services/backend/src/migrator/migration-files/1_add_user.up.sql | 1 - 1 file changed, 1 deletion(-) diff --git a/services/backend/src/migrator/migration-files/1_add_user.up.sql b/services/backend/src/migrator/migration-files/1_add_user.up.sql index c15b9e96..74fcb880 100644 --- a/services/backend/src/migrator/migration-files/1_add_user.up.sql +++ b/services/backend/src/migrator/migration-files/1_add_user.up.sql @@ -57,7 +57,6 @@ INSERT INTO role_permissions (role_id, permission_id) VALUES ((SELECT id FROM roles WHERE name = 'User'), (SELECT id FROM permissions WHERE identifier = 'GREET_USER')), ((SELECT id FROM roles WHERE name = 'Admin'), (SELECT id FROM permissions WHERE identifier = 'GREET_ADMIN')), ((SELECT id FROM roles WHERE name = 'Admin'), (SELECT id FROM permissions WHERE identifier = 'MANAGE_USERS')); -dvdkgcridb -- password is default "123" INSERT INTO users (username, email, password, ldap_uuid, auth_source, role_id) VALUES From 5dca890c05324f46c609b0c8daeb3ee90021747d Mon Sep 17 00:00:00 2001 From: Tim Riedl Date: Mon, 22 Apr 2024 23:19:45 +0200 Subject: [PATCH 30/31] fix: frontend tests --- .github/workflows/execute-tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/execute-tests.yaml b/.github/workflows/execute-tests.yaml index 2e443ec8..a8005b34 100644 --- a/.github/workflows/execute-tests.yaml +++ b/.github/workflows/execute-tests.yaml @@ -35,7 +35,7 @@ jobs: - name: run frontend tests if: ${{ always() }} - run: make test-fe-ci + run: make test-fe test-result: runs-on: ubuntu-latest From f87e987ed965786522f9501b9c60a40896ca72ca Mon Sep 17 00:00:00 2001 From: Tim Riedl Date: Mon, 22 Apr 2024 23:45:10 +0200 Subject: [PATCH 31/31] remove frontend tests + iac code --- .github/workflows/execute-tests.yaml | 37 ++++-------- Makefile | 3 - .../base-applications/helmfile.yaml | 6 -- devops/deployments/makefile | 15 ----- .../server-infrastructure/.gitignore | 34 ----------- .../server-infrastructure/azure/.gitkeep | 0 .../server-infrastructure/civo/.gitignore | 1 - .../civo/.terraform.lock.hcl | 23 -------- .../server-infrastructure/civo/main.tf | 58 ------------------- .../server-infrastructure/civo/makefile | 15 ----- .../server-infrastructure/civo/packages.tf | 32 ---------- .../civo/terraform.tfvars.copy.txt | 14 ----- .../server-infrastructure/hetzner/.gitkeep | 0 13 files changed, 11 insertions(+), 227 deletions(-) delete mode 100644 devops/deployments/makefile delete mode 100644 devops/deployments/server-infrastructure/.gitignore delete mode 100644 devops/deployments/server-infrastructure/azure/.gitkeep delete mode 100644 devops/deployments/server-infrastructure/civo/.gitignore delete mode 100644 devops/deployments/server-infrastructure/civo/.terraform.lock.hcl delete mode 100644 devops/deployments/server-infrastructure/civo/main.tf delete mode 100644 devops/deployments/server-infrastructure/civo/makefile delete mode 100644 devops/deployments/server-infrastructure/civo/packages.tf delete mode 100644 devops/deployments/server-infrastructure/civo/terraform.tfvars.copy.txt delete mode 100644 devops/deployments/server-infrastructure/hetzner/.gitkeep diff --git a/.github/workflows/execute-tests.yaml b/.github/workflows/execute-tests.yaml index a8005b34..c0fc1971 100644 --- a/.github/workflows/execute-tests.yaml +++ b/.github/workflows/execute-tests.yaml @@ -6,7 +6,7 @@ on: jobs: test-backend: runs-on: ubuntu-latest - continue-on-error: true + # continue-on-error: true steps: - uses: actions/checkout@v4 @@ -24,30 +24,15 @@ jobs: APP_DATABASE_DATABASE: postgres APP_DATABASE_SSLMODE: False - test-frontend: - runs-on: ubuntu-latest - continue-on-error: true - - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 + # test-frontend: + # runs-on: ubuntu-latest + # continue-on-error: true - - name: run frontend tests - if: ${{ always() }} - run: make test-fe + # steps: + # - uses: actions/checkout@v4 + # with: + # fetch-depth: 0 - test-result: - runs-on: ubuntu-latest - needs: [test-backend, test-frontend] - if: ${{ always() }} - - steps: - - name: Check if any tests failed - run: | - if [ "${{ needs.test-backend.result }}" == "failure" ] || [ "${{ needs.test-frontend.result }}" == "failure" ]; then - echo "One or more tests failed." - exit 1 - else - echo "All tests passed." - fi + # - name: run frontend tests + # if: ${{ always() }} + # run: make test-fe diff --git a/Makefile b/Makefile index ab023d7e..4ecd34eb 100644 --- a/Makefile +++ b/Makefile @@ -26,9 +26,6 @@ build-dockerfile-frontend: ## build the frontend microservice build-dockerfile-backend: ## build the backend microservice @bash ./devops/scripts/build-container/backend.sh -act-create: - @act -W .github/workflows/infrastructure-as-code-create.yaml --container-architecture linux/amd64 --secret-file .secrets --input-file .input - help: ## print our all commands to commandline @echo "\033[34m" @echo " SvelteKit + Golang Example" diff --git a/devops/deployments/base-applications/helmfile.yaml b/devops/deployments/base-applications/helmfile.yaml index fba56d7f..d4d5da27 100644 --- a/devops/deployments/base-applications/helmfile.yaml +++ b/devops/deployments/base-applications/helmfile.yaml @@ -1,9 +1,3 @@ -environments: - civo-k3s: - - hetzner-microk8s: {} - azure-aks: {} - repositories: - name: ingress-nginx url: https://kubernetes.github.io/ingress-nginx diff --git a/devops/deployments/makefile b/devops/deployments/makefile deleted file mode 100644 index 18e3b4c3..00000000 --- a/devops/deployments/makefile +++ /dev/null @@ -1,15 +0,0 @@ -.PHONY: base-applications - -base-applications: - @(cd ./base-applications/ ; make run) - -infrastructure-civo: - @(cd server-infrastructure/civo/ ; make apply) - -# $(MAKE) base-applications - -destroy-infrastructure-civo: - @(cd server-infrastructure/civo/ ; make destroy) - -# infrastructure-hetzner: -# infrastructure-azure: diff --git a/devops/deployments/server-infrastructure/.gitignore b/devops/deployments/server-infrastructure/.gitignore deleted file mode 100644 index dc825268..00000000 --- a/devops/deployments/server-infrastructure/.gitignore +++ /dev/null @@ -1,34 +0,0 @@ -# Local .terraform directories -**/.terraform/* - -# .tfstate files -*.tfstate -*.tfstate.* - -# Crash log files -crash.log -crash.*.log - -# Exclude all .tfvars files, which are likely to contain sensitive data, such as -# password, private keys, and other secrets. These should not be part of version -# control as they are data points which are potentially sensitive and subject -# to change depending on the environment. -*.tfvars -*.tfvars.json - -# Ignore override files as they are usually used to override resources locally and so -# are not checked in -override.tf -override.tf.json -*_override.tf -*_override.tf.json - -# Include override files you do wish to add to version control using negated pattern -# !example_override.tf - -# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan -# example: *tfplan* - -# Ignore CLI configuration files -.terraformrc -terraform.rc \ No newline at end of file diff --git a/devops/deployments/server-infrastructure/azure/.gitkeep b/devops/deployments/server-infrastructure/azure/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/devops/deployments/server-infrastructure/civo/.gitignore b/devops/deployments/server-infrastructure/civo/.gitignore deleted file mode 100644 index 2eea525d..00000000 --- a/devops/deployments/server-infrastructure/civo/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.env \ No newline at end of file diff --git a/devops/deployments/server-infrastructure/civo/.terraform.lock.hcl b/devops/deployments/server-infrastructure/civo/.terraform.lock.hcl deleted file mode 100644 index 4deff345..00000000 --- a/devops/deployments/server-infrastructure/civo/.terraform.lock.hcl +++ /dev/null @@ -1,23 +0,0 @@ -# This file is maintained automatically by "terraform init". -# Manual edits may be lost in future updates. - -provider "registry.terraform.io/civo/civo" { - version = "1.0.39" - constraints = "1.0.39" - hashes = [ - "h1:q9Q9sgU/rz/i6LSrC1UIIe09ho7RIhuQy4PwONMK6aM=", - "zh:31be8b548cd947e295d36f15d06aa8639b341b4a5ab6d510b2d8ad3cdad5fd80", - "zh:487703dacda66ac26191995fb3de7a81f40e693811df4a4c4bbb5749683e3858", - "zh:581b7137edc725675ad6e5f3a793009a00426eadbaaad0998ce42b32762e46af", - "zh:67f3b8deacd0c8bed1a19f384d9b67870cb7e4c7264ce231de9fd4034722ca47", - "zh:6875b743ab015d6dc54a1f2188848cd2ac37e5fcc5fcf469cff68a5ae41defa4", - "zh:68f0d2a86ad23f7c413862de83630f5cada77bd24d93f47f3739e2a6c0892303", - "zh:8b7f7aa8a53ebe94b75a37966dd9f4553ae3c6beb27e239a55f480eb7e85bda8", - "zh:9f6b944dcfcc2bc492930025dd57544afabdbfb3aed2b56c1e2f898be8aa291f", - "zh:b4f8c6a9478ab53c399d75bb7b8c0d5c72ff66f74d8d6423f93d6f9caca1b04b", - "zh:b72e6856d9e4bc5d6ffba996d542aef96973011fd58fe464fda628477839634c", - "zh:bdbafdcb2bf07625a39c88cba465fd16b211a74a22d62341bd488d445784b840", - "zh:e027b42063702a470ba2d8f9e7af22edb0997051ab9deb7c4775c13e9aebe89f", - "zh:e16f7731c9f65a2467538ea4ac7b8f241cec0a4e4db04198f19f238d7e507b82", - ] -} diff --git a/devops/deployments/server-infrastructure/civo/main.tf b/devops/deployments/server-infrastructure/civo/main.tf deleted file mode 100644 index ad1cd1fd..00000000 --- a/devops/deployments/server-infrastructure/civo/main.tf +++ /dev/null @@ -1,58 +0,0 @@ -variable "civo_kubernetes_size" {} -variable "civo_kubernetes_count" {} - -# # Create Object Storage Credetials for Bucket to store backups -# data "civo_object_store_credential" "backup" { -# name = "application-backup-bucket-credentials" -# } - -# # Create Object Storage for Bucket to store backups -# resource "civo_object_store" "backup" { -# name = "application-backup-bucket" -# max_size_gb = 500 -# access_key_id = civo_object_store_credential.backup.access_key_id -# } - -# # Create a managaed Database -# resource "civo_database" "custom_database" { -# name = "custom_database" -# size = element(data.civo_size.small.sizes, 0).name -# nodes = 2 -# engine = element(data.civo_database_version.mysql.versions, 0).engine -# version = element(data.civo_database_version.mysql.versions, 0).version -# } - -# Create a firewall -resource "civo_firewall" "my-firewall" { - name = "application-firewall" -} - -# Create a firewall rule -resource "civo_firewall_rule" "kubernetes" { - firewall_id = civo_firewall.my-firewall.id - protocol = "tcp" - start_port = "6443" - end_port = "6443" - cidr = ["0.0.0.0/0"] - direction = "ingress" - label = "kubernetes-api-server" - action = "allow" -} - -# Create a cluster with k3s -resource "civo_kubernetes_cluster" "my-cluster" { - name = "my-cluster" - # applications = "Portainer,Linkerd:Linkerd & Jaeger" - firewall_id = civo_firewall.my-firewall.id - cluster_type = "k3s" - pools { - label = "myapplication" // Optional - size = var.civo_kubernetes_size - node_count = var.civo_kubernetes_count - } -} - -output "k8skubeconfig" { - sensitive = true - value = civo_kubernetes_cluster.my-cluster.kubeconfig -} diff --git a/devops/deployments/server-infrastructure/civo/makefile b/devops/deployments/server-infrastructure/civo/makefile deleted file mode 100644 index 7866a1a1..00000000 --- a/devops/deployments/server-infrastructure/civo/makefile +++ /dev/null @@ -1,15 +0,0 @@ -apply: - terraform init \ - -backend-config='bucket=iac-storage' \ - -backend-config='key=terraform.tfstate' \ - -backend-config='access_key=' \ - -backend-config='secret_key=' - @terraform apply -auto-approve - @terraform output -raw k8skubeconfig > ../../.ci-pipeline/k8s.civo.config - @chmod 600 ../../.ci-pipeline/k8s.civo.config - -destroy: - @terraform init - @terraform destroy -auto-approve - - diff --git a/devops/deployments/server-infrastructure/civo/packages.tf b/devops/deployments/server-infrastructure/civo/packages.tf deleted file mode 100644 index 59337a07..00000000 --- a/devops/deployments/server-infrastructure/civo/packages.tf +++ /dev/null @@ -1,32 +0,0 @@ -variable "civo_token" { type = string } -variable "civo_region" { type = string } - -terraform { - backend "s3" { - endpoints { - s3 = "https://objectstore.fra1.civo.com/" - } - bucket = "" - key = "" - region = "FRA1" - skip_region_validation = true - skip_credentials_validation = true - skip_requesting_account_id = true - skip_metadata_api_check = true - use_path_style = true - # access_key = var.tfbackend_objectstorage_accesskey - # secret_key = var.tfbackend_objectstorage_secretkey - } - - required_providers { - civo = { - source = "civo/civo" - version = "1.0.39" - } - } -} - -provider "civo" { - token = var.civo_token - region = var.civo_region -} diff --git a/devops/deployments/server-infrastructure/civo/terraform.tfvars.copy.txt b/devops/deployments/server-infrastructure/civo/terraform.tfvars.copy.txt deleted file mode 100644 index fe86f064..00000000 --- a/devops/deployments/server-infrastructure/civo/terraform.tfvars.copy.txt +++ /dev/null @@ -1,14 +0,0 @@ -# terraform backend -tfbackend_objectstorage_bucketurl = "" -tfbackend_objectstorage_bucketkey = "terraform.tfstate" -tfbackend_objectstorage_bucketname = "iac-storage" -tfbackend_objectstorage_accesskey = "" -tfbackend_objectstorage_secretkey = "" - -# civo settings -# civo_token = "" -civo_region = "FRA1" - -# civo cluster -civo_kubernetes_size = "g4s.kube.small" -civo_kubernetes_count = 2 diff --git a/devops/deployments/server-infrastructure/hetzner/.gitkeep b/devops/deployments/server-infrastructure/hetzner/.gitkeep deleted file mode 100644 index e69de29b..00000000