diff --git a/.dockerignore b/.dockerignore index a9ad5dc..4dca47a 100644 --- a/.dockerignore +++ b/.dockerignore @@ -6,4 +6,3 @@ Readme.md slides/ node_modules/ vendor/ -*.go diff --git a/Dockerfile b/Dockerfile index 7a5aa0b..ca9b7c0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/Makefile b/Makefile index edd1ca9..4d61aa9 100644 --- a/Makefile +++ b/Makefile @@ -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)