mirror of
https://git.mills.io/prologic/zs.git
synced 2024-11-24 05:06:47 -05:00
71 lines
1.5 KiB
Docker
71 lines
1.5 KiB
Docker
# Build
|
|
FROM golang:alpine AS build
|
|
|
|
RUN apk add --no-cache -U build-base git
|
|
|
|
RUN mkdir -p /src
|
|
|
|
WORKDIR /src
|
|
|
|
# Copy Makefile
|
|
COPY Makefile ./
|
|
|
|
# Install deps
|
|
RUN make deps
|
|
|
|
# Copy go.mod and go.sum and install and cache dependencies
|
|
COPY go.mod .
|
|
COPY go.sum .
|
|
|
|
# Download dependencies
|
|
RUN go mod download
|
|
|
|
# Copy sources
|
|
COPY *.go ./
|
|
|
|
# Version/Commit (there there is no .git in Docker build context)
|
|
# NOTE: This is fairly low down in the Dockerfile instructions so
|
|
# we don't break the Docker build cache just be changing
|
|
# unrelated files that actually haven't changed but caused the
|
|
# COMMIT value to change.
|
|
ARG VERSION="0.0.0"
|
|
ARG COMMIT="HEAD"
|
|
ARG BUILD=""
|
|
|
|
# Build cli binary
|
|
RUN make cli VERSION=$VERSION COMMIT=$COMMIT BUILD=$BUILD
|
|
|
|
# Tools
|
|
FROM golang:alpine AS tools
|
|
|
|
RUN go install github.com/tdewolff/minify/v2/cmd/minify@latest
|
|
RUN go install go.mills.io/static/cmd/static@latest
|
|
RUN go install go.mills.io/toc/cmd/toc@latest
|
|
|
|
# Runtime
|
|
FROM alpine:latest
|
|
|
|
RUN apk --no-cache -U add su-exec shadow tzdata ca-certificates curl jq
|
|
|
|
ENV PUID=1000
|
|
ENV PGID=1000
|
|
|
|
RUN mkdir -p /data && chown -R nobody:nobody /data
|
|
|
|
EXPOSE 8000/tcp
|
|
|
|
VOLUME /data
|
|
|
|
WORKDIR /data
|
|
|
|
COPY --from=build /src/zs /usr/local/bin/zs
|
|
COPY --from=tools /go/bin/minify /usr/local/bin/minify
|
|
COPY --from=tools /go/bin/static /usr/local/bin/static
|
|
COPY --from=tools /go/bin/toc /usr/local/bin/toc
|
|
|
|
COPY .dockerfiles/entrypoint.sh /init
|
|
|
|
ENTRYPOINT ["/init"]
|
|
|
|
CMD ["zs", "-p", "serve", "-b", "0.0.0.0:8000", "-r", "/data"]
|