Compare commits

9 Commits

Author SHA1 Message Date
64c73cd69b format
All checks were successful
Build & Push Docker Image / build-and-push (push) Successful in 1m15s
2025-11-23 16:38:45 +01:00
0215bdd6a6 sd
Some checks failed
Build & Push Docker Image / build-and-push (push) Has been cancelled
2025-11-23 16:38:18 +01:00
5fdb97b03d use 1.25
Some checks failed
Build & Push Docker Image / build-and-push (push) Failing after 42s
2025-11-23 16:36:57 +01:00
3418919ae2 Dockerfile
Some checks failed
Build & Push Docker Image / build-and-push (push) Failing after 13s
2025-11-23 16:36:07 +01:00
10a86044fa Update ci.yaml
Some checks failed
Build & Push Docker Image / build-and-push (push) Failing after 4s
2025-11-23 16:34:54 +01:00
cc082d5e52 re
Some checks failed
Build & Push Docker Image / build-and-push (push) Failing after 4s
2025-11-23 16:33:22 +01:00
44cf5b6607 test
Some checks failed
Build & Push Docker Image / build-and-push (push) Failing after 3s
2025-11-23 16:27:58 +01:00
9d51bd50f3 workflow test
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 38s
2025-11-23 14:06:54 +01:00
de00fffd79 Merge pull request 'test' (#1) from feature/test into main
Reviewed-on: #1
2025-11-20 20:17:22 +00:00
2 changed files with 86 additions and 0 deletions

51
.gitea/workflows/ci.yaml Normal file
View File

@@ -0,0 +1,51 @@
name: Build & Push Docker Image
run-name: "Build & publish go-micro-service Docker image"
on:
push:
branches:
- main
jobs:
build-and-push:
runs-on: ubuntu-latest # ← must match your Gitea Act Runner label
steps:
# ----------------------------------------------------------
# 1. Check out code
# ----------------------------------------------------------
- name: Checkout repository
uses: actions/checkout@v4
# ----------------------------------------------------------
# 2. Set required variables
# ----------------------------------------------------------
- name: Set environment variables
run: |
echo "REGISTRY=${{ gitea.server_url }}" >> $GITHUB_ENV
echo "IMAGE_NAME=${{ gitea.repository }}" >> $GITHUB_ENV
echo "TAG=latest" >> $GITHUB_ENV
# ----------------------------------------------------------
# 3. Login to Gitea Container Registry
# You must create a secret: GITEA_REGISTRY_TOKEN
# ----------------------------------------------------------
- name: Log in to Gitea Container Registry
run: |
echo "${{ secrets.REGISTRY_TOKEN }}" | \
docker login ${{ env.REGISTRY }} \
-u "${{ gitea.actor }}" --password-stdin
# ----------------------------------------------------------
# 4. Build Docker image from your Dockerfile
# ----------------------------------------------------------
- name: Build Docker image
run: |
docker build -t git.mset.dk/${{ env.IMAGE_NAME }}:${{ env.TAG }} .
# ----------------------------------------------------------
# 5. Push Docker image
# ----------------------------------------------------------
- name: Push Docker image
run: |
docker push git.mset.dk/${{ env.IMAGE_NAME }}:${{ env.TAG }}

35
Dockerfile Normal file
View File

@@ -0,0 +1,35 @@
# ------------------------------------------------------------
# 1. Build stage
# ------------------------------------------------------------
FROM golang:1.25-alpine AS builder
RUN apk add --no-cache git
WORKDIR /app
# Dependencies first (cache friendly)
COPY go.mod go.sum ./
RUN go mod download
# Copy the entire codebase
COPY . .
# Build for the architecture of the host (ARM64 runner)
RUN CGO_ENABLED=0 go build -o server .
# ------------------------------------------------------------
# 2. Final minimal runtime image
# ------------------------------------------------------------
FROM alpine:3.20
RUN adduser -D -g '' appuser
WORKDIR /app
COPY --from=builder /app/server .
EXPOSE 8080
USER appuser
CMD ["./server"]