- Runs without root - Internal port changed to 8000 - Healthcheck added - Added emojis - Switched to go modules - Added hooks for labels - Added env variable LISTENINGPORT with checks - Updated readmepull/4/head
parent
e3d61004cb
commit
5aae6ff56a
@ -1,29 +1,55 @@
|
|||||||
FROM alpine:3.8 AS stackedit
|
ARG ALPINE_VERSION=3.8
|
||||||
RUN echo https://alpine.global.ssl.fastly.net/alpine/v3.8/main > /etc/apk/repositories && \
|
ARG GO_VERSION=1.11.2
|
||||||
apk add -q --progress --update --no-cache git npm
|
ARG STACKEDIT_VERSION=v5.13.2
|
||||||
RUN git clone --branch v5.13.2 --single-branch --depth 1 https://github.com/benweet/stackedit.git /stackedit &> /dev/null
|
|
||||||
|
FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS builder
|
||||||
|
RUN apk --update add git build-base upx
|
||||||
|
RUN go get -u -v golang.org/x/vgo
|
||||||
|
WORKDIR /tmp/gobuild
|
||||||
|
|
||||||
|
FROM scratch AS final
|
||||||
|
ARG BUILD_DATE
|
||||||
|
ARG VCS_REF
|
||||||
|
ARG STACKEDIT_VERSION
|
||||||
|
LABEL org.label-schema.schema-version="1.0.0-rc1" \
|
||||||
|
maintainer="quentin.mcgaw@gmail.com" \
|
||||||
|
org.label-schema.build-date=$BUILD_DATE \
|
||||||
|
org.label-schema.vcs-ref=$VCS_REF \
|
||||||
|
org.label-schema.vcs-url="https://github.com/qdm12/stackedit-docker" \
|
||||||
|
org.label-schema.url="https://github.com/qdm12/stackedit-docker" \
|
||||||
|
org.label-schema.vcs-description="StackEdit server in a lightweight Docker container" \
|
||||||
|
org.label-schema.vcs-usage="https://github.com/qdm12/stackedit-docker/blob/master/README.md#setup" \
|
||||||
|
org.label-schema.docker.cmd="docker run -d -p 8000:8000/tcp qmcgaw/stackedit" \
|
||||||
|
org.label-schema.docker.cmd.devel="docker run -it --rm -p 8000:8000/tcp qmcgaw/stackedit" \
|
||||||
|
org.label-schema.docker.params="" \
|
||||||
|
org.label-schema.version=$STACKEDIT_VERSION \
|
||||||
|
image-size="29.3MB" \
|
||||||
|
ram-usage="7MB" \
|
||||||
|
cpu-usage="Very low"
|
||||||
|
EXPOSE 8000
|
||||||
|
HEALTHCHECK --start-period=1s --interval=100s --timeout=2s --retries=1 CMD ["/server","healthcheck"]
|
||||||
|
USER 1000
|
||||||
|
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
|
||||||
WORKDIR /stackedit
|
WORKDIR /stackedit
|
||||||
RUN npm install
|
RUN npm install
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
FROM golang:alpine AS server
|
FROM builder AS server
|
||||||
RUN apk --update add git build-base upx
|
COPY go.mod go.sum ./
|
||||||
WORKDIR /go/src/app
|
RUN go mod download
|
||||||
COPY main.go ./
|
COPY *.go ./
|
||||||
RUN go get -v ./... && \
|
RUN go test -v
|
||||||
CGO_ENABLED=0 GOOS=linux go build -a -ldflags="-s -w" -installsuffix cgo -o server . && \
|
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -ldflags="-s -w" -o app .
|
||||||
upx -v --best --ultra-brute --overlay=strip server && \
|
RUN upx -v --best --ultra-brute --overlay=strip app && upx -t app
|
||||||
upx -t server
|
|
||||||
|
|
||||||
FROM scratch
|
FROM final
|
||||||
LABEL maintainer="quentin.mcgaw@gmail.com" \
|
COPY --from=stackedit --chown=1000 /stackedit/dist /html
|
||||||
description="StackEdit server in a lightweight Docker container" \
|
COPY --from=server --chown=1000 /tmp/gobuild/app /server
|
||||||
download="9.9MB" \
|
|
||||||
size="29.2MB" \
|
|
||||||
ram="7MB" \
|
|
||||||
cpu_usage="Very low" \
|
|
||||||
github="https://github.com/qdm12/stackedit-docker"
|
|
||||||
EXPOSE 80
|
|
||||||
COPY --from=stackedit /stackedit/dist /
|
|
||||||
COPY --from=server /go/src/app/server /server
|
|
||||||
ENTRYPOINT [ "/server" ]
|
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
module github.com/qdm12/stackedit-docker
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/julienschmidt/httprouter v1.2.0
|
||||||
|
github.com/kyokomi/emoji v1.5.1
|
||||||
|
)
|
@ -0,0 +1,4 @@
|
|||||||
|
github.com/julienschmidt/httprouter v1.2.0 h1:TDTW5Yz1mjftljbcKqRcrYhd4XeOoI98t+9HbQbYf7g=
|
||||||
|
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
||||||
|
github.com/kyokomi/emoji v1.5.1 h1:qp9dub1mW7C4MlvoRENH6EAENb9skEFOvIEbp1Waj38=
|
||||||
|
github.com/kyokomi/emoji v1.5.1/go.mod h1:mZ6aGCD7yk8j6QY6KICwnZ2pxoszVseX1DNoGtU2tBA=
|
@ -0,0 +1,9 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# see http://label-schema.org/rc1
|
||||||
|
# https://docs.docker.com/docker-cloud/builds/advanced/#override-build-test-or-push-commands
|
||||||
|
# https://docs.docker.com/docker-cloud/builds/advanced/#custom-build-phase-hooks
|
||||||
|
|
||||||
|
docker build --build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \
|
||||||
|
--build-arg VCS_REF=`git rev-parse --short HEAD` \
|
||||||
|
-t $IMAGE_NAME .
|
Loading…
Reference in new issue