Skip to content

Refactor to Kubernetes and Helm setup #263

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: listOfMed
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions .github/workflows/cd-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# .github/workflows/cd-deploy.yml
name: CD – Build, Push & Deploy

on:
push:
branches: [ listOfMed ]

permissions:
contents: read
packages: write

env:
IMAGE_REG: ghcr.io/${{ github.repository_owner }}

jobs:
build:
name: Build & Push Production Images
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.set-vars.outputs.TAG }}
steps:
- uses: actions/checkout@v3

- name: Set version tag
id: set-vars
run: |
# e.g. v1.2.3 or commit SHA fallback
if [[ "${GITHUB_REF##*/}" =~ ^v[0-9] ]]; then
echo "TAG=${GITHUB_REF##*/}" >> $GITHUB_OUTPUT
else
echo "TAG=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
fi

- name: Login to registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build & push backend
uses: docker/build-push-action@v3
with:
context: server
file: server/Dockerfile.prod
push: true
tags: |
${{ env.IMAGE_REG }}/balancer-backend:${{ needs.build.outputs.tag }}
${{ env.IMAGE_REG }}/balancer-backend:latest

- name: Build & push frontend
uses: docker/build-push-action@v3
with:
context: frontend
file: frontend/Dockerfile
push: true
tags: |
${{ env.IMAGE_REG }}/balancer-frontend:${{ needs.build.outputs.tag }}
${{ env.IMAGE_REG }}/balancer-frontend:latest

# deploy:
# name: Deploy to Kubernetes
# needs: build
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3

# - name: Set up kubectl
# # or use azure/setup-kubectl, google-github-actions/setup-gcloud, etc.
# uses: azure/setup-kubectl@v3
# with:
# version: 'latest'
# # supply your kubeconfig via a secret
# kubeconfig: ${{ secrets.KUBE_CONFIG_DATA }}

# - name: Update Helm chart values
# run: |
# helm upgrade --install balancer ./charts/balancer \
# --namespace production \
# --create-namespace \
# --set backend.image.tag=${{ needs.build.outputs.tag }} \
# --set frontend.image.tag=${{ needs.build.outputs.tag }}
49 changes: 49 additions & 0 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: CI – Build & Push PR Images

on:
pull_request:
branches: [ listOfMed ]

permissions:
contents: read
packages: write

jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Compute lowercase owner
id: vars
run: |
owner=$(echo "$GITHUB_REPOSITORY_OWNER" | tr '[:upper:]' '[:lower:]')
echo "owner=$owner" >> $GITHUB_OUTPUT

- name: Log in to registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ steps.vars.outputs.owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build & push backend
uses: docker/build-push-action@v3
with:
context: server
file: server/Dockerfile.prod
push: true
tags: |
ghcr.io/${{ steps.vars.outputs.owner }}/balancer-backend:pr-${{ github.event.number }}
ghcr.io/${{ steps.vars.outputs.owner }}/balancer-backend:pr-${{ github.event.number }}-latest

- name: Build & push frontend
uses: docker/build-push-action@v3
with:
context: frontend
file: frontend/Dockerfile
push: true
tags: |
ghcr.io/${{ steps.vars.outputs.owner }}/balancer-frontend:pr-${{ github.event.number }}
ghcr.io/${{ steps.vars.outputs.owner }}/balancer-frontend:pr-${{ github.event.number }}-latest
69 changes: 0 additions & 69 deletions .github/workflows/containers-publish.yml

This file was deleted.

18 changes: 0 additions & 18 deletions .github/workflows/release-prepare.yml

This file was deleted.

14 changes: 0 additions & 14 deletions .github/workflows/release-publish.yml

This file was deleted.

14 changes: 0 additions & 14 deletions .github/workflows/release-validate.yml

This file was deleted.

10 changes: 2 additions & 8 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,11 @@ services:
image: balancer-frontend
build:
context: frontend
dockerfile: Dockerfile
dockerfile: Dockerfile.prod
args:
- IMAGE_NAME=balancer-frontend
ports:
- "3000:3000"
environment:
- CHOKIDAR_USEPOLLING=true
- VITE_API_BASE_URL=https://balancertestsite.com/
volumes:
- "./frontend:/usr/src/app:delegated"
- "/usr/src/app/node_modules/"
- "80:80"
depends_on:
- backend

Expand Down
6 changes: 3 additions & 3 deletions frontend/Dockerfile.prod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:18 as builder
FROM node:23-slim AS builder

WORKDIR /usr/src/app

Expand All @@ -10,10 +10,10 @@ COPY . .

RUN npm run build

FROM nginx:latest
FROM nginx:stable-alpine

COPY nginx.conf /etc/nginx/conf.d/default.conf

COPY --from=builder /usr/src/app/build /usr/share/nginx/html
COPY --from=builder /usr/src/app/dist /usr/share/nginx/html

EXPOSE 80
10 changes: 10 additions & 0 deletions frontend/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,14 @@ server {
index index.html;
try_files $uri $uri/ /index.html;
}

# Proxy API requests to the backend container
location /api/ {
proxy_pass http://backend:8000/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
2 changes: 0 additions & 2 deletions frontend/src/api/apiClient.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import axios from "axios";
import { FormValues } from "../pages/Feedback/FeedbackForm";
import { Conversation } from "../components/Header/Chat";
const baseURL = import.meta.env.VITE_API_BASE_URL;

export const api = axios.create({
baseURL,
headers: {
Authorization: `JWT ${localStorage.getItem("access")}`,
},
Expand Down
8 changes: 0 additions & 8 deletions frontend/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";

// https://vitejs.dev/config/
export default defineConfig({
build: {
outDir: '../server/build', // Custom output directory
assetsDir: 'static',
},
plugins: [react()],
server: {
watch: {
usePolling: true,
},
host: "0.0.0.0",
strictPort: true,
port: 3000,
},
});
9 changes: 0 additions & 9 deletions helm-chart/Chart.yaml

This file was deleted.

Loading