Update docker file to support go modules build.
This commit is contained in:
parent
9857e3d452
commit
ae63721e69
3 changed files with 17 additions and 6 deletions
|
@ -6,4 +6,3 @@ Readme.md
|
||||||
slides/
|
slides/
|
||||||
node_modules/
|
node_modules/
|
||||||
vendor/
|
vendor/
|
||||||
*.go
|
|
||||||
|
|
21
Dockerfile
21
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
|
FROM alpine:3.8
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /srv
|
||||||
|
|
||||||
COPY . /app
|
|
||||||
ENV GIN_MODE=release
|
ENV GIN_MODE=release
|
||||||
|
RUN mkdir slides
|
||||||
CMD ./main $PORT
|
COPY --from=compiler /bin/app /bin/app
|
||||||
|
COPY static static
|
||||||
|
COPY templates templates
|
||||||
|
COPY initial-slides.md initial-slides.md
|
||||||
|
CMD app $PORT
|
||||||
|
|
1
Makefile
1
Makefile
|
@ -7,7 +7,6 @@ repo:
|
||||||
@echo $(DOCKER_IMAGE)
|
@echo $(DOCKER_IMAGE)
|
||||||
|
|
||||||
build:
|
build:
|
||||||
@GOOS=linux CGO_ENABLE=0 go build main.go
|
|
||||||
@docker build -t $(DOCKER_IMAGE) .
|
@docker build -t $(DOCKER_IMAGE) .
|
||||||
@docker tag $(DOCKER_IMAGE) $(REPO)
|
@docker tag $(DOCKER_IMAGE) $(REPO)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue