# syntax=docker/dockerfile:1 FROM docker.io/rust:1.53-alpine AS builder WORKDIR /usr/src/conduit # Install required packages to build Conduit and it's dependencies RUN apk add musl-dev # == Build dependencies without our own code separately for caching == # # Need a fake main.rs since Cargo refuses to build anything otherwise. # # See https://github.com/rust-lang/cargo/issues/2644 for a Cargo feature # request that would allow just dependencies to be compiled, presumably # regardless of whether source files are available. RUN mkdir src && touch src/lib.rs && echo 'fn main() {}' > src/main.rs COPY Cargo.toml Cargo.lock ./ RUN cargo build --release && rm -r src # Copy over actual Conduit sources COPY src src # main.rs and lib.rs need their timestamp updated for this to work correctly since # otherwise the build with the fake main.rs from above is newer than the # source files (COPY preserves timestamps). # # Builds conduit and places the binary at /usr/src/conduit/target/release/conduit RUN touch src/main.rs && touch src/lib.rs && cargo build --release # --------------------------------------------------------------------------------------------------------------- # Stuff below this line actually ends up in the resulting docker image # --------------------------------------------------------------------------------------------------------------- FROM docker.io/alpine:3.14 AS runner # Conduit needs: # ca-certificates: for https # curl: for the container's healtcheck # libgcc: Apparently this is needed, even if I (@jfowl) don't know exactly why. But whatever, it's not that big. RUN apk add --no-cache \ ca-certificates \ curl \ libgcc # Created directory for the database and media files RUN mkdir -p /srv/conduit/.local/share/conduit # Copy over the actual Conduit binary from the builder stage COPY --from=builder /usr/src/conduit/target/release/conduit /srv/conduit/ # 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" # Not strictly needed, but documents the port. EXPOSE 6167 WORKDIR /srv/conduit ENTRYPOINT [ "/srv/conduit/conduit" ]