Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dockerfile #466

Open
wants to merge 2 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*
!go.mod
!go.sum
!*.go
!Makefile
!internal/*
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM golang:1.15 AS builder
WORKDIR /go/src/github.com/adnanh/webhook/
COPY . ./
RUN make CGO_ENABLED=0 LDFLAGS="-w -s" build

FROM scratch
COPY --from=builder /go/src/github.com/adnanh/webhook/webhook /bin/
ENTRYPOINT ["/bin/webhook"]
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
OS = darwin freebsd linux openbsd
ARCHS = 386 arm amd64 arm64
LDFLAGS =

.DEFAULT_GOAL := help

Expand All @@ -10,7 +11,7 @@ help:
all: build release release-windows

build: deps ## Build the project
go build
go build -ldflags="$(LDFLAGS)"

release: clean deps ## Generate releases for unix systems
@for arch in $(ARCHS);\
Expand All @@ -19,7 +20,7 @@ release: clean deps ## Generate releases for unix systems
do \
echo "Building $$os-$$arch"; \
mkdir -p build/webhook-$$os-$$arch/; \
GOOS=$$os GOARCH=$$arch go build -o build/webhook-$$os-$$arch/webhook; \
GOOS=$$os GOARCH=$$arch go build -ldflags="$(LDFLAGS)" -o build/webhook-$$os-$$arch/webhook; \
tar cz -C build -f build/webhook-$$os-$$arch.tar.gz webhook-$$os-$$arch; \
done \
done
Expand All @@ -29,7 +30,7 @@ release-windows: clean deps ## Generate release for windows
do \
echo "Building windows-$$arch"; \
mkdir -p build/webhook-windows-$$arch/; \
GOOS=windows GOARCH=$$arch go build -o build/webhook-windows-$$arch/webhook.exe; \
GOOS=windows GOARCH=$$arch go build -ldflags="$(LDFLAGS)" -o build/webhook-windows-$$arch/webhook.exe; \
tar cz -C build -f build/webhook-windows-$$arch.tar.gz webhook-windows-$$arch; \
done

Expand Down