Upgraded Dockerfile

- Updated stackedit to 5.15.5
- Simplified base images naming
- Adopted newer opencontainers labeling
- Trimmed useless instructions from Dockerfile
- Simplified non AMD64 build instructions in readme
pull/6/head
Quentin McGaw (desktop) 5 years ago
parent a6e6fc7fb3
commit d6beb35efe

@ -1,24 +1,17 @@
ARG BASE_IMAGE_BUILDER_GO=golang
ARG BASE_IMAGE_BUILDER_NODE=alpine
ARG ALPINE_VERSION=3.10 ARG ALPINE_VERSION=3.10
ARG GO_VERSION=1.13.0 ARG GO_VERSION=1.13.0
ARG STACKEDIT_VERSION=v5.14.0 ARG STACKEDIT_VERSION=v5.14.5
FROM ${BASE_IMAGE_BUILDER_GO}:${GO_VERSION}-alpine${ALPINE_VERSION} AS server FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS server
ARG GOARCH=amd64 RUN apk --update add git g++
ARG GOARM
ARG BINCOMPRESS
RUN apk --update add git build-base upx
RUN go get -u -v golang.org/x/vgo
WORKDIR /tmp/gobuild WORKDIR /tmp/gobuild
COPY go.mod go.sum ./ COPY go.mod go.sum ./
RUN go mod download RUN go mod download 2>&1
COPY *.go ./ COPY main.go ./
#RUN go test -v -race ./... #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 CGO_ENABLED=0 go build -ldflags="-s -w" -o app main.go
RUN [ "${BINCOMPRESS}" == "" ] || (upx -v --best --lzma --overlay=strip app && upx -t app)
FROM ${BASE_IMAGE_BUILDER_NODE}:${ALPINE_VERSION} AS stackedit FROM alpine:${ALPINE_VERSION} AS stackedit
ARG STACKEDIT_VERSION ARG STACKEDIT_VERSION
WORKDIR /stackedit WORKDIR /stackedit
RUN apk add -q --progress --update --no-cache git npm RUN apk add -q --progress --update --no-cache git npm
@ -33,21 +26,16 @@ FROM scratch AS final
ARG BUILD_DATE ARG BUILD_DATE
ARG VCS_REF ARG VCS_REF
ARG STACKEDIT_VERSION ARG STACKEDIT_VERSION
LABEL org.label-schema.schema-version="1.0.0-rc1" \ LABEL \
maintainer="quentin.mcgaw@gmail.com" \ org.opencontainers.image.authors="quentin.mcgaw@gmail.com" \
org.label-schema.build-date=$BUILD_DATE \ org.opencontainers.image.created=$BUILD_DATE \
org.label-schema.vcs-ref=$VCS_REF \ org.opencontainers.image.version=$STACKEDIT_VERSION \
org.label-schema.vcs-url="https://github.com/qdm12/stackedit-docker" \ org.opencontainers.image.revision=$VCS_REF \
org.label-schema.url="https://github.com/qdm12/stackedit-docker" \ org.opencontainers.image.url="https://github.com/qdm12/stackedit-docker" \
org.label-schema.vcs-description="StackEdit server in a lightweight Docker container" \ org.opencontainers.image.documentation="https://github.com/qdm12/stackedit-docker/blob/master/README.md" \
org.label-schema.vcs-usage="https://github.com/qdm12/stackedit-docker/blob/master/README.md#setup" \ org.opencontainers.image.source="https://github.com/qdm12/stackedit-docker" \
org.label-schema.docker.cmd="docker run -d -p 8000:8000/tcp qmcgaw/stackedit" \ org.opencontainers.image.title="stackedit-docker" \
org.label-schema.docker.cmd.devel="docker run -it --rm -p 8000:8000/tcp qmcgaw/stackedit" \ org.opencontainers.image.description="StackEdit server in a lightweight Docker container"
org.label-schema.docker.params="" \
org.label-schema.version=$STACKEDIT_VERSION \
image-size="29.3MB" \
ram-usage="7MB" \
cpu-usage="Very low"
EXPOSE 8000 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

@ -1,6 +1,6 @@
# StackEdit Docker server # StackEdit Docker server
*StackEdit v5.14.0 (July 2019) with a Golang HTTP server on Scratch* *StackEdit v5.14.5 (January 2020) with a Golang HTTP server on Scratch*
[![Docker StackEdit](https://github.com/qdm12/stackedit-docker/raw/master/readme/title.png)](https://hub.docker.com/r/qmcgaw/stackedit/) [![Docker StackEdit](https://github.com/qdm12/stackedit-docker/raw/master/readme/title.png)](https://hub.docker.com/r/qmcgaw/stackedit/)
@ -21,13 +21,13 @@
| Image size | RAM usage | CPU usage | | Image size | RAM usage | CPU usage |
| --- | --- | --- | | --- | --- | --- |
| 29.3MB | 7MB | Very low | | 34.1MB | 7MB | Very low |
## Features ## Features
- [Stackedit features](https://github.com/benweet/stackedit/blob/master/README.md#stackedit-can) - [Stackedit features](https://github.com/benweet/stackedit/blob/master/README.md#stackedit-can)
- Lightweight image based on: - Lightweight image based on:
- [Stackedit 5.14.0](https://github.com/benweet/stackedit) - [Stackedit 5.14.5](https://github.com/benweet/stackedit)
- [Scratch](https://hub.docker.com/_/scratch) - [Scratch](https://hub.docker.com/_/scratch)
- Golang simple HTTP static server - Golang simple HTTP static server
- Running without root - Running without root
@ -38,37 +38,11 @@
1. <details><summary>CLICK IF YOU HAVE AN ARM DEVICE</summary><p> 1. <details><summary>CLICK IF YOU HAVE AN ARM DEVICE</summary><p>
- If you have a ARM 32 bit v6 architecture You need to build the Docker image yourself using `git` and `docker`
```sh ```sh
docker build -t qmcgaw/REPONAME_DOCKER \ docker build -t qmcgaw/stackedit https://github.com/qdm12/stackedit-docker.git
--build-arg BASE_IMAGE_BUILDER_GO=arm32v6/golang \ ```
--build-arg BASE_IMAGE_BUILDER_NODE=arm32v6/alpine \
--build-arg GOARCH=arm \
--build-arg GOARM=6 \
https://github.com/qdm12/stackedit-docker.git
```
- If you have a ARM 32 bit v7 architecture
```sh
docker build -t qmcgaw/REPONAME_DOCKER \
--build-arg BASE_IMAGE_BUILDER_GO=arm32v7/golang \
--build-arg BASE_IMAGE_BUILDER_NODE=arm32v7/alpine \
--build-arg GOARCH=arm \
--build-arg GOARM=7 \
https://github.com/qdm12/stackedit-docker.git
```
- If you have a ARM 64 bit v8 architecture
```sh
docker build -t qmcgaw/REPONAME_DOCKER \
--build-arg BASE_IMAGE_BUILDER_GO=arm64v8/golang \
--build-arg BASE_IMAGE_BUILDER_NODE=arm64v8/alpine \
--build-arg GOARCH=arm64 \
https://github.com/qdm12/stackedit-docker.git
```
</p></details> </p></details>
@ -92,9 +66,9 @@
## Acknowledgements ## Acknowledgements
Credits to the [developers](https://github.com/benweet/stackedit/graphs/contributors) Credits to the [developers](https://github.com/benweet/stackedit/graphs/contributors) of [StackEdit](https://stackedit.io/)
of [StackEdit](https://stackedit.io/)
## TODOs ## TODOs
- [ ] Configuration of Stackedit with env variables - [ ] Configuration of Stackedit with env variables
- [ ] Travis CI build cross CPU arch

@ -1,4 +1,4 @@
version: '3' version: "3.7"
services: services:
stackedit: stackedit:
image: qmcgaw/stackedit image: qmcgaw/stackedit

@ -2,5 +2,4 @@
docker build --build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \ docker build --build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \
--build-arg VCS_REF=`git rev-parse --short HEAD` \ --build-arg VCS_REF=`git rev-parse --short HEAD` \
--build-arg BINCOMPRESS= \
-t $IMAGE_NAME . -t $IMAGE_NAME .

Loading…
Cancel
Save