2022-11-09 10:05:00 +00:00
|
|
|
ARG RUST_BUILDER_IMAGE=rust:1.64-slim-buster
|
2020-12-22 12:13:51 +00:00
|
|
|
|
|
|
|
# Build Lemmy
|
|
|
|
FROM $RUST_BUILDER_IMAGE as builder
|
|
|
|
|
|
|
|
# Install compilation dependencies
|
|
|
|
RUN apt-get update \
|
2021-12-06 00:35:50 +00:00
|
|
|
&& apt-get -y install --no-install-recommends libssl-dev pkg-config libpq-dev git \
|
2020-12-22 12:13:51 +00:00
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
COPY ./ ./
|
2021-04-12 11:47:58 +00:00
|
|
|
RUN echo "pub const VERSION: &str = \"$(git describe --tag)\";" > "crates/utils/src/version.rs"
|
2020-12-22 12:13:51 +00:00
|
|
|
|
|
|
|
RUN cargo build --release
|
|
|
|
|
|
|
|
RUN cp ./target/release/lemmy_server /app/lemmy_server
|
|
|
|
|
|
|
|
# The Debian runner
|
|
|
|
FROM debian:buster-slim as lemmy
|
|
|
|
|
2021-04-01 17:30:24 +00:00
|
|
|
# Install libpq for postgres
|
2020-12-22 12:13:51 +00:00
|
|
|
RUN apt-get update \
|
2021-12-06 00:35:50 +00:00
|
|
|
&& apt-get -y install --no-install-recommends postgresql-client libc6 libssl1.1 ca-certificates \
|
2020-12-22 12:13:51 +00:00
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
|
|
RUN addgroup --gid 1000 lemmy
|
2021-12-06 00:35:50 +00:00
|
|
|
RUN useradd --no-create-home --shell /bin/sh --uid 1000 --gid 1000 lemmy
|
2020-12-22 12:13:51 +00:00
|
|
|
|
|
|
|
# Copy resources
|
|
|
|
COPY --chown=lemmy:lemmy --from=builder /app/lemmy_server /app/lemmy
|
|
|
|
|
|
|
|
RUN chown lemmy:lemmy /app/lemmy
|
|
|
|
USER lemmy
|
|
|
|
EXPOSE 8536
|
|
|
|
CMD ["/app/lemmy"]
|