2021-11-21 17:34:08 +00:00
|
|
|
# syntax=docker/dockerfile:1
|
2021-07-19 15:18:25 +00:00
|
|
|
# ---------------------------------------------------------------------------------------------------------
|
|
|
|
# This Dockerfile is intended to be built as part of Conduit's CI pipeline.
|
2021-12-15 10:14:20 +00:00
|
|
|
# It does not build Conduit in Docker, but just copies the matching build artifact from the build jobs.
|
2021-07-19 15:18:25 +00:00
|
|
|
#
|
|
|
|
# It is mostly based on the normal Conduit Dockerfile, but adjusted in a few places to maximise caching.
|
|
|
|
# Credit's for the original Dockerfile: Weasy666.
|
|
|
|
# ---------------------------------------------------------------------------------------------------------
|
|
|
|
|
2022-06-18 11:05:42 +00:00
|
|
|
FROM docker.io/alpine:3.16.0@sha256:4ff3ca91275773af45cb4b0834e12b7eb47d1c18f770a0b151381cd227f4c253 AS runner
|
2021-07-19 15:18:25 +00:00
|
|
|
|
2022-01-23 17:09:14 +00:00
|
|
|
|
2021-11-21 17:34:08 +00:00
|
|
|
# Standard port on which Conduit launches.
|
|
|
|
# You still need to map the port when using the docker command or docker-compose.
|
|
|
|
EXPOSE 6167
|
|
|
|
|
2022-02-16 14:04:32 +00:00
|
|
|
# Users are expected to mount a volume to this directory:
|
|
|
|
ARG DEFAULT_DB_PATH=/var/lib/matrix-conduit
|
|
|
|
|
|
|
|
ENV CONDUIT_PORT=6167 \
|
|
|
|
CONDUIT_ADDRESS="0.0.0.0" \
|
|
|
|
CONDUIT_DATABASE_PATH=${DEFAULT_DB_PATH} \
|
|
|
|
CONDUIT_CONFIG=''
|
|
|
|
# └─> Set no config file to do all configuration with env vars
|
2021-11-21 17:34:08 +00:00
|
|
|
|
|
|
|
# Conduit needs:
|
|
|
|
# ca-certificates: for https
|
2022-02-01 23:51:38 +00:00
|
|
|
# iproute2: for `ss` for the healthcheck script
|
2021-08-31 21:17:32 +00:00
|
|
|
RUN apk add --no-cache \
|
2022-02-01 23:51:38 +00:00
|
|
|
ca-certificates \
|
|
|
|
iproute2
|
2021-08-31 21:17:32 +00:00
|
|
|
|
2021-07-19 15:18:25 +00:00
|
|
|
ARG CREATED
|
|
|
|
ARG VERSION
|
|
|
|
ARG GIT_REF
|
|
|
|
# Labels according to https://github.com/opencontainers/image-spec/blob/master/annotations.md
|
|
|
|
# including a custom label specifying the build command
|
|
|
|
LABEL org.opencontainers.image.created=${CREATED} \
|
2021-12-15 10:14:20 +00:00
|
|
|
org.opencontainers.image.authors="Conduit Contributors" \
|
|
|
|
org.opencontainers.image.title="Conduit" \
|
|
|
|
org.opencontainers.image.version=${VERSION} \
|
|
|
|
org.opencontainers.image.vendor="Conduit Contributors" \
|
|
|
|
org.opencontainers.image.description="A Matrix homeserver written in Rust" \
|
|
|
|
org.opencontainers.image.url="https://conduit.rs/" \
|
|
|
|
org.opencontainers.image.revision=${GIT_REF} \
|
|
|
|
org.opencontainers.image.source="https://gitlab.com/famedly/conduit.git" \
|
|
|
|
org.opencontainers.image.licenses="Apache-2.0" \
|
|
|
|
org.opencontainers.image.documentation="https://gitlab.com/famedly/conduit" \
|
|
|
|
org.opencontainers.image.ref.name=""
|
2021-07-19 15:18:25 +00:00
|
|
|
|
|
|
|
|
2021-11-21 17:34:08 +00:00
|
|
|
# Test if Conduit is still alive, uses the same endpoint as Element
|
2021-11-25 22:36:44 +00:00
|
|
|
COPY ./docker/healthcheck.sh /srv/conduit/healthcheck.sh
|
2021-11-21 17:34:08 +00:00
|
|
|
HEALTHCHECK --start-period=5s --interval=5s CMD ./healthcheck.sh
|
|
|
|
|
|
|
|
# Improve security: Don't run stuff as root, that does not need to run as root:
|
2022-02-16 14:04:32 +00:00
|
|
|
# Most distros also use 1000:1000 for the first real user, so this should resolve volume mounting problems.
|
|
|
|
ARG USER_ID=1000
|
|
|
|
ARG GROUP_ID=1000
|
2021-07-19 15:18:25 +00:00
|
|
|
RUN set -x ; \
|
2022-02-16 14:04:32 +00:00
|
|
|
deluser --remove-home www-data ; \
|
|
|
|
addgroup -S -g ${GROUP_ID} conduit 2>/dev/null ; \
|
|
|
|
adduser -S -u ${USER_ID} -D -H -h /srv/conduit -G conduit -g conduit conduit 2>/dev/null ; \
|
|
|
|
addgroup conduit conduit 2>/dev/null && exit 0 ; exit 1
|
2021-07-19 15:18:25 +00:00
|
|
|
|
2022-02-16 14:04:32 +00:00
|
|
|
# Change ownership of Conduit files to conduit user and group
|
|
|
|
RUN chown -cR conduit:conduit /srv/conduit && \
|
2022-02-22 15:22:53 +00:00
|
|
|
chmod +x /srv/conduit/healthcheck.sh && \
|
|
|
|
mkdir -p ${DEFAULT_DB_PATH} && \
|
|
|
|
chown -cR conduit:conduit ${DEFAULT_DB_PATH}
|
2021-07-19 15:18:25 +00:00
|
|
|
|
2022-02-16 14:04:32 +00:00
|
|
|
# Change user to conduit
|
|
|
|
USER conduit
|
2021-07-19 15:18:25 +00:00
|
|
|
# Set container home directory
|
|
|
|
WORKDIR /srv/conduit
|
2021-11-21 17:34:08 +00:00
|
|
|
|
|
|
|
# Run Conduit and print backtraces on panics
|
|
|
|
ENV RUST_BACKTRACE=1
|
2021-07-19 15:18:25 +00:00
|
|
|
ENTRYPOINT [ "/srv/conduit/conduit" ]
|
2022-02-16 14:04:32 +00:00
|
|
|
|
|
|
|
# Depending on the target platform (e.g. "linux/arm/v7", "linux/arm64/v8", or "linux/amd64")
|
|
|
|
# copy the matching binary into this docker image
|
|
|
|
ARG TARGETPLATFORM
|
|
|
|
COPY --chown=conduit:conduit ./$TARGETPLATFORM /srv/conduit/conduit
|