Add Backend Dockerfile and workflow
This commit is contained in:
33
.gitea/workflows/feedmee-test-backend-build-docker.yaml
Normal file
33
.gitea/workflows/feedmee-test-backend-build-docker.yaml
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
name: Build Feedmee Go Backend App
|
||||||
|
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
working-directory: ./backend
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-push:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Log in to Gitea Container Registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ${{vars.REGISTRY_URL}}
|
||||||
|
username: ${{vars.ACTOR}}
|
||||||
|
password: ${{secrets.TOKEN}}
|
||||||
|
|
||||||
|
- name: Build Docker image
|
||||||
|
run: |
|
||||||
|
docker build -f Dockerfile -t ${{vars.REGISTRY_URL}}/${{github.repository}}-backend-test:latest .
|
||||||
|
|
||||||
|
- name: Push Docker image
|
||||||
|
run: |
|
||||||
|
docker push ${{vars.REGISTRY_URL}}/${{github.repository}}-backend-test:latest
|
||||||
32
backend/Dockerfile
Normal file
32
backend/Dockerfile
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
# --- BUILD STAGE ---
|
||||||
|
FROM golang:1.25.0 AS builder
|
||||||
|
WORKDIR /app
|
||||||
|
COPY go.mod go.sum ./
|
||||||
|
RUN go mod download
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# Fontos: CGO_ENABLED=0 a statikusan linkelt binárisért, ami kompatibilis lesz az Alpine alapú futtatási környezettel.
|
||||||
|
RUN CGO_ENABLED=0 GOOS=linux go build -a -ldflags="-s -w" -o backend .
|
||||||
|
|
||||||
|
|
||||||
|
FROM alpine:latest
|
||||||
|
|
||||||
|
WORKDIR /root/
|
||||||
|
COPY --from=builder /app/backend .
|
||||||
|
|
||||||
|
# Ha a Go alkalmazásodnak szüksége van SSL tanúsítványokra (pl. HTTPS hívásokhoz külső API-k felé), akkor az Alpine image-be telepíteni kell a ca-certificates csomagot.
|
||||||
|
# A CGO_ENABLED=0 miatt elvileg a Go beépített gyökér tanúsítványtárát használja, de biztonságosabb a rendszer ca-certificates csomagját is felrakni.
|
||||||
|
# Ezt csak akkor tedd meg, ha szükséges, és csak a futtatási stage-ben!
|
||||||
|
# RUN apk add --no-cache ca-certificates
|
||||||
|
|
||||||
|
RUN apk add --no-cache tzdata
|
||||||
|
RUN cp /usr/share/zoneinfo/Europe/Budapest /etc/localtime
|
||||||
|
RUN echo "Europe/Budapest" > /etc/timezone
|
||||||
|
|
||||||
|
ENV TZ="Europe/Budapest"
|
||||||
|
ENV LANG="hu_HU.UTF-8"
|
||||||
|
ENV LANGUAGE="hu_HU.UTF-8"
|
||||||
|
ENV LC_ALL="hu_HU.UTF-8"
|
||||||
|
|
||||||
|
EXPOSE 7153
|
||||||
|
CMD ["./backend"]
|
||||||
Reference in New Issue
Block a user