Merge pull request #4 from steigr/feature/docker-image

Added Dockerfile
This commit is contained in:
Björn Busse 2018-03-14 00:18:35 +01:00 committed by GitHub
commit cdbef56090
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 39 additions and 0 deletions

7
.dockerignore Normal file
View File

@ -0,0 +1,7 @@
**/*
!.git/
!*.go
!GNUmakefile
!common.mk
!Dockerfile
!.dockerignore

17
Dockerfile Normal file
View File

@ -0,0 +1,17 @@
FROM golang:1.10 AS goircd-builder
ARG PACKAGE=github.com/bbusse/goircd
ENV PACKAGE=$PACKAGE
WORKDIR /go/src/$PACKAGE/
ADD . /go/src/$PACKAGE/
RUN export CGO_ENABLED=0 \
&& go get $PACKAGE \
&& make -f GNUmakefile goircd \
&& mv goircd /go/bin/goircd
FROM alpine AS goircd
COPY --from=goircd-builder /go/bin/goircd /bin/goircd
ENTRYPOINT ["sh","-c"]
CMD ["exec goircd"]

View File

@ -1,3 +1,4 @@
VERSION = $(shell git describe --tags) VERSION = $(shell git describe --tags)
PACKAGE ?= quay.io/goircd/goircd
include common.mk include common.mk

View File

@ -2,3 +2,17 @@ LDFLAGS = -X main.version=$(VERSION)
goircd: *.go goircd: *.go
go build -ldflags "$(LDFLAGS)" go build -ldflags "$(LDFLAGS)"
docker-image: *.go Dockerfile .dockerignore
docker build -t $(shell basename $(PACKAGE)):$(VERSION) .
docker-image-push: docker-image-push-latest docker-image-push-version
@true
docker-image-push-version: docker-image-push-latest docker-image-push-version
docker tag $(shell basename $(PACKAGE)):$(VERSION) $(PACKAGE):$(VERSION)
docker push $(PACKAGE):$(VERSION)
docker-image-push-latest: docker-image
docker tag $(shell basename $(PACKAGE)):$(VERSION) $(PACKAGE):latest
docker push $(PACKAGE):latest