Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 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
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
22 changes: 22 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Build and Push Docker Image

on:
push:
branches: [ "main" ]

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

- name: Log in to Docker Hub
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin

- name: Build and push
run: |
IMAGE=mathiasoverby/backend:latest
IMAGE=mathiasoverby/frontend:latest
docker build -t $IMAGE .
docker push $IMAGE
61 changes: 61 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: main workflow

on:
push:
branches:
- main
pull_request:
branches:
- main

env:
GIT_COMMIT: ${{ github.sha }}

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
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
14 changes: 14 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Build stage
FROM golang:1.21
# as builder
WORKDIR /app
COPY . .
RUN go mod download
RUN go build -o backend .
EXPOSE 9000
CMD ["./backend", "run", "go"]

# Run stage
#FROM alpine:3.19
#COPY --from=builder /app/backend backend
#CMD ["backend"]
18 changes: 18 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: "3.9"
services:
backend:
build:
context: ./backend
dockerfile: Dockerfile
image: albla20/backend:latest
ports:
- 9000
frontend:
build:
context: ./frontend
dockerfile: Dockerfile
image: albla20/frontend:latest
ports:
- 8080
depends_on:
- backend
12 changes: 12 additions & 0 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Build stage
FROM golang:1.21 as builder
WORKDIR /app
COPY . .
RUN go mod download
RUN go build -o frontend .

# Run stage
FROM alpine:3.19
COPY --from=builder /app/frontend /frontend
EXPOSE 8080
CMD ["/frontend", "run", "go"]
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)
}