Skip to content

Commit

Permalink
Use goreleaser to build docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
russss committed Mar 13, 2024
1 parent 89b5306 commit 1770b0d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 31 deletions.
10 changes: 1 addition & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}
4 changes: 4 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
26 changes: 4 additions & 22 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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

Expand Down

0 comments on commit 1770b0d

Please sign in to comment.