From 4ef5130e7887c0c97ff6a2ad154e10c30a334bfa Mon Sep 17 00:00:00 2001 From: Olsgaard1 <143800465+Olsgaard1@users.noreply.github.com> Date: Thu, 14 Aug 2025 11:19:32 +0200 Subject: [PATCH 01/48] Create main.yml (#2) * Create main.yml * Update main.yml * Update main.yml * Update main.yml Test and build added * Update main.yml * Update main.yml * Update main.yml * Update main.yml * Update main.go --------- Co-authored-by: albla20 <143800277+albla20@users.noreply.github.com> --- .github/workflows/main.yml | 30 ++++++++++++++++++++++++++++++ frontend/main.go | 2 +- 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 000000000..c68e5b6ba --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,30 @@ +name: main workflow +on: + push: + branches: + - main + pull_request: + branches: + - main +jobs: + Build: + runs-on: ubuntu-latest + 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 ./... + diff --git a/frontend/main.go b/frontend/main.go index bede472b4..27f4da2a4 100644 --- a/frontend/main.go +++ b/frontend/main.go @@ -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) } From c7056bb2e757e9191d448572692f413b1c0d269c Mon Sep 17 00:00:00 2001 From: maove23 Date: Thu, 14 Aug 2025 10:03:39 +0000 Subject: [PATCH 02/48] Inserted dockerfiles for backend and frontend --- frontend/Dockerfile | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 frontend/Dockerfile diff --git a/frontend/Dockerfile b/frontend/Dockerfile new file mode 100644 index 000000000..bbbb669ed --- /dev/null +++ b/frontend/Dockerfile @@ -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 gcr.io/distroless/base-debian12 +COPY --from=builder /app/frontend /frontend +EXPOSE 8080 +CMD ["/frontend"] From b7c2a3b6f0a087c472abadab7588a104f97da8d6 Mon Sep 17 00:00:00 2001 From: maove23 Date: Thu, 14 Aug 2025 10:08:07 +0000 Subject: [PATCH 03/48] dockerfiles added --- backend/Dockerfile | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 backend/Dockerfile diff --git a/backend/Dockerfile b/backend/Dockerfile new file mode 100644 index 000000000..f456f03d5 --- /dev/null +++ b/backend/Dockerfile @@ -0,0 +1,12 @@ +# Build stage +FROM golang:1.21 as builder +WORKDIR /app +COPY . . +RUN go mod download +RUN go build -o backend . + +# Run stage +FROM gcr.io/distroless/base-debian12 +COPY --from=builder /app/backend /backend +EXPOSE 9000 +CMD ["/backend"] From 6557da1cc3f482b967c37666ffa2f5d9270f14f7 Mon Sep 17 00:00:00 2001 From: Olsgaard1 <143800465+Olsgaard1@users.noreply.github.com> Date: Thu, 14 Aug 2025 12:37:41 +0200 Subject: [PATCH 04/48] added Manifests waiting for images (#7) --- Manifests/backend-pod.yaml | 10 ++++++++++ Manifests/frontend-pod.yaml | 10 ++++++++++ 2 files changed, 20 insertions(+) create mode 100644 Manifests/backend-pod.yaml create mode 100644 Manifests/frontend-pod.yaml diff --git a/Manifests/backend-pod.yaml b/Manifests/backend-pod.yaml new file mode 100644 index 000000000..60fabc470 --- /dev/null +++ b/Manifests/backend-pod.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +kind: Pod +metadata: + name: backend +spec: + containers: + - name: backend + image: + ports: + - containerPort: 9000 diff --git a/Manifests/frontend-pod.yaml b/Manifests/frontend-pod.yaml new file mode 100644 index 000000000..5c5eb3b7b --- /dev/null +++ b/Manifests/frontend-pod.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +kind: Pod +metadata: + name: frontend +spec: + containers: + - name: frontend + image: + ports: + - containerPort: 8080 From ce8981368149d6528c71113fb535ffbf7cb0a20f Mon Sep 17 00:00:00 2001 From: maove23 Date: Thu, 14 Aug 2025 10:44:55 +0000 Subject: [PATCH 05/48] dockerfile update --- frontend/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/Dockerfile b/frontend/Dockerfile index bbbb669ed..64a059b2b 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -6,7 +6,7 @@ RUN go mod download RUN go build -o frontend . # Run stage -FROM gcr.io/distroless/base-debian12 +FROM alpine:3.19 COPY --from=builder /app/frontend /frontend EXPOSE 8080 CMD ["/frontend"] From ed02ddb812d2308dabb13e9fd4f515421779b890 Mon Sep 17 00:00:00 2001 From: albla20 <143800277+albla20@users.noreply.github.com> Date: Thu, 14 Aug 2025 12:57:52 +0200 Subject: [PATCH 06/48] Create docker.yml --- .github/workflows/docker.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/docker.yml diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 000000000..5b7ac463a --- /dev/null +++ b/.github/workflows/docker.yml @@ -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 From 8076d4125dda8b4bd40c99fd16a89259a5bf4e1a Mon Sep 17 00:00:00 2001 From: maove23 Date: Thu, 14 Aug 2025 12:12:29 +0000 Subject: [PATCH 07/48] updated docker files and spinned up pods --- Manifests/backend-pod.yaml | 2 +- Manifests/frontend-pod.yaml | 2 +- backend/Dockerfile | 12 +++++++----- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Manifests/backend-pod.yaml b/Manifests/backend-pod.yaml index 60fabc470..e8fc93925 100644 --- a/Manifests/backend-pod.yaml +++ b/Manifests/backend-pod.yaml @@ -5,6 +5,6 @@ metadata: spec: containers: - name: backend - image: + image: mathiasoverby/backend:latest ports: - containerPort: 9000 diff --git a/Manifests/frontend-pod.yaml b/Manifests/frontend-pod.yaml index 5c5eb3b7b..f4453a6fd 100644 --- a/Manifests/frontend-pod.yaml +++ b/Manifests/frontend-pod.yaml @@ -5,6 +5,6 @@ metadata: spec: containers: - name: frontend - image: + image: mathiasoverby/frontend:latest ports: - containerPort: 8080 diff --git a/backend/Dockerfile b/backend/Dockerfile index f456f03d5..f6b4bce4c 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,12 +1,14 @@ # Build stage -FROM golang:1.21 as builder +FROM golang:1.21 +# as builder WORKDIR /app COPY . . RUN go mod download RUN go build -o backend . +EXPOSE 9000 +CMD ["./backend"] # Run stage -FROM gcr.io/distroless/base-debian12 -COPY --from=builder /app/backend /backend -EXPOSE 9000 -CMD ["/backend"] +#FROM alpine:3.19 +#COPY --from=builder /app/backend backend +#CMD ["backend"] From faa8b41986c2c41abb1e7194b6118d4e21143f40 Mon Sep 17 00:00:00 2001 From: mathiasoverby <143800439+mathiasoverby@users.noreply.github.com> Date: Thu, 14 Aug 2025 14:27:13 +0200 Subject: [PATCH 08/48] Update main.yml --- .github/workflows/main.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c68e5b6ba..4235514ff 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -6,6 +6,10 @@ on: pull_request: branches: - main +env: + docker_username: ${{ github.actor }} + docker_password: ${{ secrets.GITHUB_TOKEN }} + GIT_COMMIT: ${{ github.sha }} jobs: Build: runs-on: ubuntu-latest @@ -27,4 +31,15 @@ jobs: run: | cd frontend go test ./... + - name: Checkout + uses: actions/checkout@v3 + + + - name: Build and push + run: | + IMAGE=mathiasoverby/backend:latest + IMAGE=mathiasoverby/frontend:latest + docker build -t $IMAGE . + docker push $IMAGE + From 2cf0670ebbb6d66b6f3ac605ff0c0d817b7e029b Mon Sep 17 00:00:00 2001 From: mathiasoverby <143800439+mathiasoverby@users.noreply.github.com> Date: Thu, 14 Aug 2025 14:33:23 +0200 Subject: [PATCH 09/48] Update main.yml --- .github/workflows/main.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4235514ff..a6d4a2908 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -41,5 +41,12 @@ jobs: IMAGE=mathiasoverby/frontend:latest docker build -t $IMAGE . docker push $IMAGE - - + - 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 From ea30e9e1b9365aae81dc1a188b1cd2b8ec1ec279 Mon Sep 17 00:00:00 2001 From: mathiasoverby <143800439+mathiasoverby@users.noreply.github.com> Date: Thu, 14 Aug 2025 14:43:52 +0200 Subject: [PATCH 10/48] Update main.yml --- .github/workflows/main.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a6d4a2908..41e108462 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -39,7 +39,9 @@ jobs: run: | IMAGE=mathiasoverby/backend:latest IMAGE=mathiasoverby/frontend:latest - docker build -t $IMAGE . + docker build -t mathiasoverby/frontend:latest . + docker build -t mathiasoverby/backend:latest . + docker push $IMAGE - name: Log in to Docker Hub run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin From f37f949fbb0d776f8aee66d936c2958cc072f503 Mon Sep 17 00:00:00 2001 From: mathiasoverby <143800439+mathiasoverby@users.noreply.github.com> Date: Thu, 14 Aug 2025 14:46:03 +0200 Subject: [PATCH 11/48] Update main.yml --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 41e108462..fa6473629 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -37,8 +37,8 @@ jobs: - name: Build and push run: | - IMAGE=mathiasoverby/backend:latest - IMAGE=mathiasoverby/frontend:latest + IMAGE=backend/Dockerfile + IMAGE=frontend/Dockerfile docker build -t mathiasoverby/frontend:latest . docker build -t mathiasoverby/backend:latest . From 9680c4eb9c430fd492777dd7bd94df12e7428f2b Mon Sep 17 00:00:00 2001 From: mathiasoverby <143800439+mathiasoverby@users.noreply.github.com> Date: Thu, 14 Aug 2025 14:54:22 +0200 Subject: [PATCH 12/48] Update main.yml --- .github/workflows/main.yml | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fa6473629..6c937e0b8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -35,20 +35,19 @@ jobs: uses: actions/checkout@v3 - - name: Build and push - run: | - IMAGE=backend/Dockerfile - IMAGE=frontend/Dockerfile - docker build -t mathiasoverby/frontend:latest . - docker build -t mathiasoverby/backend:latest . - - docker push $IMAGE - name: Log in to Docker Hub - run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} - - name: Build and push + - name: Build and push Docker images + run: | + docker build -t mathiasoverby/backend:latest ./backend + docker push mathiasoverby/backend:latest + docker build -t mathiasoverby/frontend:latest ./frontend + docker push mathiasoverby/frontend:latest + - name: pull docker images run: | - IMAGE=mathiasoverby/backend:latest - IMAGE=mathiasoverby/frontend:latest - docker build -t $IMAGE . - docker push $IMAGE + docker pull mathiasoverby/backend:latest + docker pull mathiasoverby/frontend:latest From c07ec99486d065f9277a97a9399b5b11de86b34a Mon Sep 17 00:00:00 2001 From: mathiasoverby <143800439+mathiasoverby@users.noreply.github.com> Date: Thu, 14 Aug 2025 14:56:15 +0200 Subject: [PATCH 13/48] Update main.yml --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6c937e0b8..51b66d4ce 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -38,8 +38,8 @@ jobs: - name: Log in to Docker Hub uses: docker/login-action@v2 with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} + username: ${{ env.DOCKER_USERNAME }} + password: ${{ env.DOCKER_PASSWORD }} - name: Build and push Docker images run: | From 22f4dd5fd2f55b313466fa1ad1a1e268f1e74981 Mon Sep 17 00:00:00 2001 From: mathiasoverby <143800439+mathiasoverby@users.noreply.github.com> Date: Thu, 14 Aug 2025 14:57:30 +0200 Subject: [PATCH 14/48] Update main.yml --- .github/workflows/main.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 51b66d4ce..9da893f07 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -34,13 +34,6 @@ jobs: - name: Checkout uses: actions/checkout@v3 - - - name: Log in to Docker Hub - uses: docker/login-action@v2 - with: - username: ${{ env.DOCKER_USERNAME }} - password: ${{ env.DOCKER_PASSWORD }} - - name: Build and push Docker images run: | docker build -t mathiasoverby/backend:latest ./backend From 6e54a45907a526dd0ddd4d005ad1abcb7dd794e9 Mon Sep 17 00:00:00 2001 From: mathiasoverby <143800439+mathiasoverby@users.noreply.github.com> Date: Thu, 14 Aug 2025 15:10:44 +0200 Subject: [PATCH 15/48] Update main.yml --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9da893f07..e81f1784f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -36,9 +36,9 @@ jobs: - name: Build and push Docker images run: | - docker build -t mathiasoverby/backend:latest ./backend + docker build -t mathiasoverby/backend:latest . docker push mathiasoverby/backend:latest - docker build -t mathiasoverby/frontend:latest ./frontend + docker build -t mathiasoverby/frontend:latest . docker push mathiasoverby/frontend:latest - name: pull docker images run: | From da63a5662c771112ee249d55d2708a0284664428 Mon Sep 17 00:00:00 2001 From: mathiasoverby <143800439+mathiasoverby@users.noreply.github.com> Date: Thu, 14 Aug 2025 15:13:19 +0200 Subject: [PATCH 16/48] Update main.yml --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e81f1784f..662fefc66 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -36,9 +36,9 @@ jobs: - name: Build and push Docker images run: | - docker build -t mathiasoverby/backend:latest . + docker build -t mathiasoverby/backend:latest docker push mathiasoverby/backend:latest - docker build -t mathiasoverby/frontend:latest . + docker build -t mathiasoverby/frontend:latest docker push mathiasoverby/frontend:latest - name: pull docker images run: | From 297b4245fdf78e74052bccedeee7824e598c570d Mon Sep 17 00:00:00 2001 From: mathiasoverby <143800439+mathiasoverby@users.noreply.github.com> Date: Thu, 14 Aug 2025 15:15:51 +0200 Subject: [PATCH 17/48] Update main.yml --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 662fefc66..9da893f07 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -36,9 +36,9 @@ jobs: - name: Build and push Docker images run: | - docker build -t mathiasoverby/backend:latest + docker build -t mathiasoverby/backend:latest ./backend docker push mathiasoverby/backend:latest - docker build -t mathiasoverby/frontend:latest + docker build -t mathiasoverby/frontend:latest ./frontend docker push mathiasoverby/frontend:latest - name: pull docker images run: | From af439815cbb99d1a5366bbe0530609a35336f8b1 Mon Sep 17 00:00:00 2001 From: mathiasoverby <143800439+mathiasoverby@users.noreply.github.com> Date: Thu, 14 Aug 2025 15:17:51 +0200 Subject: [PATCH 18/48] Update Dockerfile --- backend/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/Dockerfile b/backend/Dockerfile index f6b4bce4c..76f53d3d0 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -6,7 +6,7 @@ COPY . . RUN go mod download RUN go build -o backend . EXPOSE 9000 -CMD ["./backend"] +CMD ["./backend", "run", "go"] # Run stage #FROM alpine:3.19 From eb34902dc297051522bcb745dd235f24aa73827e Mon Sep 17 00:00:00 2001 From: mathiasoverby <143800439+mathiasoverby@users.noreply.github.com> Date: Thu, 14 Aug 2025 15:18:14 +0200 Subject: [PATCH 19/48] Update Dockerfile --- frontend/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 64a059b2b..a32746893 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -9,4 +9,4 @@ RUN go build -o frontend . FROM alpine:3.19 COPY --from=builder /app/frontend /frontend EXPOSE 8080 -CMD ["/frontend"] +CMD ["/frontend", "run", "go"] From 5c91664b58b94204523a07d8b5faaf3a2118a2e7 Mon Sep 17 00:00:00 2001 From: mathiasoverby <143800439+mathiasoverby@users.noreply.github.com> Date: Thu, 14 Aug 2025 15:24:17 +0200 Subject: [PATCH 20/48] Update main.yml --- .github/workflows/main.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9da893f07..9c4a6ae56 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -33,7 +33,11 @@ jobs: go test ./... - name: Checkout uses: actions/checkout@v3 - + - name: login to docker hub + uses: docker/login-action@v3 + with: + username: ${{env.docker_username}} + password: ${{ env.docker_password }} - name: Build and push Docker images run: | docker build -t mathiasoverby/backend:latest ./backend From 5037738aeee5986c5e5d1bbcf7a934bed0ae02d3 Mon Sep 17 00:00:00 2001 From: mathiasoverby <143800439+mathiasoverby@users.noreply.github.com> Date: Thu, 14 Aug 2025 15:26:25 +0200 Subject: [PATCH 21/48] Update main.yml --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9c4a6ae56..87bc6a1d9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -36,8 +36,8 @@ jobs: - name: login to docker hub uses: docker/login-action@v3 with: - username: ${{env.docker_username}} - password: ${{ env.docker_password }} + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} - name: Build and push Docker images run: | docker build -t mathiasoverby/backend:latest ./backend From 2926929e53bcb587013880e9b827c724f0df3d0d Mon Sep 17 00:00:00 2001 From: mathiasoverby <143800439+mathiasoverby@users.noreply.github.com> Date: Thu, 14 Aug 2025 15:28:03 +0200 Subject: [PATCH 22/48] Update main.yml --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 87bc6a1d9..6161b6722 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -36,8 +36,8 @@ jobs: - name: login to docker hub uses: docker/login-action@v3 with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} + username: ${{ env.DOCKER_USERNAME }} + password: ${{ env.DOCKER_PASSWORD }} - name: Build and push Docker images run: | docker build -t mathiasoverby/backend:latest ./backend From 25737a25a1a9518bd85d2f0195b06c0ef7fe2c23 Mon Sep 17 00:00:00 2001 From: mathiasoverby <143800439+mathiasoverby@users.noreply.github.com> Date: Thu, 14 Aug 2025 15:38:13 +0200 Subject: [PATCH 23/48] Update main.yml --- .github/workflows/main.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6161b6722..9eb418e14 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -40,11 +40,11 @@ jobs: password: ${{ env.DOCKER_PASSWORD }} - name: Build and push Docker images run: | - docker build -t mathiasoverby/backend:latest ./backend - docker push mathiasoverby/backend:latest - docker build -t mathiasoverby/frontend:latest ./frontend - docker push mathiasoverby/frontend:latest + docker build -t albla20/backend:latest ./backend + docker push albla20/backend:latest + docker build -t albla20/frontend:latest ./frontend + docker push albla20/frontend:latest - name: pull docker images run: | - docker pull mathiasoverby/backend:latest - docker pull mathiasoverby/frontend:latest + docker pull albla20/backend:latest + docker pull albla20/frontend:latest From 95ee2c76c890d6e3295f1cc5c411a59f5693187c Mon Sep 17 00:00:00 2001 From: mathiasoverby <143800439+mathiasoverby@users.noreply.github.com> Date: Thu, 14 Aug 2025 15:39:59 +0200 Subject: [PATCH 24/48] Update main.yml --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9eb418e14..7cfac8361 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -36,8 +36,8 @@ jobs: - name: login to docker hub uses: docker/login-action@v3 with: - username: ${{ env.DOCKER_USERNAME }} - password: ${{ env.DOCKER_PASSWORD }} + username: ${{ env.docker_username }} + password: ${{ env.docker_password}} - name: Build and push Docker images run: | docker build -t albla20/backend:latest ./backend From 1056de634e7e981d42fc1bcc4ba46780b0d50a01 Mon Sep 17 00:00:00 2001 From: albla20 <143800277+albla20@users.noreply.github.com> Date: Thu, 14 Aug 2025 15:49:01 +0200 Subject: [PATCH 25/48] Update main.yml --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7cfac8361..ba2bd2fde 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -40,9 +40,9 @@ jobs: password: ${{ env.docker_password}} - name: Build and push Docker images run: | - docker build -t albla20/backend:latest ./backend + docker build -t albla20/backend:latest docker push albla20/backend:latest - docker build -t albla20/frontend:latest ./frontend + docker build -t albla20/frontend:latest docker push albla20/frontend:latest - name: pull docker images run: | From a372fb41a876d28a89d032328409135c856b9ff7 Mon Sep 17 00:00:00 2001 From: albla20 <143800277+albla20@users.noreply.github.com> Date: Thu, 14 Aug 2025 15:56:38 +0200 Subject: [PATCH 26/48] Update main.yml --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ba2bd2fde..1c183b1b9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,7 +9,7 @@ on: env: docker_username: ${{ github.actor }} docker_password: ${{ secrets.GITHUB_TOKEN }} - GIT_COMMIT: ${{ github.sha }} + GIT_COMMIT: ${{ github.sha }} jobs: Build: runs-on: ubuntu-latest From b057df093de09fe44777b7084fdf416b84610f49 Mon Sep 17 00:00:00 2001 From: albla20 <143800277+albla20@users.noreply.github.com> Date: Thu, 14 Aug 2025 15:58:28 +0200 Subject: [PATCH 27/48] Update main.yml Changed the Tokens --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1c183b1b9..28060733a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -36,8 +36,8 @@ jobs: - name: login to docker hub uses: docker/login-action@v3 with: - username: ${{ env.docker_username }} - password: ${{ env.docker_password}} + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_TOKEN }} - name: Build and push Docker images run: | docker build -t albla20/backend:latest From b5b4ca202e8bd5f89fdc851034f8fbfcb56b4c1f Mon Sep 17 00:00:00 2001 From: albla20 <143800277+albla20@users.noreply.github.com> Date: Thu, 14 Aug 2025 16:00:58 +0200 Subject: [PATCH 28/48] Update main.yml Changed the env --- .github/workflows/main.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 28060733a..bb242fc78 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -6,9 +6,7 @@ on: pull_request: branches: - main -env: - docker_username: ${{ github.actor }} - docker_password: ${{ secrets.GITHUB_TOKEN }} +env: GIT_COMMIT: ${{ github.sha }} jobs: Build: From 63755b73e293d6c71527a98048149a6d2ef5f4b5 Mon Sep 17 00:00:00 2001 From: albla20 <143800277+albla20@users.noreply.github.com> Date: Thu, 14 Aug 2025 16:14:29 +0200 Subject: [PATCH 29/48] Update main.yml Changed The push and pull to github reg instead of docker. --- .github/workflows/main.yml | 53 ++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 20 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bb242fc78..53d84c7a6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,48 +1,61 @@ name: main workflow + on: push: branches: - - main + - main pull_request: branches: - - main -env: - GIT_COMMIT: ${{ github.sha }} + - main + +env: + GIT_COMMIT: ${{ github.sha }} + jobs: - Build: - runs-on: ubuntu-latest - steps: + 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 + + - name: Test frontend run: | cd frontend go test ./... - - name: Checkout - uses: actions/checkout@v3 - - name: login to docker hub + + - name: Login to GitHub Container Registry uses: docker/login-action@v3 with: - username: ${{ secrets.DOCKER_HUB_USERNAME }} - password: ${{ secrets.DOCKER_HUB_TOKEN }} + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push Docker images run: | - docker build -t albla20/backend:latest - docker push albla20/backend:latest - docker build -t albla20/frontend:latest - docker push albla20/frontend:latest - - name: pull docker images + 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 albla20/backend:latest - docker pull albla20/frontend:latest + docker pull ghcr.io/albla20/backend:latest + docker pull ghcr.io/albla20/frontend:latest From b7e04300bb885235986e6e38c24b88b05ceb7d11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Bl=C3=A5sten?= Date: Thu, 14 Aug 2025 14:32:39 +0000 Subject: [PATCH 30/48] Added docker-compose file --- docker-compose.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 docker-compose.yml diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..5624d10bc --- /dev/null +++ b/docker-compose.yml @@ -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 \ No newline at end of file From 18f7ab2c96896f9762d46c528910d9f44bddff7d Mon Sep 17 00:00:00 2001 From: albla20 <143800277+albla20@users.noreply.github.com> Date: Thu, 14 Aug 2025 16:39:48 +0200 Subject: [PATCH 31/48] Delete .github/workflows/docker.yml We made it all in main. so we only have 1 workflow. --- .github/workflows/docker.yml | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100644 .github/workflows/docker.yml diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml deleted file mode 100644 index 5b7ac463a..000000000 --- a/.github/workflows/docker.yml +++ /dev/null @@ -1,22 +0,0 @@ -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 From 93c0f7e973fe88a6a299814e20aceb4346550f03 Mon Sep 17 00:00:00 2001 From: albla20 <143800277+albla20@users.noreply.github.com> Date: Thu, 14 Aug 2025 16:50:20 +0200 Subject: [PATCH 32/48] Update main.yml Added kubernetes KUBECONFIG --- .github/workflows/main.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 53d84c7a6..4d8ae109e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -59,3 +59,8 @@ jobs: run: | docker pull ghcr.io/albla20/backend:latest docker pull ghcr.io/albla20/frontend:latest + + - name: kubeconfig + - run: echo "${{ secrets.KUBECONFIG }}" | base64 -d > kubeconfig + - run: kubectl --kubeconfig kubeconfig kubectl get pods + From 3c03c15d4495f472ff7b04b09da16763b50e9cdd Mon Sep 17 00:00:00 2001 From: albla20 <143800277+albla20@users.noreply.github.com> Date: Thu, 14 Aug 2025 16:57:51 +0200 Subject: [PATCH 33/48] Update main.yml Fixed a thing in last line where it was dublicated with kubernetes command. --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4d8ae109e..bbbc0c349 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -62,5 +62,5 @@ jobs: - name: kubeconfig - run: echo "${{ secrets.KUBECONFIG }}" | base64 -d > kubeconfig - - run: kubectl --kubeconfig kubeconfig kubectl get pods + - run: kubectl --kubeconfig kubeconfig get pods From 42099147b6e6814eb1b4f30302e6e16c6bafbb77 Mon Sep 17 00:00:00 2001 From: albla20 <143800277+albla20@users.noreply.github.com> Date: Thu, 14 Aug 2025 17:00:28 +0200 Subject: [PATCH 34/48] Update main.yml Changed the run to run them all at once. --- .github/workflows/main.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bbbc0c349..6ba0379f9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -61,6 +61,7 @@ jobs: docker pull ghcr.io/albla20/frontend:latest - name: kubeconfig - - run: echo "${{ secrets.KUBECONFIG }}" | base64 -d > kubeconfig - - run: kubectl --kubeconfig kubeconfig get pods + run: | + echo "${{ secrets.KUBECONFIG }}" | base64 -d > kubeconfig + kubectl --kubeconfig kubeconfig get pods From 1946e11bb4162b79b4dd543c007434fc21c05f50 Mon Sep 17 00:00:00 2001 From: albla20 <143800277+albla20@users.noreply.github.com> Date: Thu, 14 Aug 2025 17:02:08 +0200 Subject: [PATCH 35/48] Update main.yml From 165c71cfafa9ea64c552b58a3f3dcd42b302c0ce Mon Sep 17 00:00:00 2001 From: albla20 <143800277+albla20@users.noreply.github.com> Date: Thu, 14 Aug 2025 17:04:04 +0200 Subject: [PATCH 36/48] Update main.yml Changed the get message --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6ba0379f9..9e6f26ab4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -63,5 +63,5 @@ jobs: - name: kubeconfig run: | echo "${{ secrets.KUBECONFIG }}" | base64 -d > kubeconfig - kubectl --kubeconfig kubeconfig get pods + kubectl --kubeconfig kubeconfig get deployments From 7944fe3ecd92659a1f970eb4adefa5caa729c7a0 Mon Sep 17 00:00:00 2001 From: albla20 <143800277+albla20@users.noreply.github.com> Date: Thu, 14 Aug 2025 17:05:11 +0200 Subject: [PATCH 37/48] Update main.yml --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9e6f26ab4..337fd934c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -63,5 +63,5 @@ jobs: - name: kubeconfig run: | echo "${{ secrets.KUBECONFIG }}" | base64 -d > kubeconfig - kubectl --kubeconfig kubeconfig get deployments + kubectl --kubeconfig kubeconfig get deployments From 9cbbc00becf05c642cf557d2d0164b6246f29199 Mon Sep 17 00:00:00 2001 From: albla20 <143800277+albla20@users.noreply.github.com> Date: Thu, 14 Aug 2025 17:18:31 +0200 Subject: [PATCH 38/48] Update main.yml --- .github/workflows/main.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 337fd934c..97530044a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -62,6 +62,7 @@ jobs: - name: kubeconfig run: | - echo "${{ secrets.KUBECONFIG }}" | base64 -d > kubeconfig kubectl --kubeconfig kubeconfig get deployments + echo "${{ secrets.KUBECONFIG }}" | base64 -d > kubeconfig + From f0ebad5510d37e4563b1c6fdf4c4e8c499c5799b Mon Sep 17 00:00:00 2001 From: albla20 <143800277+albla20@users.noreply.github.com> Date: Thu, 14 Aug 2025 17:22:42 +0200 Subject: [PATCH 39/48] Update main.yml --- .github/workflows/main.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 97530044a..c8dad9675 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -62,7 +62,8 @@ jobs: - name: kubeconfig run: | - kubectl --kubeconfig kubeconfig get deployments echo "${{ secrets.KUBECONFIG }}" | base64 -d > kubeconfig - + cat kubeconfig + kubectl --kubeconfig kubeconfig get deployments + From a271e58a9d6ddc219fcce368154329e7e05b2ed8 Mon Sep 17 00:00:00 2001 From: albla20 <143800277+albla20@users.noreply.github.com> Date: Thu, 14 Aug 2025 17:26:25 +0200 Subject: [PATCH 40/48] Update main.yml Hopefully fixed kubeconfig. --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c8dad9675..930533b82 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -63,7 +63,7 @@ jobs: - name: kubeconfig run: | echo "${{ secrets.KUBECONFIG }}" | base64 -d > kubeconfig - cat kubeconfig - kubectl --kubeconfig kubeconfig get deployments + export KUBECONFIG=$PWD/kubeconfig + kubectl get nodes From 7b779f69f115ff326372585bb3553b1ed941c4a1 Mon Sep 17 00:00:00 2001 From: albla20 <143800277+albla20@users.noreply.github.com> Date: Thu, 14 Aug 2025 17:35:08 +0200 Subject: [PATCH 41/48] Update main.yml Added env with kubeconfig. --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 930533b82..fcc97a78d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,6 +10,7 @@ on: env: GIT_COMMIT: ${{ github.sha }} + KUBECONFIG: ${{ github.workspace }}/kubeconfig jobs: Build: From bb6bfb4827f45673b44233b1f451e78368273b43 Mon Sep 17 00:00:00 2001 From: albla20 <143800277+albla20@users.noreply.github.com> Date: Thu, 14 Aug 2025 17:44:46 +0200 Subject: [PATCH 42/48] Update main.yml Updated 3 branches to the thing and tried to fix kubernetes to deploy. --- .github/workflows/main.yml | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fcc97a78d..0585a2ebc 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -4,9 +4,13 @@ on: push: branches: - main + - staging + - development pull_request: branches: - main + - staging + - development env: GIT_COMMIT: ${{ github.sha }} @@ -61,10 +65,26 @@ jobs: docker pull ghcr.io/albla20/backend:latest docker pull ghcr.io/albla20/frontend:latest - - name: kubeconfig + - name: Set up kubeconfig run: | echo "${{ secrets.KUBECONFIG }}" | base64 -d > kubeconfig export KUBECONFIG=$PWD/kubeconfig - kubectl get nodes + + - name: Select environment + run: | + if [[ "${GITHUB_REF##*/}" == "main" ]]; then + ENV="production" + elif [[ "${GITHUB_REF##*/}" == "staging" ]]; then + ENV="staging" + else + ENV="development" + fi + echo "Deploying to $ENV environment" + + - name: Deploy to Kubernetes + run: | + kubectl apply -f k8s/${ENV}/ + kubectl rollout status deployment/backend -n $ENV + kubectl rollout status deployment/frontend -n $ENV From 238e15a7c155aa5a3bccafb615c714138ed14bef Mon Sep 17 00:00:00 2001 From: albla20 <143800277+albla20@users.noreply.github.com> Date: Thu, 14 Aug 2025 17:49:22 +0200 Subject: [PATCH 43/48] Update main.yml --- .github/workflows/main.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0585a2ebc..cb0575d7f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -72,14 +72,14 @@ jobs: - name: Select environment run: | - if [[ "${GITHUB_REF##*/}" == "main" ]]; then - ENV="production" - elif [[ "${GITHUB_REF##*/}" == "staging" ]]; then - ENV="staging" - else - ENV="development" - fi - echo "Deploying to $ENV environment" + 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: | From 0f2de38b336cce4355ddffb3c53af676c4286dc7 Mon Sep 17 00:00:00 2001 From: albla20 <143800277+albla20@users.noreply.github.com> Date: Thu, 14 Aug 2025 17:53:11 +0200 Subject: [PATCH 44/48] Update main.yml --- .github/workflows/main.yml | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index cb0575d7f..18a1a2029 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -65,26 +65,34 @@ jobs: 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 + if [[ "${GITHUB_REF##*/}" == "main" ]]; then echo "ENV=production" >> $GITHUB_ENV - elif [[ "${GITHUB_REF##*/}" == "staging" ]]; then + elif [[ "${GITHUB_REF##*/}" == "staging" ]]; then echo "ENV=staging" >> $GITHUB_ENV - else + else echo "ENV=development" >> $GITHUB_ENV - fi - echo "Deploying to $ENV environment" + fi + echo "Deploying to $ENV environment" - name: Deploy to Kubernetes run: | - kubectl apply -f k8s/${ENV}/ - kubectl rollout status deployment/backend -n $ENV - kubectl rollout status deployment/frontend -n $ENV + 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 From 32eef8c0011ef67aeef4c6102c0c4a0defc22b25 Mon Sep 17 00:00:00 2001 From: maove23 Date: Thu, 14 Aug 2025 15:55:54 +0000 Subject: [PATCH 45/48] db added and test.sh --- docker-compose.yml | 22 +++++++++++++++++++--- test_app.sh | 16 ++++++++++++++++ 2 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 test_app.sh diff --git a/docker-compose.yml b/docker-compose.yml index 5624d10bc..368e37bad 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,18 +1,34 @@ version: "3.9" + services: + redis: + image: redis:7-alpine + container_name: redis + restart: always + volumes: + - redis_data:/data + backend: build: context: ./backend dockerfile: Dockerfile image: albla20/backend:latest + environment: + - REDIS_DNS=redis + depends_on: + - redis ports: - - 9000 + - "9000:9000" + frontend: build: context: ./frontend dockerfile: Dockerfile image: albla20/frontend:latest ports: - - 8080 + - "8080:8080" depends_on: - - backend \ No newline at end of file + - backend + +volumes: + redis_data: diff --git a/test_app.sh b/test_app.sh new file mode 100644 index 000000000..ed57f0373 --- /dev/null +++ b/test_app.sh @@ -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 From 2dc1ae06f25cae7ea7f1090e36d038b07e452444 Mon Sep 17 00:00:00 2001 From: Olsgaard1 <143800465+Olsgaard1@users.noreply.github.com> Date: Fri, 15 Aug 2025 10:31:23 +0200 Subject: [PATCH 46/48] Olsgaard1 patch 1 (#23) * Update docker-compose.yml * Update main.yml * Update main.yml * Update main.yml * Update docker-compose.yml * Update docker-compose.yml * docker testing * Update docker-compose.yml * Update main.yml * FIXED Dockerfile AND DOCKER compose * Update main.yml --- .github/workflows/main.yml | 4 ++++ backend/Dockerfile | 6 ------ docker-compose.yml | 27 ++++++++++----------------- frontend/Dockerfile | 10 ++-------- 4 files changed, 16 insertions(+), 31 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 18a1a2029..d7a63892b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -94,5 +94,9 @@ jobs: else echo "No manifests found for $ENV, skipping deployment." fi + + + + diff --git a/backend/Dockerfile b/backend/Dockerfile index 76f53d3d0..1e027a454 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,14 +1,8 @@ # 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"] diff --git a/docker-compose.yml b/docker-compose.yml index 368e37bad..9148ff4fc 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,30 +1,23 @@ -version: "3.9" - services: redis: image: redis:7-alpine - container_name: redis restart: always volumes: - redis_data:/data - backend: - build: - context: ./backend - dockerfile: Dockerfile - image: albla20/backend:latest + backend: + image: albla20/backend:100 environment: - - REDIS_DNS=redis - depends_on: - - redis - ports: - - "9000:9000" + - 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: - build: - context: ./frontend - dockerfile: Dockerfile - image: albla20/frontend:latest + image: albla20/frontend:100 + environment: + - BACKEND_DNS=backend + - BACKEND_PORT=9000 ports: - "8080:8080" depends_on: diff --git a/frontend/Dockerfile b/frontend/Dockerfile index a32746893..50258b790 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -1,12 +1,6 @@ -# Build stage -FROM golang:1.21 as builder +FROM golang:1.21 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"] +CMD ["/app/frontend"] From f7dd2701fe1271a65421cd57a263e7b4cc654bcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Bl=C3=A5sten?= Date: Fri, 15 Aug 2025 08:42:34 +0000 Subject: [PATCH 47/48] Fixed docker files to latest --- docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 9148ff4fc..40163305f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,7 +6,7 @@ services: - redis_data:/data backend: - image: albla20/backend:100 + image: albla20/backend:latest environment: - REDIS_DNS=redis ports: @@ -14,7 +14,7 @@ services: # IMPORTANT: backend must listen on 0.0.0.0:9000 inside the container frontend: - image: albla20/frontend:100 + image: albla20/frontend:latest environment: - BACKEND_DNS=backend - BACKEND_PORT=9000 From 7ef3c3d51ebb43ced0fa711e20a16390e4c72f40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Bl=C3=A5sten?= Date: Fri, 15 Aug 2025 08:58:23 +0000 Subject: [PATCH 48/48] Fixed so it gets the latest image from GITHUB registry --- docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 40163305f..879d45717 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,7 +6,7 @@ services: - redis_data:/data backend: - image: albla20/backend:latest + image: ghcr.io/albla20/backend:latest environment: - REDIS_DNS=redis ports: @@ -14,7 +14,7 @@ services: # IMPORTANT: backend must listen on 0.0.0.0:9000 inside the container frontend: - image: albla20/frontend:latest + image: ghcr.io/albla20/frontend:latest environment: - BACKEND_DNS=backend - BACKEND_PORT=9000