2018-03-25 21:37:32 +00:00
|
|
|
# Build
|
|
|
|
FROM golang:alpine AS build
|
|
|
|
|
2022-03-19 22:28:39 +00:00
|
|
|
RUN apk add --no-cache -U build-base git make
|
2018-03-25 21:37:32 +00:00
|
|
|
|
2022-03-19 22:28:39 +00:00
|
|
|
RUN mkdir -p /src
|
2018-03-25 21:37:32 +00:00
|
|
|
|
2022-03-19 22:28:39 +00:00
|
|
|
WORKDIR /src
|
2018-03-25 21:37:32 +00:00
|
|
|
|
2022-03-19 22:28:39 +00:00
|
|
|
# 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 .
|
|
|
|
|
|
|
|
# Copy sources
|
|
|
|
COPY *.go ./
|
|
|
|
COPY ./client/*.go ./client/
|
|
|
|
COPY ./cmd/msgbusd/*.go ./cmd/msgbusd/
|
|
|
|
COPY ./cmd/msgbus/*.go ./cmd/msgbus/
|
|
|
|
|
|
|
|
# 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"
|
|
|
|
|
|
|
|
# Build client binary
|
|
|
|
RUN make cli VERSION=$VERSION COMMIT=$COMMIT
|
|
|
|
|
|
|
|
# Build server binary
|
|
|
|
RUN make server VERSION=$VERSION COMMIT=$COMMIT
|
2018-03-25 21:37:32 +00:00
|
|
|
|
|
|
|
# Runtime
|
2022-03-19 22:28:39 +00:00
|
|
|
FROM alpine:latest
|
|
|
|
|
|
|
|
RUN apk --no-cache -U add su-exec shadow ca-certificates tzdata
|
|
|
|
|
|
|
|
ENV PUID=1000
|
|
|
|
ENV PGID=1000
|
|
|
|
|
|
|
|
RUN addgroup -g "${PGID}" msgbus && \
|
|
|
|
adduser -D -H -G msgbus -h /var/empty -u "${PUID}" msgbus && \
|
|
|
|
mkdir -p /data && chown -R msgbus:msgbus /data
|
|
|
|
|
|
|
|
VOLUME /data
|
2018-03-25 21:37:32 +00:00
|
|
|
|
2022-03-19 22:28:39 +00:00
|
|
|
WORKDIR /
|
2018-03-25 21:37:32 +00:00
|
|
|
|
2022-03-19 22:28:39 +00:00
|
|
|
# force cgo resolver
|
|
|
|
ENV GODEBUG=netdns=cgo
|
2018-03-25 21:37:32 +00:00
|
|
|
|
2022-03-19 22:28:39 +00:00
|
|
|
COPY --from=build /src/msgbusd /usr/local/bin/msgbusd
|
|
|
|
COPY --from=build /src/msgbus /usr/local/bin/msgbus
|
2018-03-25 21:37:32 +00:00
|
|
|
|
2022-03-19 22:28:39 +00:00
|
|
|
COPY .dockerfiles/entrypoint.sh /init
|
2018-03-25 21:37:32 +00:00
|
|
|
|
2022-03-19 22:28:39 +00:00
|
|
|
ENTRYPOINT ["/init"]
|
|
|
|
CMD ["msgbusd"]
|