Uses a simple Go binary server in Scratch

Downsize from 45.5MB to 29.6MB
pull/4/head
Quentin McGaw 6 years ago
parent f4fa622693
commit 8d3b2658f0

@ -6,13 +6,22 @@ WORKDIR /stackedit
RUN npm install
RUN npm run build
FROM nginx:1.15-alpine
FROM golang:alpine AS server
RUN apk --update add git build-base upx
WORKDIR /go/src/app
COPY main.go ./
RUN CGO_ENABLED=0 GOOS=linux go build -a -ldflags="-s -w" -installsuffix cgo -o server . && \
upx -v --best --overlay=strip server && \
upx -t server
FROM scratch
LABEL maintainer="quentin.mcgaw@gmail.com" \
description="StackEdit server in a lightweight Docker container" \
download="15.6MB" \
size="45.5MB" \
size="29.6MB" \
ram="7MB" \
cpu_usage="Very low" \
github="https://github.com/qdm12/stackedit-docker"
COPY --from=stackedit /stackedit/dist /usr/share/nginx/html/
ENTRYPOINT nginx -g "daemon off;"
EXPOSE 80
COPY --from=stackedit /stackedit/dist /
COPY --from=server /go/src/app/server /server
ENTRYPOINT [ "/server" ]

@ -0,0 +1,13 @@
package main
import (
"log"
"net/http"
)
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, r.URL.Path[1:])
})
log.Fatal(http.ListenAndServe(":80", nil))
}
Loading…
Cancel
Save