- 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
|
||||
RUN echo https://alpine.global.ssl.fastly.net/alpine/v3.8/main > /etc/apk/repositories && \
|
||||
apk add -q --progress --update --no-cache git npm
|
||||
RUN git clone --branch v5.13.2 --single-branch --depth 1 https://github.com/benweet/stackedit.git /stackedit &> /dev/null
|
||||
ARG ALPINE_VERSION=3.8
|
||||
ARG GO_VERSION=1.11.2
|
||||
ARG STACKEDIT_VERSION=v5.13.2
|
||||
|
||||
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
|
||||
RUN npm install
|
||||
RUN npm run build
|
||||
|
||||
FROM golang:alpine AS server
|
||||
RUN apk --update add git build-base upx
|
||||
WORKDIR /go/src/app
|
||||
COPY main.go ./
|
||||
RUN go get -v ./... && \
|
||||
CGO_ENABLED=0 GOOS=linux go build -a -ldflags="-s -w" -installsuffix cgo -o server . && \
|
||||
upx -v --best --ultra-brute --overlay=strip server && \
|
||||
upx -t server
|
||||
FROM builder AS server
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
COPY *.go ./
|
||||
RUN go test -v
|
||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -ldflags="-s -w" -o app .
|
||||
RUN upx -v --best --ultra-brute --overlay=strip app && upx -t app
|
||||
|
||||
FROM scratch
|
||||
LABEL maintainer="quentin.mcgaw@gmail.com" \
|
||||
description="StackEdit server in a lightweight Docker container" \
|
||||
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" ]
|
||||
FROM final
|
||||
COPY --from=stackedit --chown=1000 /stackedit/dist /html
|
||||
COPY --from=server --chown=1000 /tmp/gobuild/app /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