Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
4ef5130
Create main.yml (#2)
Olsgaard1 Aug 14, 2025
c7056bb
Inserted dockerfiles for backend and frontend
mathiasoverby Aug 14, 2025
b7c2a3b
dockerfiles added
mathiasoverby Aug 14, 2025
f74b82b
Merge pull request #6 from albla20/dockerfile
mathiasoverby Aug 14, 2025
6557da1
added Manifests waiting for images (#7)
Olsgaard1 Aug 14, 2025
ce89813
dockerfile update
mathiasoverby Aug 14, 2025
6ec0b28
Merge pull request #8 from albla20/main
mathiasoverby Aug 14, 2025
ed02ddb
Create docker.yml
albla20 Aug 14, 2025
1ca554a
Merge branch 'main' into albla20-patch-1
albla20 Aug 14, 2025
18694e5
Merge pull request #9 from albla20/albla20-patch-1
albla20 Aug 14, 2025
8076d41
updated docker files and spinned up pods
mathiasoverby Aug 14, 2025
faa8b41
Update main.yml
mathiasoverby Aug 14, 2025
2cf0670
Update main.yml
mathiasoverby Aug 14, 2025
806871a
Merge branch 'main' into dockerfile
mathiasoverby Aug 14, 2025
ed79180
Merge pull request #12 from albla20/dockerfile
mathiasoverby Aug 14, 2025
bc1de6c
Merge branch 'main' into mathiasoverby-patch-2
mathiasoverby Aug 14, 2025
ea30e9e
Update main.yml
mathiasoverby Aug 14, 2025
f37f949
Update main.yml
mathiasoverby Aug 14, 2025
9680c4e
Update main.yml
mathiasoverby Aug 14, 2025
c07ec99
Update main.yml
mathiasoverby Aug 14, 2025
22f4dd5
Update main.yml
mathiasoverby Aug 14, 2025
6e54a45
Update main.yml
mathiasoverby Aug 14, 2025
da63a56
Update main.yml
mathiasoverby Aug 14, 2025
297b424
Update main.yml
mathiasoverby Aug 14, 2025
af43981
Update Dockerfile
mathiasoverby Aug 14, 2025
eb34902
Update Dockerfile
mathiasoverby Aug 14, 2025
5c91664
Update main.yml
mathiasoverby Aug 14, 2025
5037738
Update main.yml
mathiasoverby Aug 14, 2025
2926929
Update main.yml
mathiasoverby Aug 14, 2025
25737a2
Update main.yml
mathiasoverby Aug 14, 2025
95ee2c7
Update main.yml
mathiasoverby Aug 14, 2025
1056de6
Update main.yml
albla20 Aug 14, 2025
a372fb4
Update main.yml
albla20 Aug 14, 2025
b057df0
Update main.yml
albla20 Aug 14, 2025
b5b4ca2
Update main.yml
albla20 Aug 14, 2025
63755b7
Update main.yml
albla20 Aug 14, 2025
833da8e
Merge pull request #11 from albla20/mathiasoverby-patch-2
albla20 Aug 14, 2025
b7e0430
Added docker-compose file
albla20 Aug 14, 2025
87b91ca
Merge pull request #14 from albla20/docker-compose
albla20 Aug 14, 2025
18f7ab2
Delete .github/workflows/docker.yml
albla20 Aug 14, 2025
0964fe0
Merge pull request #15 from albla20/albla20-patch-1
albla20 Aug 14, 2025
93c0f7e
Update main.yml
albla20 Aug 14, 2025
3c03c15
Update main.yml
albla20 Aug 14, 2025
4209914
Update main.yml
albla20 Aug 14, 2025
1946e11
Update main.yml
albla20 Aug 14, 2025
165c71c
Update main.yml
albla20 Aug 14, 2025
7944fe3
Update main.yml
albla20 Aug 14, 2025
9cbbc00
Update main.yml
albla20 Aug 14, 2025
f0ebad5
Update main.yml
albla20 Aug 14, 2025
a271e58
Update main.yml
albla20 Aug 14, 2025
7b779f6
Update main.yml
albla20 Aug 14, 2025
bb6bfb4
Update main.yml
albla20 Aug 14, 2025
238e15a
Update main.yml
albla20 Aug 14, 2025
0f2de38
Update main.yml
albla20 Aug 14, 2025
32eef8c
db added and test.sh
mathiasoverby Aug 14, 2025
c43ee78
Merge pull request #17 from albla20/albla20-patch-1
albla20 Aug 14, 2025
fc87b23
Merge branch 'main' into db
albla20 Aug 14, 2025
81bb2ad
Merge pull request #18 from albla20/db
albla20 Aug 14, 2025
2dc1ae0
Olsgaard1 patch 1 (#23)
Olsgaard1 Aug 15, 2025
f7dd270
Fixed docker files to latest
albla20 Aug 15, 2025
9dae2fd
Merge pull request #24 from albla20/dockerfix
albla20 Aug 15, 2025
7ef3c3d
Fixed so it gets the latest image from GITHUB registry
albla20 Aug 15, 2025
e57baba
Merge branch 'main' into dockerfix
albla20 Aug 15, 2025
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
102 changes: 102 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: main workflow

on:
push:
branches:
- main
- staging
- development
pull_request:
branches:
- main
- staging
- development

env:
GIT_COMMIT: ${{ github.sha }}
KUBECONFIG: ${{ github.workspace }}/kubeconfig

jobs:
Build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.21.12'

- name: Build backend
run: |
cd backend
go build .

- name: Build frontend
run: |
cd frontend
go build .

- name: Test frontend
run: |
cd frontend
go test ./...

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker images
run: |
docker build -t ghcr.io/albla20/backend:latest backend
docker push ghcr.io/albla20/backend:latest

docker build -t ghcr.io/albla20/frontend:latest frontend
docker push ghcr.io/albla20/frontend:latest

- name: Pull docker images
run: |
docker pull ghcr.io/albla20/backend:latest
docker pull ghcr.io/albla20/frontend:latest


- name: Set up kubeconfig
run: |
echo "${{ secrets.KUBECONFIG }}" | base64 -d > kubeconfig
export KUBECONFIG=$PWD/kubeconfig

- name: Select environment
id: env
run: |
if [[ "${GITHUB_REF##*/}" == "main" ]]; then
echo "ENV=production" >> $GITHUB_ENV
elif [[ "${GITHUB_REF##*/}" == "staging" ]]; then
echo "ENV=staging" >> $GITHUB_ENV
else
echo "ENV=development" >> $GITHUB_ENV
fi
echo "Deploying to $ENV environment"

- name: Deploy to Kubernetes
run: |
MANIFEST_DIR="k8s/${ENV}"
if [ -d "$MANIFEST_DIR" ]; then
echo "Applying manifests in $MANIFEST_DIR"
kubectl apply -f "$MANIFEST_DIR"
kubectl rollout status deployment/backend -n $ENV || true
kubectl rollout status deployment/frontend -n $ENV || true
else
echo "No manifests found for $ENV, skipping deployment."
fi






10 changes: 10 additions & 0 deletions Manifests/backend-pod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: Pod
metadata:
name: backend
spec:
containers:
- name: backend
image: mathiasoverby/backend:latest
ports:
- containerPort: 9000
10 changes: 10 additions & 0 deletions Manifests/frontend-pod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: Pod
metadata:
name: frontend
spec:
containers:
- name: frontend
image: mathiasoverby/frontend:latest
ports:
- containerPort: 8080
8 changes: 8 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Build stage
FROM golang:1.21
WORKDIR /app
COPY . .
RUN go mod download
RUN go build -o backend .
EXPOSE 9000
CMD ["./backend", "run", "go"]
27 changes: 27 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
services:
redis:
image: redis:7-alpine
restart: always
volumes:
- redis_data:/data

backend:
image: ghcr.io/albla20/backend:latest
environment:
- REDIS_DNS=redis
ports:
- "9000:9000" # for host access (not needed for containers to talk)
# IMPORTANT: backend must listen on 0.0.0.0:9000 inside the container

frontend:
image: ghcr.io/albla20/frontend:latest
environment:
- BACKEND_DNS=backend
- BACKEND_PORT=9000
ports:
- "8080:8080"
depends_on:
- backend

volumes:
redis_data:
6 changes: 6 additions & 0 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM golang:1.21
WORKDIR /app
COPY . .
RUN go build -o frontend .
EXPOSE 8080
CMD ["/app/frontend"]
2 changes: 1 addition & 1 deletion frontend/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,5 +101,5 @@ func main() {

http.Handle("/", http.FileServer(http.Dir("./static")))
err := http.ListenAndServe(":8080", nil)
fmt.Println("%v", err)
fmt.Printf("%v", err)
}
16 changes: 16 additions & 0 deletions test_app.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
set -e

URL=${1:-http://localhost:8080}

echo "🚀 Waiting for service to be up at $URL..."
for i in {1..15}; do
if curl -s --head "$URL" | grep "200 OK" > /dev/null; then
echo "✅ Service is reachable!"
exit 0
fi
echo "⏳ Attempt $i: Service not ready yet..."
sleep 2
done

echo "❌ Service did not respond in time"
exit 1