From e0c8cc9c74cb8f2fa88a6d71ff669ce2ae5b618f Mon Sep 17 00:00:00 2001 From: hook-lord Date: Sat, 14 Sep 2024 00:18:42 +0200 Subject: [PATCH] added workflows --- .gitea/.workflow/build-push.yaml | 37 ++++++++++++++++++++++++++++++++ Dockerfile | 37 ++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 .gitea/.workflow/build-push.yaml create mode 100644 Dockerfile diff --git a/.gitea/.workflow/build-push.yaml b/.gitea/.workflow/build-push.yaml new file mode 100644 index 0000000..6d54211 --- /dev/null +++ b/.gitea/.workflow/build-push.yaml @@ -0,0 +1,37 @@ +# Build docker image and push it to registry +name: Build and Push + +on: + push: + branches: + - main + tags: + - * + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Login to Gitea Container Registry + uses: docker/login-action@v1 + with: + registry: gitea.rannes.dev + username: ${{ secrets.REGISTRY_USERNAME }} + password: ${{ secrets.REGISTRY_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v2 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: true + tags: hooklord/confetti-trigger:${{ github.ref_name }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..93158e5 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,37 @@ +# Use a multi-stage build to create a minimal Docker image + +# Stage 1: Build the Go application +FROM golang:1.23-alpine as builder + +# Set the working directory inside the container +WORKDIR /app + +# Copy go.mod and go.sum files if you have them +COPY go.mod go.sum ./ + +# Download all dependencies +RUN go mod download + +# Copy the source code into the container +COPY . . + +# Build the Go application +RUN go build -o confetti-api main.go + +# Stage 2: Create a minimal image with the application binary +FROM alpine:latest + +# Install ca-certificates to handle HTTPS requests +RUN apk --no-cache add ca-certificates + +# Set the working directory inside the container +WORKDIR /root/ + +# Copy the binary from the builder stage +COPY --from=builder /app/confetti-api . + +# Expose port 8080 for the application +EXPOSE 8080 + +# Command to run the application +CMD ["./confetti-api"] \ No newline at end of file