From 794e314fa7ae6fb50cc3ae9a83008ff41ba7783d Mon Sep 17 00:00:00 2001 From: Jose Henrique Date: Fri, 20 Mar 2026 21:26:05 -0300 Subject: [PATCH] adding new project pipelines --- .gitea/workflows/mindforge-api.yaml | 84 ++++++++++++++++++++++++ .gitea/workflows/mindforge-web.yaml | 86 +++++++++++++++++++++++++ Mindforge.API/Dockerfile | 21 ++++++ Mindforge.API/deploy/mindforge-api.yaml | 51 +++++++++++++++ Mindforge.Web/Dockerfile | 15 +++++ Mindforge.Web/deploy/mindforge-web.yaml | 40 ++++++++++++ 6 files changed, 297 insertions(+) create mode 100644 .gitea/workflows/mindforge-api.yaml create mode 100644 .gitea/workflows/mindforge-web.yaml create mode 100644 Mindforge.API/Dockerfile create mode 100644 Mindforge.API/deploy/mindforge-api.yaml create mode 100644 Mindforge.Web/Dockerfile create mode 100644 Mindforge.Web/deploy/mindforge-web.yaml diff --git a/.gitea/workflows/mindforge-api.yaml b/.gitea/workflows/mindforge-api.yaml new file mode 100644 index 0000000..ab5ce76 --- /dev/null +++ b/.gitea/workflows/mindforge-api.yaml @@ -0,0 +1,84 @@ +name: Mindforge API Build and Deploy + +on: + push: + branches: + - main + paths: + - "Mindforge.API/**" + - ".gitea/workflows/**" + workflow_dispatch: {} + +env: + REGISTRY_HOST: git.ivanch.me + REGISTRY_USERNAME: ivanch + IMAGE_API: ${{ env.REGISTRY_HOST }}/ivanch/mindforge-api + KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }} + +jobs: + build_mindforge_api: + name: Build Mindforge API Image + runs-on: ubuntu-22.04 + + steps: + - name: Check out repository + uses: actions/checkout@v2 + + - name: Log in to Container Registry + run: | + echo "${{ secrets.REGISTRY_PASSWORD }}" \ + | docker login "${{ env.REGISTRY_HOST }}" \ + -u "${{ env.REGISTRY_USERNAME }}" \ + --password-stdin + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and Push Multi-Arch Image + uses: docker/build-push-action@v6 + with: + push: true + context: Mindforge.API + platforms: linux/amd64,linux/arm64 + tags: | + ${{ env.IMAGE_API }}:latest + + deploy_mindforge_api: + name: Deploy Mindforge API (internal) + runs-on: ubuntu-amd64 + needs: build_mindforge_api + steps: + - name: Check KUBE_CONFIG validity + run: | + if [ -z "${KUBE_CONFIG}" ] || [ "${KUBE_CONFIG}" = "" ] || [ "${KUBE_CONFIG// }" = "" ]; then + echo "KUBE_CONFIG is not set or is empty." + exit 1 + fi + + - name: Check out repository + uses: actions/checkout@v2 + + - name: Download and install dependencies + run: | + apt-get update -y + apt-get install -y curl + curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" + install -m 0755 kubectl /usr/local/bin/kubectl + kubectl version --client + + - name: Set up kubeconfig + run: | + cd Mindforge.API/deploy + echo "$KUBE_CONFIG" > kubeconfig.yaml + env: + KUBE_CONFIG: ${{ env.KUBE_CONFIG }} + + - name: Check connection to cluster + run: | + cd Mindforge.API/deploy + kubectl --kubeconfig=kubeconfig.yaml cluster-info + + - name: Apply mindforge-api deployment + run: | + cd Mindforge.API/deploy + kubectl --kubeconfig=kubeconfig.yaml apply -f mindforge-api.yaml diff --git a/.gitea/workflows/mindforge-web.yaml b/.gitea/workflows/mindforge-web.yaml new file mode 100644 index 0000000..6370105 --- /dev/null +++ b/.gitea/workflows/mindforge-web.yaml @@ -0,0 +1,86 @@ +name: Mindforge Web Build and Deploy + +on: + push: + branches: + - main + paths: + - "Mindforge.Web/**" + - ".gitea/workflows/**" + workflow_dispatch: {} + +env: + REGISTRY_HOST: git.ivanch.me + REGISTRY_USERNAME: ivanch + IMAGE_WEB: ${{ env.REGISTRY_HOST }}/ivanch/mindforge-web + KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }} + +jobs: + build_mindforge_web: + name: Build Mindforge Web Image + runs-on: ubuntu-22.04 + + steps: + - name: Check out repository + uses: actions/checkout@v2 + + - name: Log in to Container Registry + run: | + echo "${{ secrets.REGISTRY_PASSWORD }}" \ + | docker login "${{ env.REGISTRY_HOST }}" \ + -u "${{ env.REGISTRY_USERNAME }}" \ + --password-stdin + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and Push Multi-Arch Image + uses: docker/build-push-action@v6 + with: + push: true + context: Mindforge.Web + platforms: linux/amd64,linux/arm64 + build-args: | + VITE_API_BASE_URL=${{ secrets.VITE_API_BASE_URL }} + tags: | + ${{ env.IMAGE_WEB }}:latest + + deploy_mindforge_web: + name: Deploy Mindforge Web (internal) + runs-on: ubuntu-amd64 + needs: build_mindforge_web + steps: + - name: Check KUBE_CONFIG validity + run: | + if [ -z "${KUBE_CONFIG}" ] || [ "${KUBE_CONFIG}" = "" ] || [ "${KUBE_CONFIG// }" = "" ]; then + echo "KUBE_CONFIG is not set or is empty." + exit 1 + fi + + - name: Check out repository + uses: actions/checkout@v2 + + - name: Download and install dependencies + run: | + apt-get update -y + apt-get install -y curl + curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" + install -m 0755 kubectl /usr/local/bin/kubectl + kubectl version --client + + - name: Set up kubeconfig + run: | + cd Mindforge.Web/deploy + echo "$KUBE_CONFIG" > kubeconfig.yaml + env: + KUBE_CONFIG: ${{ env.KUBE_CONFIG }} + + - name: Check connection to cluster + run: | + cd Mindforge.Web/deploy + kubectl --kubeconfig=kubeconfig.yaml cluster-info + + - name: Apply mindforge-web deployment + run: | + cd Mindforge.Web/deploy + kubectl --kubeconfig=kubeconfig.yaml apply -f mindforge-web.yaml diff --git a/Mindforge.API/Dockerfile b/Mindforge.API/Dockerfile new file mode 100644 index 0000000..93042f2 --- /dev/null +++ b/Mindforge.API/Dockerfile @@ -0,0 +1,21 @@ +FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:9.0-alpine AS builder + +ARG TARGETARCH +ARG TARGETOS + +WORKDIR /app +COPY Mindforge.API.csproj ./ +RUN dotnet restore -a $TARGETARCH +COPY . . +RUN dotnet publish -c Release -a $TARGETARCH --no-restore -o /app/publish + +FROM mcr.microsoft.com/dotnet/aspnet:9.0-alpine +WORKDIR /app +COPY --from=builder /app/publish . + +ENV ASPNETCORE_URLS=http://+:8080 +ENV OPENAI_API_KEY="" +ENV GEMINI_API_KEY="" + +EXPOSE 8080 +ENTRYPOINT ["dotnet", "Mindforge.API.dll"] diff --git a/Mindforge.API/deploy/mindforge-api.yaml b/Mindforge.API/deploy/mindforge-api.yaml new file mode 100644 index 0000000..08bdbf6 --- /dev/null +++ b/Mindforge.API/deploy/mindforge-api.yaml @@ -0,0 +1,51 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: mindforge-api + namespace: mindforge +spec: + replicas: 1 + selector: + matchLabels: + app: mindforge-api + template: + metadata: + labels: + app: mindforge-api + spec: + containers: + - name: mindforge-api + image: git.ivanch.me/ivanch/mindforge-api:latest + imagePullPolicy: Always + ports: + - containerPort: 8080 + env: + - name: OPENAI_API_KEY + valueFrom: + secretKeyRef: + name: mindforge-secrets + key: OPENAI_API_KEY + - name: GEMINI_API_KEY + valueFrom: + secretKeyRef: + name: mindforge-secrets + key: GEMINI_API_KEY + resources: + requests: + memory: "128Mi" + cpu: "250m" + limits: + memory: "512Mi" + cpu: "1" +--- +apiVersion: v1 +kind: Service +metadata: + name: mindforge-api + namespace: mindforge +spec: + selector: + app: mindforge-api + ports: + - port: 80 + targetPort: 8080 diff --git a/Mindforge.Web/Dockerfile b/Mindforge.Web/Dockerfile new file mode 100644 index 0000000..2e82117 --- /dev/null +++ b/Mindforge.Web/Dockerfile @@ -0,0 +1,15 @@ +FROM node:22-alpine AS builder + +ARG VITE_API_BASE_URL +ENV VITE_API_BASE_URL=${VITE_API_BASE_URL} + +WORKDIR /app +COPY package.json package-lock.json ./ +RUN npm ci +COPY . . +RUN npm run build + +FROM nginx:alpine +COPY --from=builder /app/dist /usr/share/nginx/html +EXPOSE 80 +CMD ["nginx", "-g", "daemon off;"] diff --git a/Mindforge.Web/deploy/mindforge-web.yaml b/Mindforge.Web/deploy/mindforge-web.yaml new file mode 100644 index 0000000..19816c6 --- /dev/null +++ b/Mindforge.Web/deploy/mindforge-web.yaml @@ -0,0 +1,40 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: mindforge-web + namespace: mindforge +spec: + replicas: 1 + selector: + matchLabels: + app: mindforge-web + template: + metadata: + labels: + app: mindforge-web + spec: + containers: + - name: mindforge-web + image: git.ivanch.me/ivanch/mindforge-web:latest + imagePullPolicy: Always + ports: + - containerPort: 80 + resources: + requests: + memory: "32Mi" + cpu: "100m" + limits: + memory: "128Mi" + cpu: "250m" +--- +apiVersion: v1 +kind: Service +metadata: + name: mindforge-web + namespace: mindforge +spec: + selector: + app: mindforge-web + ports: + - port: 80 + targetPort: 80