feat: add dockerfile for debian, alpine

This commit is contained in:
soulteary 2022-01-01 23:54:14 +08:00
parent 36e77b1c7a
commit 9da8289ef8
4 changed files with 27 additions and 0 deletions

2
.dockerignore Normal file
View File

@ -0,0 +1,2 @@
Dockerfile
Dockerfile.*

10
Dockerfile Normal file
View File

@ -0,0 +1,10 @@
FROM golang:1.17.5-stretch AS Builder
WORKDIR /app
COPY . .
RUN go mod download -x
RUN GOOS=linux GOARCH=amd64 go build -o webhook
FROM debian:stretch
LABEL maintainer "soulteary <soulteary@gmail.com>"
COPY --from=builder /app/webhook /bin/
CMD webhook

10
Dockerfile.alpine Normal file
View File

@ -0,0 +1,10 @@
FROM golang:1.17.5-alpine3.15 AS Builder
WORKDIR /app
COPY . .
RUN go mod download -x
RUN GOOS=linux GOARCH=amd64 go build -o webhook
FROM alpine:3.15
LABEL maintainer "soulteary <soulteary@gmail.com>"
COPY --from=builder /app/webhook /bin/
CMD webhook

View File

@ -1,5 +1,6 @@
OS = darwin freebsd linux openbsd
ARCHS = 386 arm amd64 arm64
DOCKER_REPO_NAME=adnanh/webhook
.DEFAULT_GOAL := help
@ -33,6 +34,10 @@ release-windows: clean deps ## Generate release for windows
tar cz -C build -f build/webhook-windows-$$arch.tar.gz webhook-windows-$$arch; \
done
release-docker:
docker build -t "${DOCKER_REPO_NAME}" -f Dockerfile .
docker build -t "${DOCKER_REPO_NAME}:alpine" -f Dockerfile.alpine .
test: deps ## Execute tests
go test ./...