lemmy/docker/dev/Dockerfile

48 lines
1.1 KiB
Docker
Raw Normal View History

2021-11-09 17:16:59 -05:00
ARG RUST_BUILDER_IMAGE=clux/muslrust:1.56.0
2019-04-10 14:10:57 -04:00
2021-11-09 17:16:59 -05:00
FROM $RUST_BUILDER_IMAGE as chef
USER root
2021-02-24 17:10:28 -05:00
RUN cargo install cargo-chef
2021-11-09 17:16:59 -05:00
WORKDIR /app
# Cargo chef plan
FROM chef as planner
ENV RUSTFLAGS="--cfg tokio_unstable"
# Copy dirs
2021-11-09 17:16:59 -05:00
COPY . .
RUN cargo chef prepare --recipe-path recipe.json
2021-11-09 17:16:59 -05:00
FROM chef as builder
ARG CARGO_BUILD_TARGET=x86_64-unknown-linux-musl
ARG RUSTRELEASEDIR="debug"
ENV RUSTFLAGS="--cfg tokio_unstable"
2020-09-02 11:42:48 -04:00
2021-11-09 17:16:59 -05:00
COPY --from=planner /app/recipe.json ./recipe.json
RUN cargo chef cook --recipe-path recipe.json --target ${CARGO_BUILD_TARGET}
# Copy the rest of the dirs
2021-11-09 17:16:59 -05:00
COPY . .
2021-11-09 17:16:59 -05:00
# Build the project
RUN echo "pub const VERSION: &str = \"$(git describe --tag)\";" > "crates/utils/src/version.rs"
2021-11-09 17:16:59 -05:00
RUN cargo build --target ${CARGO_BUILD_TARGET}
2019-04-10 14:10:57 -04:00
# reduce binary size
RUN strip ./target/$CARGO_BUILD_TARGET/$RUSTRELEASEDIR/lemmy_server
2020-01-01 12:01:49 -05:00
RUN cp ./target/$CARGO_BUILD_TARGET/$RUSTRELEASEDIR/lemmy_server /app/lemmy_server
# The alpine runner
FROM alpine:3 as lemmy
# Install libpq for postgres
RUN apk add libpq
# Copy resources
2021-11-09 17:16:59 -05:00
COPY --from=builder /app/lemmy_server /app/lemmy
EXPOSE 8536
CMD ["/app/lemmy"]