From 19e5af32c43dc3a0f81a61b31c4d5ce2d9933a36 Mon Sep 17 00:00:00 2001 From: omegion Date: Thu, 4 Mar 2021 21:51:07 +0100 Subject: [PATCH] add Docker image --- .github/workflows/build.yml | 4 ++-- Dockerfile | 30 ++++++++++++++++++++++++++++++ Makefile | 2 +- 3 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 Dockerfile diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7019bc7..d9457eb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: Build DB Backup +name: Build on: push: @@ -6,7 +6,7 @@ on: - 'v*' jobs: push_to_registry: - name: Push Docker image to Docker Hub + name: Push Docker image to Docker Hub and GitHub runs-on: ubuntu-latest steps: - name: Check out the repo diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f78ce7a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,30 @@ +ARG GO_VERSION=1.15-alpine3.12 +ARG FROM_IMAGE=alpine:3.11 + +FROM golang:${GO_VERSION} AS builder + +LABEL org.opencontainers.image.source="https://github.com/omegion/bw-ssh" + +RUN apk update && \ + apk add ca-certificates gettext git make && \ + rm -rf /tmp/* && \ + rm -rf /var/cache/apk/* && \ + rm -rf /var/tmp/* + +COPY ./ /app + +WORKDIR /app + +RUN make build-for-container + +FROM ${FROM_IMAGE} + +RUN apk update && \ + apk add ca-certificates gettext jq curl openssl git postgresql && \ + rm -rf /tmp/* && \ + rm -rf /var/cache/apk/* && \ + rm -rf /var/tmp/* + +COPY --from=builder /app/dist/bw-ssh-linux /bin/bw-ssh + +ENTRYPOINT ["bw-ssh"] diff --git a/Makefile b/Makefile index c87a239..71d4f0c 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ build: CGO_ENABLED=0 go build $(LDFLAGS) -installsuffix cgo -o dist/bw-ssh main.go build-for-container: - CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build $(LDFLAGS) -a -installsuffix cgo -o dist/bw-ssh-linux cmd/bw-ssh/main.go + CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build $(LDFLAGS) -a -installsuffix cgo -o dist/bw-ssh-linux main.go .PHONY: lint lint: