From 4f7a5cfbde7def2ffabb91cfe378922fb059df66 Mon Sep 17 00:00:00 2001 From: ouqiang Date: Fri, 18 May 2018 22:20:41 +0800 Subject: [PATCH] =?UTF-8?q?docker=E9=95=9C=E5=83=8F=E5=A4=9A=E9=98=B6?= =?UTF-8?q?=E6=AE=B5=E6=9E=84=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .dockerignore | 2 +- Dockerfile | 30 ++++++++++++++++++++++++++++++ Dockerfile-release | 9 --------- makefile | 2 +- 4 files changed, 32 insertions(+), 11 deletions(-) create mode 100644 Dockerfile delete mode 100644 Dockerfile-release diff --git a/.dockerignore b/.dockerignore index 85dcc16..81e9c01 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,2 +1,2 @@ .git -node_modules +web/vue/node_modules diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..55e70d1 --- /dev/null +++ b/Dockerfile @@ -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"] \ No newline at end of file diff --git a/Dockerfile-release b/Dockerfile-release deleted file mode 100644 index a6aebec..0000000 --- a/Dockerfile-release +++ /dev/null @@ -1,9 +0,0 @@ -FROM alpine:latest - -WORKDIR /usr/local/gocron - -COPY . . - -EXPOSE 5920 - -ENTRYPOINT ["/usr/local/gocron/gocron", "web"] \ No newline at end of file diff --git a/makefile b/makefile index 3d851cb..b76c372 100644 --- a/makefile +++ b/makefile @@ -48,7 +48,7 @@ build-vue: .PHONY: install-vue install-vue: - cp web/vue && yarn install + cd web/vue && yarn install .PHONY: statik statik: