docker镜像多阶段构建

develop
ouqiang 2018-05-18 22:20:41 +08:00
parent f24d306026
commit 4f7a5cfbde
4 changed files with 32 additions and 11 deletions

View File

@ -1,2 +1,2 @@
.git .git
node_modules web/vue/node_modules

30
Dockerfile Normal file
View File

@ -0,0 +1,30 @@
FROM golang:1.10-alpine as builder
WORKDIR /go/src/github.com/ouqiang/gocron
COPY . .
RUN apk update \
&& apk add --no-cache git ca-certificates make bash nodejs yarn
RUN make install-vue \
&& make build-vue \
&& make statik \
&& CGO_ENABLED=0 make gocron
FROM alpine:3.7
RUN addgroup -S app \
&& adduser -S -g app app
WORKDIR /app
COPY --from=builder /go/src/github.com/ouqiang/gocron/bin/gocron .
RUN chown -R app:app ./
EXPOSE 5920
USER app
ENTRYPOINT ["/app/gocron", "web"]

View File

@ -1,9 +0,0 @@
FROM alpine:latest
WORKDIR /usr/local/gocron
COPY . .
EXPOSE 5920
ENTRYPOINT ["/usr/local/gocron/gocron", "web"]

View File

@ -48,7 +48,7 @@ build-vue:
.PHONY: install-vue .PHONY: install-vue
install-vue: install-vue:
cp web/vue && yarn install cd web/vue && yarn install
.PHONY: statik .PHONY: statik
statik: statik: