From 1770b0dd15c545be6f3d08c50421822555192c8a Mon Sep 17 00:00:00 2001 From: Russ Garrett Date: Wed, 13 Mar 2024 11:44:52 +0000 Subject: [PATCH] Use goreleaser to build docker image --- .github/workflows/build.yml | 10 +--------- .goreleaser.yaml | 4 ++++ Dockerfile | 26 ++++---------------------- 3 files changed, 9 insertions(+), 31 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ea2f69d..de05aed 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,7 +23,7 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Docker meta id: meta - uses: docker/metadata-action@v3 + uses: docker/metadata-action@v5 with: images: | ghcr.io/irccloud/irccat @@ -45,11 +45,3 @@ jobs: args: release --clean env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Build and push Dockerfile - id: docker_build - uses: docker/build-push-action@v5 - with: - file: ./Dockerfile - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 119ae48..1d49273 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -16,6 +16,10 @@ builds: ldflags: - -X main.branch={{.Version}} -X main.revision={{.Commit}} +dockers: + - image_templates: + - ghcr.io/irccloud/irccat + changelog: sort: asc filters: diff --git a/Dockerfile b/Dockerfile index 42d15af..139f77e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,28 +1,10 @@ -# This is a multi-part build that first statically builds irccat, and then -# copies over the resulting binary and the default SSL root certs over into -# a 'scratch' image, resulting in a very small image. -# -# You must provide a config file at /etc/irccat.[json|yaml|toml|hcl], for -# example: -# -# docker build . -t irccat -# docker run -d -P -v /path/to/my/config/irccat.json:/etc/irccat.json irccat -# -# (This will also expose the default ports: 12345 and 8045.) - -# Step one: fetch deps and build -FROM golang:1.22.1 AS build - -ADD . /go/src/github.com/irccloud/irccat -WORKDIR /go/src/github.com/irccloud/irccat - -RUN CGO_ENABLED=0 go get -t -v ./... && go build -a . - -# Step two: copy over the binary and root certs +FROM debian:stable-slim AS build +RUN apt-get update && apt-get install -y ca-certificates && update-ca-certificates FROM scratch -COPY --from=build /go/bin/irccat /irccat COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt +COPY irccat / + EXPOSE 12345 EXPOSE 8045