mirror of
https://github.com/matrix-org/dendrite.git
synced 2024-11-29 17:51:56 -06:00
99f94fc735
Since the removal of `build.sh`, we don't include any information about the revision Dendrite was build from. Since go1.18, the revision a binary was build from is automatically included, so we can try to get that instead. This also adds a `dendrite_up` metric showing the current version (`dendrite_up{version="0.13.1+c796f20"} 1`) Closes #2993
50 lines
1.6 KiB
Docker
50 lines
1.6 KiB
Docker
#syntax=docker/dockerfile:1.2
|
|
|
|
#
|
|
# base installs required dependencies and runs go mod download to cache dependencies
|
|
#
|
|
FROM --platform=${BUILDPLATFORM} docker.io/golang:1.20-alpine AS base
|
|
RUN apk --update --no-cache add bash build-base curl git
|
|
|
|
#
|
|
# build creates all needed binaries
|
|
#
|
|
FROM --platform=${BUILDPLATFORM} base AS build
|
|
WORKDIR /src
|
|
ARG TARGETOS
|
|
ARG TARGETARCH
|
|
ARG FLAGS
|
|
RUN --mount=target=. \
|
|
--mount=type=cache,target=/root/.cache/go-build \
|
|
--mount=type=cache,target=/go/pkg/mod \
|
|
USERARCH=`go env GOARCH` \
|
|
GOARCH="$TARGETARCH" \
|
|
GOOS="linux" \
|
|
CGO_ENABLED=$([ "$TARGETARCH" = "$USERARCH" ] && echo "1" || echo "0") \
|
|
go build -v -ldflags="${FLAGS}" -trimpath -o /out/ ./cmd/...
|
|
|
|
|
|
#
|
|
# Builds the Dendrite image containing all required binaries
|
|
#
|
|
FROM alpine:latest
|
|
RUN apk --update --no-cache add curl
|
|
LABEL org.opencontainers.image.title="Dendrite"
|
|
LABEL org.opencontainers.image.description="Next-generation Matrix homeserver written in Go"
|
|
LABEL org.opencontainers.image.source="https://github.com/matrix-org/dendrite"
|
|
LABEL org.opencontainers.image.licenses="Apache-2.0"
|
|
LABEL org.opencontainers.image.documentation="https://matrix-org.github.io/dendrite/"
|
|
LABEL org.opencontainers.image.vendor="The Matrix.org Foundation C.I.C."
|
|
|
|
COPY --from=build /out/create-account /usr/bin/create-account
|
|
COPY --from=build /out/generate-config /usr/bin/generate-config
|
|
COPY --from=build /out/generate-keys /usr/bin/generate-keys
|
|
COPY --from=build /out/dendrite /usr/bin/dendrite
|
|
|
|
VOLUME /etc/dendrite
|
|
WORKDIR /etc/dendrite
|
|
|
|
ENTRYPOINT ["/usr/bin/dendrite"]
|
|
EXPOSE 8008 8448
|
|
|