Add Dockerfiles and CI pipeline for Docker build/push
- Dockerfile.cli: multi-stage build for exploredns CLI tool - Dockerfile.web: multi-stage build for the HTTP API/web server - Both use golang:1.24-alpine builder + alpine:3.21 final image - CI pipeline docker job builds and pushes to gitea.hansenits.com.au registry on push to main/master Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
co-authored by
Copilot
multica-agent
parent
25e6039bde
commit
43af39dfd7
@@ -33,3 +33,37 @@ jobs:
|
|||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: go build -v ./...
|
run: go build -v ./...
|
||||||
|
|
||||||
|
docker:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: test
|
||||||
|
if: github.event_name == 'push'
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Log in to registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: gitea.hansenits.com.au
|
||||||
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
|
||||||
|
- name: Build and push CLI image
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: Dockerfile.cli
|
||||||
|
push: true
|
||||||
|
tags: |
|
||||||
|
gitea.hansenits.com.au/hits/exploredns-cli:latest
|
||||||
|
gitea.hansenits.com.au/hits/exploredns-cli:${{ github.sha }}
|
||||||
|
|
||||||
|
- name: Build and push web image
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: Dockerfile.web
|
||||||
|
push: true
|
||||||
|
tags: |
|
||||||
|
gitea.hansenits.com.au/hits/exploredns-web:latest
|
||||||
|
gitea.hansenits.com.au/hits/exploredns-web:${{ github.sha }}
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
# Build stage
|
||||||
|
FROM golang:1.24-alpine AS builder
|
||||||
|
|
||||||
|
WORKDIR /src
|
||||||
|
|
||||||
|
COPY go.mod go.sum ./
|
||||||
|
RUN go mod download
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
RUN CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags="-s -w" -o /out/exploredns ./cmd/exploredns
|
||||||
|
|
||||||
|
# Final stage
|
||||||
|
FROM alpine:3.21
|
||||||
|
|
||||||
|
RUN apk --no-cache add ca-certificates
|
||||||
|
|
||||||
|
COPY --from=builder /out/exploredns /usr/local/bin/exploredns
|
||||||
|
|
||||||
|
ENTRYPOINT ["exploredns"]
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
# Build stage
|
||||||
|
FROM golang:1.24-alpine AS builder
|
||||||
|
|
||||||
|
WORKDIR /src
|
||||||
|
|
||||||
|
COPY go.mod go.sum ./
|
||||||
|
RUN go mod download
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
RUN CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags="-s -w" -o /out/server ./cmd/server
|
||||||
|
|
||||||
|
# Final stage
|
||||||
|
FROM alpine:3.21
|
||||||
|
|
||||||
|
RUN apk --no-cache add ca-certificates
|
||||||
|
|
||||||
|
COPY --from=builder /out/server /usr/local/bin/server
|
||||||
|
|
||||||
|
EXPOSE 8080
|
||||||
|
|
||||||
|
ENTRYPOINT ["server"]
|
||||||
Reference in New Issue
Block a user