diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml new file mode 100644 index 0000000..f63f188 --- /dev/null +++ b/.gitea/workflows/build.yaml @@ -0,0 +1,16 @@ +name: Build and Publish +run-name: ${{ gitea.actor }} is building 🚀 +on: [push] + +jobs: + BuildAndDeploy: + runs-on: arm64 + steps: + - name: Check out repository code + uses: actions/checkout@v4 + - name: Run a script + run: docker build -t registry.knatofs.se/go-cart-actor . + - name: Push to registry + run: docker push registry.knatofs.se/go-cart-actor + - name: Deploy to Kubernetes + run: kubectl apply -f deployment.yaml -n cart \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..27a1dd7 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +# syntax=docker/dockerfile:1 + +FROM golang:alpine AS build-stage +WORKDIR /app +COPY go.mod go.sum ./ +RUN go mod download + +COPY *.go ./ +RUN CGO_ENABLED=0 GOOS=linux go build -o /go-cart-actor + +FROM gcr.io/distroless/base-debian11 +WORKDIR / + +COPY --from=build-stage /go-cart-actor /go-cart-actor +ENTRYPOINT ["/go-cart-actor"] \ No newline at end of file diff --git a/deployment.yaml b/deployment.yaml new file mode 100644 index 0000000..1935734 --- /dev/null +++ b/deployment.yaml @@ -0,0 +1,87 @@ + +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app: cart-actor + name: cart-actor +spec: + replicas: 3 + selector: + matchLabels: + app: cart-actor + template: + metadata: + labels: + app: cart-actor + spec: + affinity: + nodeAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - preference: + matchExpressions: + - key: kubernetes.io/arch + operator: In + values: + - arm64 + weight: 1 + volumes: + - name: data + nfs: + path: /i-data/7a8af061/nfs/cart-actor + server: 10.10.1.10 + imagePullSecrets: + - name: regcred + containers: + - image: registry.knatofs.se/go-cart-actor:latest + name: cart-actor + imagePullPolicy: Always + ports: + - containerPort: 8080 + name: generate + volumeMounts: + - mountPath: "/data" + name: data + resources: + requests: + memory: "70Mi" + cpu: "40m" + env: + - name: TZ + value: "Europe/Stockholm" +--- +kind: Service +apiVersion: v1 +metadata: + name: cart-actor +spec: + selector: + app: cart-actor + ports: + - name: generate + port: 8080 +--- +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: cart-ingress + annotations: + cert-manager.io/cluster-issuer: letsencrypt-prod + nginx.ingress.kubernetes.io/proxy-body-size: 16m +spec: + ingressClassName: nginx + tls: + - hosts: + - cart.tornberg.me + secretName: cart-actor-tls-secret + rules: + - host: cart.tornberg.me + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: cart-actor + port: + number: 8080 \ No newline at end of file