feat: Implement initial Helm charts for backend and frontend, Gitea CI/CD pipeline, and Coder workspace configuration.
Some checks failed
Build and Deploy / build-and-deploy (push) Has been cancelled
Some checks failed
Build and Deploy / build-and-deploy (push) Has been cancelled
This commit is contained in:
@@ -15,39 +15,39 @@ jobs:
|
|||||||
# -----------------------------------------------------------------
|
# -----------------------------------------------------------------
|
||||||
# CI PART
|
# CI PART
|
||||||
# -----------------------------------------------------------------
|
# -----------------------------------------------------------------
|
||||||
- name: Setup Docker Buildx
|
# -----------------------------------------------------------------
|
||||||
uses: docker/setup-buildx-action@v3
|
# CI PART (Kaniko)
|
||||||
|
# -----------------------------------------------------------------
|
||||||
- name: Docker Login (Gitea Registry)
|
- name: Create Docker Config
|
||||||
uses: docker/login-action@v3
|
run: |
|
||||||
with:
|
mkdir -p ${{ github.workspace }}/.docker
|
||||||
registry: ${{ vars.GITEA_REGISTRY_URL }}
|
echo "{\"auths\":{\"${{ vars.GITEA_REGISTRY_URL }}\":{\"username\":\"${{ secrets.GITEA_REGISTRY_USERNAME }}\",\"password\":\"${{ secrets.GITEA_REGISTRY_PASSWORD }}\"}}}" > ${{ github.workspace }}/.docker/config.json
|
||||||
username: ${{ secrets.GITEA_REGISTRY_USERNAME }}
|
|
||||||
password: ${{ secrets.GITEA_REGISTRY_PASSWORD }}
|
|
||||||
|
|
||||||
# BACKEND BUILD & PUSH
|
# BACKEND BUILD & PUSH
|
||||||
- name: Build and Push Backend
|
- name: Build and Push Backend
|
||||||
id: docker_build_backend
|
uses: docker://gcr.io/kaniko-project/executor:v1.14.0-debug
|
||||||
uses: docker/build-push-action@v5
|
env:
|
||||||
|
DOCKER_CONFIG: /github/workspace/.docker
|
||||||
with:
|
with:
|
||||||
context: ./backend
|
args: >
|
||||||
push: true
|
--context=dir:///github/workspace/backend
|
||||||
tags: ${{ vars.GITEA_REGISTRY_URL }}/${{ github.repository }}/backend:latest
|
--dockerfile=Dockerfile
|
||||||
platforms: linux/amd64,linux/arm64
|
--destination=${{ vars.GITEA_REGISTRY_URL }}/${{ github.repository }}/backend:latest
|
||||||
cache-from: type=gha
|
--cache=true
|
||||||
cache-to: type=gha,mode=max
|
--custom-platform=linux/arm64
|
||||||
|
|
||||||
# FRONTEND BUILD & PUSH
|
# FRONTEND BUILD & PUSH
|
||||||
- name: Build and Push Frontend
|
- name: Build and Push Frontend
|
||||||
id: docker_build_frontend
|
uses: docker://gcr.io/kaniko-project/executor:v1.14.0-debug
|
||||||
uses: docker/build-push-action@v5
|
env:
|
||||||
|
DOCKER_CONFIG: /github/workspace/.docker
|
||||||
with:
|
with:
|
||||||
context: ./frontend
|
args: >
|
||||||
push: true
|
--context=dir:///github/workspace/frontend
|
||||||
tags: ${{ vars.GITEA_REGISTRY_URL }}/${{ github.repository }}/frontend:latest
|
--dockerfile=Dockerfile
|
||||||
platforms: linux/amd64,linux/arm64
|
--destination=${{ vars.GITEA_REGISTRY_URL }}/${{ github.repository }}/frontend:latest
|
||||||
cache-from: type=gha
|
--cache=true
|
||||||
cache-to: type=gha,mode=max
|
--custom-platform=linux/arm64
|
||||||
|
|
||||||
# -----------------------------------------------------------------
|
# -----------------------------------------------------------------
|
||||||
# CD PART (HELM)
|
# CD PART (HELM)
|
||||||
|
|||||||
155
coder/main.tf
Normal file
155
coder/main.tf
Normal file
@@ -0,0 +1,155 @@
|
|||||||
|
terraform {
|
||||||
|
required_providers {
|
||||||
|
coder = {
|
||||||
|
source = "coder/coder"
|
||||||
|
version = "~> 0.12.0"
|
||||||
|
}
|
||||||
|
kubernetes = {
|
||||||
|
source = "hashicorp/kubernetes"
|
||||||
|
version = "~> 2.23"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
provider "coder" {}
|
||||||
|
|
||||||
|
variable "use_kubeconfig" {
|
||||||
|
type = bool
|
||||||
|
description = "Use kubeconfig instead of in-cluster config"
|
||||||
|
default = false
|
||||||
|
}
|
||||||
|
|
||||||
|
provider "kubernetes" {
|
||||||
|
# If running inside the cluster, this will use the service account token.
|
||||||
|
# If running locally for dev, set use_kubeconfig = true
|
||||||
|
config_path = var.use_kubeconfig ? "~/.kube/config" : null
|
||||||
|
}
|
||||||
|
|
||||||
|
data "coder_workspace" "me" {}
|
||||||
|
|
||||||
|
resource "coder_agent" "main" {
|
||||||
|
arch = "arm64"
|
||||||
|
os = "linux"
|
||||||
|
startup_script = <<EOT
|
||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Install basic tools
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y curl git unzip nano wget
|
||||||
|
|
||||||
|
# Install Go (ARM64)
|
||||||
|
wget https://go.dev/dl/go1.21.5.linux-arm64.tar.gz
|
||||||
|
sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go1.21.5.linux-arm64.tar.gz
|
||||||
|
export PATH=$PATH:/usr/local/go/bin
|
||||||
|
echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.bashrc
|
||||||
|
|
||||||
|
# Install Node.js (via NVM or direct) - Installing Node 20 LTS for ARM64
|
||||||
|
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
|
||||||
|
sudo apt-get install -y nodejs
|
||||||
|
|
||||||
|
# Configure Git to use the token
|
||||||
|
git config --global credential.helper store
|
||||||
|
# We can't easily inject the password here without a secret, but we can setup the user
|
||||||
|
git config --global user.name "${data.coder_workspace.me.owner}"
|
||||||
|
git config --global user.email "${data.coder_workspace.me.owner_email}"
|
||||||
|
|
||||||
|
# Clone repo if not exists
|
||||||
|
if [ ! -d "~/evrak" ]; then
|
||||||
|
git clone https://git.konstantiniyye.studio/muhammed/evrak.git ~/evrak
|
||||||
|
fi
|
||||||
|
EOT
|
||||||
|
|
||||||
|
# These environment variables are available in the workspace
|
||||||
|
env = {
|
||||||
|
GIT_AUTHOR_NAME = "${data.coder_workspace.me.owner}"
|
||||||
|
GIT_COMMITTER_NAME = "${data.coder_workspace.me.owner}"
|
||||||
|
GIT_AUTHOR_EMAIL = "${data.coder_workspace.me.owner_email}"
|
||||||
|
GIT_COMMITTER_EMAIL = "${data.coder_workspace.me.owner_email}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "kubernetes_persistent_volume_claim" "home" {
|
||||||
|
metadata {
|
||||||
|
name = "coder-${data.coder_workspace.me.owner}-${data.coder_workspace.me.name}-home"
|
||||||
|
namespace = "default" # Adjust if Coder runs in a different namespace or if you want workspaces elsewhere
|
||||||
|
labels = {
|
||||||
|
"app.kubernetes.io/name" = "coder-pvc"
|
||||||
|
"app.kubernetes.io/instance" = "coder-pvc-${data.coder_workspace.me.owner}-${data.coder_workspace.me.name}"
|
||||||
|
"app.kubernetes.io/part-of" = "coder"
|
||||||
|
"app.kubernetes.io/managed-by" = "coder"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
wait_until_bound = false
|
||||||
|
spec {
|
||||||
|
access_modes = ["ReadWriteOnce"]
|
||||||
|
resources {
|
||||||
|
requests = {
|
||||||
|
storage = "10Gi"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "kubernetes_pod" "main" {
|
||||||
|
count = data.coder_workspace.me.start_count
|
||||||
|
metadata {
|
||||||
|
name = "coder-${data.coder_workspace.me.owner}-${data.coder_workspace.me.name}"
|
||||||
|
namespace = "default"
|
||||||
|
}
|
||||||
|
spec {
|
||||||
|
security_context {
|
||||||
|
run_as_user = 1000
|
||||||
|
fs_group = 1000
|
||||||
|
}
|
||||||
|
|
||||||
|
container {
|
||||||
|
name = "dev"
|
||||||
|
image = "ubuntu:22.04"
|
||||||
|
command = ["sh", "-c", coder_agent.main.init_script]
|
||||||
|
security_context {
|
||||||
|
run_as_user = 1000
|
||||||
|
}
|
||||||
|
env {
|
||||||
|
name = "CODER_AGENT_TOKEN"
|
||||||
|
value = coder_agent.main.token
|
||||||
|
}
|
||||||
|
resources {
|
||||||
|
requests = {
|
||||||
|
"cpu" = "250m"
|
||||||
|
"memory" = "512Mi"
|
||||||
|
}
|
||||||
|
limits = {
|
||||||
|
"cpu" = "2"
|
||||||
|
"memory" = "4Gi"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
volume_mount {
|
||||||
|
mount_path = "/home/coder"
|
||||||
|
name = "home"
|
||||||
|
read_only = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
volume {
|
||||||
|
name = "home"
|
||||||
|
persistent_volume_claim {
|
||||||
|
claim_name = kubernetes_persistent_volume_claim.home.metadata.0.name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
affinity {
|
||||||
|
node_affinity {
|
||||||
|
required_during_scheduling_ignored_during_execution {
|
||||||
|
node_selector_term {
|
||||||
|
match_expressions {
|
||||||
|
key = "kubernetes.io/arch"
|
||||||
|
operator = "In"
|
||||||
|
values = ["arm64"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,6 +17,10 @@ spec:
|
|||||||
{{- include "evrak.selectorLabels" . | nindent 8 }}
|
{{- include "evrak.selectorLabels" . | nindent 8 }}
|
||||||
app.kubernetes.io/component: backend
|
app.kubernetes.io/component: backend
|
||||||
spec:
|
spec:
|
||||||
|
{{- with .Values.backend.nodeSelector }}
|
||||||
|
nodeSelector:
|
||||||
|
{{- toYaml . | nindent 8 }}
|
||||||
|
{{- end }}
|
||||||
containers:
|
containers:
|
||||||
- name: backend
|
- name: backend
|
||||||
image: "{{ .Values.backend.image.repository }}:{{ .Values.backend.image.tag }}"
|
image: "{{ .Values.backend.image.repository }}:{{ .Values.backend.image.tag }}"
|
||||||
|
|||||||
@@ -17,6 +17,10 @@ spec:
|
|||||||
{{- include "evrak.selectorLabels" . | nindent 8 }}
|
{{- include "evrak.selectorLabels" . | nindent 8 }}
|
||||||
app.kubernetes.io/component: frontend
|
app.kubernetes.io/component: frontend
|
||||||
spec:
|
spec:
|
||||||
|
{{- with .Values.frontend.nodeSelector }}
|
||||||
|
nodeSelector:
|
||||||
|
{{- toYaml . | nindent 8 }}
|
||||||
|
{{- end }}
|
||||||
containers:
|
containers:
|
||||||
- name: frontend
|
- name: frontend
|
||||||
image: "{{ .Values.frontend.image.repository }}:{{ .Values.frontend.image.tag }}"
|
image: "{{ .Values.frontend.image.repository }}:{{ .Values.frontend.image.tag }}"
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ backend:
|
|||||||
dbPort: 5432
|
dbPort: 5432
|
||||||
dbDatabase: evrak
|
dbDatabase: evrak
|
||||||
# dbHost, dbUsername, dbPassword will be injected via secrets/templates
|
# dbHost, dbUsername, dbPassword will be injected via secrets/templates
|
||||||
|
nodeSelector:
|
||||||
|
kubernetes.io/hostname: instance-20251124-1624-mzi
|
||||||
|
|
||||||
frontend:
|
frontend:
|
||||||
image:
|
image:
|
||||||
@@ -22,6 +24,8 @@ frontend:
|
|||||||
replicas: 1
|
replicas: 1
|
||||||
service:
|
service:
|
||||||
port: 80
|
port: 80
|
||||||
|
nodeSelector:
|
||||||
|
kubernetes.io/hostname: instance-20251124-1624-mzi
|
||||||
|
|
||||||
postgres:
|
postgres:
|
||||||
image:
|
image:
|
||||||
|
|||||||
Reference in New Issue
Block a user