|
|
@ -1,11 +1,33 @@
|
|
|
|
ARG ALPINE_VERSION=3.8
|
|
|
|
ARG BASE_IMAGE_BUILDER_GO=golang
|
|
|
|
ARG GO_VERSION=1.11.4
|
|
|
|
ARG BASE_IMAGE_BUILDER_NODE=alpine
|
|
|
|
|
|
|
|
ARG ALPINE_VERSION=3.10
|
|
|
|
|
|
|
|
ARG GO_VERSION=1.12.6
|
|
|
|
ARG STACKEDIT_VERSION=v5.13.3
|
|
|
|
ARG STACKEDIT_VERSION=v5.13.3
|
|
|
|
|
|
|
|
|
|
|
|
FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS builder
|
|
|
|
FROM ${BASE_IMAGE_BUILDER_GO}:${GO_VERSION}-alpine${ALPINE_VERSION} AS server
|
|
|
|
|
|
|
|
ARG GOARCH=amd64
|
|
|
|
|
|
|
|
ARG GOARM
|
|
|
|
|
|
|
|
ARG BINCOMPRESS
|
|
|
|
RUN apk --update add git build-base upx
|
|
|
|
RUN apk --update add git build-base upx
|
|
|
|
RUN go get -u -v golang.org/x/vgo
|
|
|
|
RUN go get -u -v golang.org/x/vgo
|
|
|
|
WORKDIR /tmp/gobuild
|
|
|
|
WORKDIR /tmp/gobuild
|
|
|
|
|
|
|
|
COPY go.mod go.sum ./
|
|
|
|
|
|
|
|
RUN go mod download
|
|
|
|
|
|
|
|
COPY *.go ./
|
|
|
|
|
|
|
|
#RUN go test -v -race ./...
|
|
|
|
|
|
|
|
RUN CGO_ENABLED=0 GOOS=linux GOARCH=${GOARCH} GOARM=${GOARM} go build -a -installsuffix cgo -ldflags="-s -w" -o app
|
|
|
|
|
|
|
|
RUN [ "${BINCOMPRESS}" == "" ] || (upx -v --best --lzma --overlay=strip app && upx -t app)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FROM ${BASE_IMAGE_BUILDER_NODE}:${ALPINE_VERSION} AS stackedit
|
|
|
|
|
|
|
|
ARG STACKEDIT_VERSION
|
|
|
|
|
|
|
|
WORKDIR /stackedit
|
|
|
|
|
|
|
|
RUN apk add -q --progress --update --no-cache git npm
|
|
|
|
|
|
|
|
RUN wget -q https://github.com/benweet/stackedit/archive/${STACKEDIT_VERSION}.tar.gz -O stackedit.tar.gz && \
|
|
|
|
|
|
|
|
tar -xzf stackedit.tar.gz --strip-components=1 && \
|
|
|
|
|
|
|
|
rm stackedit.tar.gz
|
|
|
|
|
|
|
|
#ENV NODE_ENV production
|
|
|
|
|
|
|
|
RUN npm install
|
|
|
|
|
|
|
|
RUN npm run build
|
|
|
|
|
|
|
|
|
|
|
|
FROM scratch AS final
|
|
|
|
FROM scratch AS final
|
|
|
|
ARG BUILD_DATE
|
|
|
|
ARG BUILD_DATE
|
|
|
@ -30,26 +52,5 @@ EXPOSE 8000
|
|
|
|
HEALTHCHECK --start-period=1s --interval=100s --timeout=2s --retries=1 CMD ["/server","healthcheck"]
|
|
|
|
HEALTHCHECK --start-period=1s --interval=100s --timeout=2s --retries=1 CMD ["/server","healthcheck"]
|
|
|
|
USER 1000
|
|
|
|
USER 1000
|
|
|
|
ENTRYPOINT ["/server"]
|
|
|
|
ENTRYPOINT ["/server"]
|
|
|
|
|
|
|
|
|
|
|
|
FROM alpine:${ALPINE_VERSION} AS stackedit
|
|
|
|
|
|
|
|
ARG STACKEDIT_VERSION
|
|
|
|
|
|
|
|
WORKDIR /stackedit
|
|
|
|
|
|
|
|
RUN apk add -q --progress --update --no-cache git npm
|
|
|
|
|
|
|
|
RUN wget -q https://github.com/benweet/stackedit/archive/${STACKEDIT_VERSION}.tar.gz -O stackedit.tar.gz && \
|
|
|
|
|
|
|
|
tar -xzf stackedit.tar.gz --strip-components=1 && \
|
|
|
|
|
|
|
|
rm stackedit.tar.gz
|
|
|
|
|
|
|
|
#ENV NODE_ENV production
|
|
|
|
|
|
|
|
RUN npm install
|
|
|
|
|
|
|
|
RUN npm run build
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FROM builder AS server
|
|
|
|
|
|
|
|
COPY go.mod go.sum ./
|
|
|
|
|
|
|
|
RUN go mod download
|
|
|
|
|
|
|
|
COPY *.go ./
|
|
|
|
|
|
|
|
#RUN go test -v -race ./...
|
|
|
|
|
|
|
|
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -ldflags="-s -w" -o app .
|
|
|
|
|
|
|
|
RUN [ "${BINCOMPRESS}" == "" ] || (upx -v --best --lzma --overlay=strip app && upx -t app)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FROM final
|
|
|
|
|
|
|
|
COPY --from=stackedit --chown=1000 /stackedit/dist /html
|
|
|
|
COPY --from=stackedit --chown=1000 /stackedit/dist /html
|
|
|
|
COPY --from=server --chown=1000 /tmp/gobuild/app /server
|
|
|
|
COPY --from=server --chown=1000 /tmp/gobuild/app /server
|
|
|
|