2020-11-23 10:59:06 -05:00
|
|
|
# Build the project
|
2021-05-03 10:46:12 -04:00
|
|
|
FROM ekidd/rust-musl-builder:1.51.0 as builder
|
2020-06-12 09:29:50 -04:00
|
|
|
|
2020-10-26 18:32:50 -04:00
|
|
|
ARG CARGO_BUILD_TARGET=x86_64-unknown-linux-musl
|
|
|
|
ARG RUSTRELEASEDIR="release"
|
|
|
|
|
2020-11-23 10:59:06 -05:00
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
COPY ./ ./
|
|
|
|
|
2020-10-26 14:35:19 -04:00
|
|
|
RUN sudo chown -R rust:rust .
|
2021-04-12 07:47:58 -04:00
|
|
|
RUN echo "pub const VERSION: &str = \"$(git describe --tag)\";" > "crates/utils/src/version.rs"
|
2020-06-14 16:36:18 -04:00
|
|
|
RUN cargo build --release
|
2020-06-12 09:29:50 -04:00
|
|
|
|
|
|
|
# reduce binary size
|
2020-06-14 16:36:18 -04:00
|
|
|
RUN strip ./target/$CARGO_BUILD_TARGET/$RUSTRELEASEDIR/lemmy_server
|
2020-06-12 09:29:50 -04:00
|
|
|
|
2020-11-23 10:59:06 -05:00
|
|
|
RUN cp ./target/$CARGO_BUILD_TARGET/$RUSTRELEASEDIR/lemmy_server /app/lemmy_server
|
2020-06-14 16:36:18 -04:00
|
|
|
|
2020-11-23 10:59:06 -05:00
|
|
|
# The alpine runner
|
2020-06-14 16:36:18 -04:00
|
|
|
FROM alpine:3.12 as lemmy
|
2020-06-12 09:29:50 -04:00
|
|
|
|
|
|
|
# Install libpq for postgres
|
|
|
|
RUN apk add libpq
|
2020-07-29 09:02:46 -04:00
|
|
|
|
2020-06-14 16:36:18 -04:00
|
|
|
RUN addgroup -g 1000 lemmy
|
|
|
|
RUN adduser -D -s /bin/sh -u 1000 -G lemmy lemmy
|
2020-06-12 09:29:50 -04:00
|
|
|
|
|
|
|
# Copy resources
|
2020-11-23 10:59:06 -05:00
|
|
|
COPY --chown=lemmy:lemmy --from=builder /app/lemmy_server /app/lemmy
|
2020-06-12 09:29:50 -04:00
|
|
|
|
|
|
|
RUN chown lemmy:lemmy /app/lemmy
|
|
|
|
USER lemmy
|
|
|
|
EXPOSE 8536
|
|
|
|
CMD ["/app/lemmy"]
|