-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
48 lines (40 loc) · 1.45 KB
/
Dockerfile
File metadata and controls
48 lines (40 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#
# base installs required dependencies and runs go mod download to cache dependencies
#
FROM --platform=${BUILDPLATFORM} docker.io/golang:1.25 AS base
RUN apt-get update && apt-get install -y --no-install-recommends \
bash \
build-essential \
curl \
git \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
#
# build creates all needed binaries
#
FROM --platform=${BUILDPLATFORM} base AS build
WORKDIR /src
ARG VERSION
RUN --mount=target=. \
--mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
GOOS=linux CGO_ENABLED=0 \
go build -ldflags "-X github.com/antinvestor/matrix/internal.versionTag=${VERSION}" -v -trimpath -o /out/ ./cmd/...
#
# Builds the Matrix image containing all required binaries
#
FROM gcr.io/distroless/static:nonroot
USER 65532:65532
EXPOSE 8008
EXPOSE 8448
LABEL org.opencontainers.image.title="Matrix"
LABEL org.opencontainers.image.description="Matrix messaging server written in Golang"
LABEL org.opencontainers.image.source="https://github.com/antinvestor/matrix"
LABEL org.opencontainers.image.licenses="Apache-2.0"
LABEL org.opencontainers.image.vendor="Ant Investor Ltd"
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/matrix /usr/bin/matrix
VOLUME /etc/matrix
WORKDIR /etc/matrix
ENTRYPOINT ["/usr/bin/matrix"]