add docker tasks

This commit is contained in:
2025-03-16 01:04:16 +00:00
parent 1bbe3102ce
commit 916d2a2d86
5 changed files with 34 additions and 7 deletions

21
docker/Dockerfile Normal file
View File

@@ -0,0 +1,21 @@
FROM golang:1.24 AS build_image
WORKDIR /usr/src/app
# pre-copy/cache go.mod for pre-downloading dependencies and only redownloading them in subsequent builds if they change
COPY go.mod go.sum ./
RUN go mod download && go mod verify
COPY . .
# build binary, place into ./bin/
RUN CGO_ENABLED=0 GOOS=linux go build -o ./bin/q3rcon-proxy ./cmd/q3rcon-proxy/
FROM scratch AS final_image
WORKDIR /bin/
COPY --from=build_image /usr/src/app/bin/q3rcon-proxy .
# Command to run when starting the container
ENTRYPOINT [ "./q3rcon-proxy" ]

View File

@@ -0,0 +1,23 @@
version: '3'
tasks:
build:
desc: Build the Docker image
cmds:
- docker build -t q3rcon-proxy -f docker/Dockerfile .
dir: .
login:
desc: Login to Github Container Registry
cmds:
- docker login ghcr.io -u onyx-and-iris --password-stdin <<< {{.GHCR_TOKEN}}
internal: true
push:
desc: Push the Docker image to Github Container Registry
deps:
- task: build
- task: login
cmds:
- docker tag q3rcon-proxy ghcr.io/onyx-and-iris/q3rcon-proxy:latest
- docker push ghcr.io/onyx-and-iris/q3rcon-proxy:latest