76 lines
1.9 KiB
Docker
76 lines
1.9 KiB
Docker
# Build
|
|
FROM golang:alpine AS build
|
|
|
|
RUN apk add --no-cache -U build-base git make
|
|
|
|
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 .
|
|
|
|
# Copy static assets
|
|
COPY ./internal/web/* ./internal/web/
|
|
COPY ./internal/web/css/* ./internal/web/css/
|
|
COPY ./internal/web/js/* ./internal/web/js/
|
|
|
|
# Copy sources
|
|
COPY *.go ./
|
|
COPY ./internal/*.go ./internal/
|
|
COPY ./internal/exec/*.go ./internal/exec/
|
|
COPY ./internal/pwa/*.go ./internal/pwa/
|
|
COPY ./internal/pwa/components/*.go ./internal/pwa/components/
|
|
COPY ./internal/pwa/storage/*.go ./internal/pwa/storage/
|
|
COPY ./internal/pwa/routes/*.go ./internal/pwa/routes/
|
|
COPY ./internal/pwa/utils/*.go ./internal/pwa/utils/
|
|
COPY ./internal/tui/*.go ./internal/tui/
|
|
COPY ./internal/*.go ./internal/
|
|
COPY ./cmd/salty-chat/*.go ./cmd/salty-chat/
|
|
COPY ./cmd/saltyd/*.go ./cmd/saltyd/
|
|
|
|
# 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 cli and server binaries
|
|
RUN make cli server VERSION=$VERSION COMMIT=$COMMIT
|
|
|
|
# Runtime
|
|
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}" salty && \
|
|
adduser -D -H -G salty -h /var/empty -u "${PUID}" salty && \
|
|
mkdir -p /data && chown -R salty:salty /data
|
|
|
|
VOLUME /data
|
|
|
|
WORKDIR /
|
|
|
|
# force cgo resolver
|
|
ENV GODEBUG=netdns=cgo
|
|
|
|
COPY --from=build /src/salty-chat /usr/local/bin/salty-chat
|
|
COPY --from=build /src/saltyd /usr/local/bin/saltyd
|
|
|
|
COPY .dockerfiles/entrypoint.sh /init
|
|
|
|
ENTRYPOINT ["/init"]
|
|
CMD ["saltyd"]
|