From 54607a527c5ebc70214c053cc1a0a98933f999b8 Mon Sep 17 00:00:00 2001 From: TheArrayser Date: Sat, 11 Jan 2025 23:11:39 +0000 Subject: [PATCH] add docker and workflow --- .gitea/workflows/build.yml | 38 ++++++++++++++++++++++++++++++++++++++ docker/Dockerfile | 18 ++++++++++++++++++ go.mod | 2 +- main.go | 2 ++ 4 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 .gitea/workflows/build.yml create mode 100644 docker/Dockerfile diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml new file mode 100644 index 0000000..ccdc428 --- /dev/null +++ b/.gitea/workflows/build.yml @@ -0,0 +1,38 @@ +name: Build and push container +run-name: ${{ gitea.actor }} is building the container +on: [push] + +jobs: + Build-Docker-Container: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to registry + uses: docker/login-action@v3 + with: + registry: git.cringe-studios.com + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: git.cringe-studios.com/CringeStudios/dns + tags: | + type=sha + type=raw,latest + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: docker/Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..5b877fa --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,18 @@ +FROM golang:1.23-alpine AS builder + +COPY . /workspace + +WORKDIR /workspace + +RUN go build -ldflags "-s -w" . + + + + +FROM alpine:latest + +COPY --from=builder /workspace/dns /usr/local/bin/dns + +WORKDIR /dns + +ENTRYPOINT [ "/usr/local/bin/dns" ] \ No newline at end of file diff --git a/go.mod b/go.mod index 5d62200..e400b4a 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module git.cringe-studios.com/mr/dnshttp +module git.cringe-studios.com/CringeStudios/dns go 1.23.2 diff --git a/main.go b/main.go index 4758590..358ef46 100644 --- a/main.go +++ b/main.go @@ -109,6 +109,8 @@ func getPage(w http.ResponseWriter, r *http.Request) { } func main() { + log.Println("Starting Server!"); + handler := new(dnsHandler) server := &dns.Server{