Update docker file to support go modules build.

This commit is contained in:
Alex Myasoedov 2019-06-13 13:29:15 +03:00
parent 9857e3d452
commit ae63721e69
3 changed files with 17 additions and 6 deletions

View file

@ -6,4 +6,3 @@ Readme.md
slides/
node_modules/
vendor/
*.go

View file

@ -1,8 +1,21 @@
FROM golang:1.12 AS compiler
WORKDIR $GOPATH/src/github.com/msoedov/hacker-slides
ENV GO111MODULE on
COPY . .
RUN GOOS=linux CGO_ENABLE=0 go build -a -tags netgo -ldflags '-w -extldflags "-static"' -o app *.go
RUN cp app /bin/app
FROM alpine:3.8
WORKDIR /app
WORKDIR /srv
COPY . /app
ENV GIN_MODE=release
CMD ./main $PORT
RUN mkdir slides
COPY --from=compiler /bin/app /bin/app
COPY static static
COPY templates templates
COPY initial-slides.md initial-slides.md
CMD app $PORT

View file

@ -7,7 +7,6 @@ repo:
@echo $(DOCKER_IMAGE)
build:
@GOOS=linux CGO_ENABLE=0 go build main.go
@docker build -t $(DOCKER_IMAGE) .
@docker tag $(DOCKER_IMAGE) $(REPO)