mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-16 18:43:10 -06:00
postgres 11
This commit is contained in:
parent
2f331f2f21
commit
7727bb3e8b
82
Dockerfile
82
Dockerfile
|
|
@ -1,49 +1,45 @@
|
||||||
#syntax=docker/dockerfile:1.2
|
FROM golang:1.18-buster as build
|
||||||
|
RUN apt-get update && apt-get install -y postgresql
|
||||||
|
WORKDIR /build
|
||||||
|
ARG BINARY
|
||||||
|
|
||||||
#
|
# Copy the build context to the repo as this is the right dendrite code. This is different to the
|
||||||
# base installs required dependencies and runs go mod download to cache dependencies
|
# Complement Dockerfile which wgets a branch.
|
||||||
#
|
COPY . .
|
||||||
FROM --platform=${BUILDPLATFORM} docker.io/golang:1.20-alpine AS base
|
|
||||||
RUN apk --update --no-cache add bash build-base curl
|
|
||||||
|
|
||||||
#
|
RUN go build ./cmd/${BINARY}
|
||||||
# build creates all needed binaries
|
RUN go build ./cmd/generate-keys
|
||||||
#
|
RUN go build ./cmd/generate-config
|
||||||
FROM --platform=${BUILDPLATFORM} base AS build
|
RUN go build ./cmd/create-account
|
||||||
WORKDIR /src
|
RUN ./generate-config --ci > dendrite.yaml
|
||||||
ARG TARGETOS
|
RUN ./generate-keys --private-key matrix_key.pem --tls-cert server.crt --tls-key server.key
|
||||||
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/...
|
|
||||||
|
|
||||||
|
# Replace the connection string with a single postgres DB, using user/db = 'postgres' and no password
|
||||||
|
RUN sed -i "s%connection_string:.*$%connection_string: postgresql://postgres@localhost/postgres?sslmode=disable%g" dendrite.yaml
|
||||||
|
# No password when connecting over localhost
|
||||||
|
RUN sed -i "s%127.0.0.1/32 md5%127.0.0.1/32 trust%g" /etc/postgresql/11/main/pg_hba.conf
|
||||||
|
# Bump up max conns for moar concurrency
|
||||||
|
RUN sed -i 's/max_connections = 100/max_connections = 2000/g' /etc/postgresql/11/main/postgresql.conf
|
||||||
|
RUN sed -i 's/max_open_conns:.*$/max_open_conns: 100/g' dendrite.yaml
|
||||||
|
|
||||||
#
|
# This entry script starts postgres, waits for it to be up then starts dendrite
|
||||||
# Builds the Dendrite image containing all required binaries
|
RUN echo '\
|
||||||
#
|
#!/bin/bash -eu \n\
|
||||||
FROM alpine:latest
|
pg_lsclusters \n\
|
||||||
RUN apk --update --no-cache add curl
|
pg_ctlcluster 11 main start \n\
|
||||||
LABEL org.opencontainers.image.title="Dendrite"
|
\n\
|
||||||
LABEL org.opencontainers.image.description="Next-generation Matrix homeserver written in Go"
|
until pg_isready \n\
|
||||||
LABEL org.opencontainers.image.source="https://github.com/matrix-org/dendrite"
|
do \n\
|
||||||
LABEL org.opencontainers.image.licenses="Apache-2.0"
|
echo "Waiting for postgres"; \n\
|
||||||
LABEL org.opencontainers.image.documentation="https://matrix-org.github.io/dendrite/"
|
sleep 1; \n\
|
||||||
LABEL org.opencontainers.image.vendor="The Matrix.org Foundation C.I.C."
|
done \n\
|
||||||
|
\n\
|
||||||
|
sed -i "s/server_name: localhost/server_name: ${SERVER_NAME}/g" dendrite.yaml \n\
|
||||||
|
PARAMS="--tls-cert server.crt --tls-key server.key --config dendrite.yaml" \n\
|
||||||
|
./${BINARY} --really-enable-open-registration ${PARAMS} || ./${BINARY} ${PARAMS} \n\
|
||||||
|
' > run_dendrite.sh && chmod +x run_dendrite.sh
|
||||||
|
|
||||||
COPY --from=build /out/create-account /usr/bin/create-account
|
ENV SERVER_NAME=localhost
|
||||||
COPY --from=build /out/generate-config /usr/bin/generate-config
|
ENV BINARY=dendrite
|
||||||
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
|
EXPOSE 8008 8448
|
||||||
|
CMD /build/run_dendrite.sh
|
||||||
|
|
@ -72,18 +72,18 @@ RUN ./generate-config --ci > dendrite.yaml
|
||||||
RUN ./generate-keys --private-key matrix_key.pem --tls-cert server.crt --tls-key server.key
|
RUN ./generate-keys --private-key matrix_key.pem --tls-cert server.crt --tls-key server.key
|
||||||
|
|
||||||
# Replace the connection string with a single postgres DB, using user/db = 'postgres' and no password
|
# Replace the connection string with a single postgres DB, using user/db = 'postgres' and no password
|
||||||
RUN sed -i "s%connection_string:.*$%connection_string: postgresql://postgres@localhost/postgres?sslmode=disable%g" dendrite.yaml
|
RUN sed -i "s%connection_string:.*$%connection_string: postgresql://postgres@localhost/postgres?sslmode=disable%g" dendrite.yaml
|
||||||
# No password when connecting over localhost
|
# No password when connecting over localhost
|
||||||
RUN sed -i "s%127.0.0.1/32 md5%127.0.0.1/32 trust%g" /etc/postgresql/9.6/main/pg_hba.conf
|
RUN sed -i "s%127.0.0.1/32 md5%127.0.0.1/32 trust%g" /etc/postgresql/11/main/pg_hba.conf
|
||||||
# Bump up max conns for moar concurrency
|
# Bump up max conns for moar concurrency
|
||||||
RUN sed -i 's/max_connections = 100/max_connections = 2000/g' /etc/postgresql/9.6/main/postgresql.conf
|
RUN sed -i 's/max_connections = 100/max_connections = 2000/g' /etc/postgresql/11/main/postgresql.conf
|
||||||
RUN sed -i 's/max_open_conns:.*$/max_open_conns: 100/g' dendrite.yaml
|
RUN sed -i 's/max_open_conns:.*$/max_open_conns: 100/g' dendrite.yaml
|
||||||
|
|
||||||
# This entry script starts postgres, waits for it to be up then starts dendrite
|
# This entry script starts postgres, waits for it to be up then starts dendrite
|
||||||
RUN echo '\
|
RUN echo '\
|
||||||
#!/bin/bash -eu \n\
|
#!/bin/bash -eu \n\
|
||||||
pg_lsclusters \n\
|
pg_lsclusters \n\
|
||||||
pg_ctlcluster 9.6 main start \n\
|
pg_ctlcluster 11 main start \n\
|
||||||
\n\
|
\n\
|
||||||
until pg_isready \n\
|
until pg_isready \n\
|
||||||
do \n\
|
do \n\
|
||||||
|
|
@ -119,7 +119,7 @@ RUN ./generate-keys --private-key matrix_key.pem --tls-cert server.crt --tls-key
|
||||||
|
|
||||||
# Make sure the SQLite databases are in a persistent location, we're already mapping
|
# Make sure the SQLite databases are in a persistent location, we're already mapping
|
||||||
# the postgresql folder so let's just use that for simplicity
|
# the postgresql folder so let's just use that for simplicity
|
||||||
RUN sed -i "s%connection_string:.file:%connection_string: file:\/var\/lib\/postgresql\/9.6\/main\/%g" dendrite.yaml
|
RUN sed -i "s%connection_string:.file:%connection_string: file:\/var\/lib\/postgresql\/11\/main\/%g" dendrite.yaml
|
||||||
|
|
||||||
# This entry script starts postgres, waits for it to be up then starts dendrite
|
# This entry script starts postgres, waits for it to be up then starts dendrite
|
||||||
RUN echo '\
|
RUN echo '\
|
||||||
|
|
@ -402,7 +402,7 @@ func runImage(dockerClient *client.Client, volumeName string, branchNameToImageI
|
||||||
{
|
{
|
||||||
Type: mount.TypeVolume,
|
Type: mount.TypeVolume,
|
||||||
Source: volumeName,
|
Source: volumeName,
|
||||||
Target: "/var/lib/postgresql/9.6/main",
|
Target: "/var/lib/postgresql/11/main",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}, nil, nil, "dendrite_upgrade_test_"+branchName)
|
}, nil, nil, "dendrite_upgrade_test_"+branchName)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue