zs/Dockerfile
James Mills 339de0457c Refactor a bunch of stuff adding zs serve, CI/CD workflows, fixing docs and license (#10)
Fixes #5
Fixes #8
Fixes #9

Co-authored-by: James Mills <1290234+prologic@users.noreply.github.com>
Reviewed-on: https://git.mills.io/prologic/zs/pulls/10
2023-03-12 04:13:53 +00:00

61 lines
1.1 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
# Runtime
FROM alpine:latest
RUN apk --no-cache -U add su-exec shadow
ENV PUID=1000
ENV PGID=1000
RUN addgroup -g "${PGID}" zs && \
adduser -D -H -G zs -h /var/empty -u "${PUID}" zs && \
mkdir -p /data && chown -R zs:zs /data
VOLUME /data
WORKDIR /
COPY --from=build /src/zs /usr/local/bin/zs
COPY .dockerfiles/entrypoint.sh /init
ENTRYPOINT ["/init"]
CMD ["zs""]