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.
|
|
|
|
# ---------------------------------------------------------------------------------------------------------
|
|
|
|
|
2021-12-15 10:14:20 +00:00
|
|
|
FROM docker.io/alpine:3.15.0 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
|
|
|
|
|
|
|
|
# Note from @jfowl: I would like to remove this in the future and just have the Docker version be configured with envs.
|
|
|
|
ENV CONDUIT_CONFIG="/srv/conduit/conduit.toml"
|
|
|
|
|
|
|
|
# Conduit needs:
|
|
|
|
# ca-certificates: for https
|
2021-08-31 21:17:32 +00:00
|
|
|
RUN apk add --no-cache \
|
2022-01-23 17:09:14 +00:00
|
|
|
ca-certificates
|
2021-08-31 21:17:32 +00:00
|
|
|
|
2021-11-21 17:34:08 +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
|
|
|
# Created directory for the database and media files
|
2021-07-19 15:18:25 +00:00
|
|
|
RUN mkdir -p /srv/conduit/.local/share/conduit
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
# 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 ./$TARGETPLATFORM /srv/conduit/conduit
|
|
|
|
|
2021-08-31 21:17:32 +00:00
|
|
|
|
2021-11-21 17:34:08 +00:00
|
|
|
# Improve security: Don't run stuff as root, that does not need to run as root:
|
2021-07-19 15:18:25 +00:00
|
|
|
# Add www-data user and group with UID 82, as used by alpine
|
|
|
|
# https://git.alpinelinux.org/aports/tree/main/nginx/nginx.pre-install
|
|
|
|
RUN set -x ; \
|
|
|
|
addgroup -Sg 82 www-data 2>/dev/null ; \
|
|
|
|
adduser -S -D -H -h /srv/conduit -G www-data -g www-data www-data 2>/dev/null ; \
|
|
|
|
addgroup www-data www-data 2>/dev/null && exit 0 ; exit 1
|
|
|
|
|
|
|
|
# Change ownership of Conduit files to www-data user and group
|
|
|
|
RUN chown -cR www-data:www-data /srv/conduit
|
2021-08-31 21:17:32 +00:00
|
|
|
RUN chmod +x /srv/conduit/healthcheck.sh
|
2021-07-19 15:18:25 +00:00
|
|
|
|
2021-11-21 17:34:08 +00:00
|
|
|
# Change user to www-data
|
2021-07-19 15:18:25 +00:00
|
|
|
USER www-data
|
|
|
|
# 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" ]
|