2020-09-02 11:42:48 -04:00
|
|
|
FROM ekidd/rust-musl-builder:nightly-2020-05-07 as rust
|
2019-04-10 14:10:57 -04:00
|
|
|
|
2019-05-13 20:46:29 -04:00
|
|
|
# Cache deps
|
2019-04-10 14:10:57 -04:00
|
|
|
WORKDIR /app
|
2019-11-02 02:41:57 -04:00
|
|
|
RUN sudo chown -R rust:rust .
|
2019-04-10 14:10:57 -04:00
|
|
|
RUN USER=root cargo new server
|
2020-09-02 11:42:48 -04:00
|
|
|
|
|
|
|
# Install cargo-build-deps
|
|
|
|
RUN cargo install --git https://github.com/romac/cargo-build-deps.git
|
2019-04-09 18:33:49 -04:00
|
|
|
WORKDIR /app/server
|
2020-09-02 19:17:35 -04:00
|
|
|
RUN mkdir -p lemmy_db/src/ \
|
|
|
|
lemmy_utils/src/ \
|
2020-09-16 06:25:22 -04:00
|
|
|
lemmy_structs/src/ \
|
2020-09-02 19:17:35 -04:00
|
|
|
lemmy_rate_limit/src/ \
|
2020-09-24 09:53:21 -04:00
|
|
|
lemmy_api/src/ \
|
|
|
|
lemmy_apub/src/ \
|
|
|
|
lemmy_websocket/src/ \
|
2020-09-02 19:17:35 -04:00
|
|
|
lemmy
|
2020-09-02 11:42:48 -04:00
|
|
|
|
|
|
|
# Copy the cargo tomls
|
2020-09-15 15:26:47 -04:00
|
|
|
COPY Cargo.toml Cargo.lock ./
|
|
|
|
COPY lemmy_db/Cargo.toml ./lemmy_db/
|
|
|
|
COPY lemmy_utils/Cargo.toml ./lemmy_utils/
|
2020-09-16 06:25:22 -04:00
|
|
|
COPY lemmy_structs/Cargo.toml ./lemmy_structs/
|
2020-09-15 15:26:47 -04:00
|
|
|
COPY lemmy_rate_limit/Cargo.toml ./lemmy_rate_limit/
|
2020-09-24 09:53:21 -04:00
|
|
|
COPY lemmy_api/Cargo.toml ./lemmy_api/
|
|
|
|
COPY lemmy_apub/Cargo.toml ./lemmy_apub/
|
|
|
|
COPY lemmy_websocket/Cargo.toml ./lemmy_websocket/
|
2020-09-02 11:42:48 -04:00
|
|
|
|
|
|
|
# Cache the deps
|
|
|
|
RUN cargo build-deps
|
|
|
|
|
|
|
|
# Copy the src folders
|
2020-09-15 15:26:47 -04:00
|
|
|
COPY src ./src/
|
|
|
|
COPY lemmy_db/src ./lemmy_db/src/
|
|
|
|
COPY lemmy_utils/src/ ./lemmy_utils/src/
|
2020-09-16 06:25:22 -04:00
|
|
|
COPY lemmy_structs/src/ ./lemmy_structs/src/
|
2020-09-15 15:26:47 -04:00
|
|
|
COPY lemmy_rate_limit/src/ ./lemmy_rate_limit/src/
|
2020-09-24 09:53:21 -04:00
|
|
|
COPY lemmy_api/src/ ./lemmy_api/src/
|
|
|
|
COPY lemmy_apub/src/ ./lemmy_apub/src/
|
|
|
|
COPY lemmy_websocket/src/ ./lemmy_websocket/src/
|
2020-09-15 15:26:47 -04:00
|
|
|
COPY migrations ./migrations/
|
2019-04-10 14:10:57 -04:00
|
|
|
|
2020-06-12 09:29:50 -04:00
|
|
|
# Build for debug
|
2020-06-14 16:36:18 -04:00
|
|
|
RUN cargo build
|
2020-01-01 12:01:49 -05:00
|
|
|
|
2020-09-02 11:42:48 -04:00
|
|
|
FROM ekidd/rust-musl-builder:nightly-2020-05-07 as docs
|
2020-01-01 12:01:49 -05:00
|
|
|
WORKDIR /app
|
|
|
|
COPY docs ./docs
|
|
|
|
RUN sudo chown -R rust:rust .
|
|
|
|
RUN mdbook build docs/
|
|
|
|
|
2020-06-14 16:36:18 -04:00
|
|
|
FROM alpine:3.12
|
2019-05-13 20:46:29 -04:00
|
|
|
|
|
|
|
# Install libpq for postgres
|
|
|
|
RUN apk add libpq
|
|
|
|
|
2020-07-29 09:02:46 -04:00
|
|
|
# Install Espeak for captchas
|
|
|
|
RUN apk add espeak
|
|
|
|
|
2019-05-13 20:46:29 -04:00
|
|
|
# Copy resources
|
2020-09-15 15:26:47 -04:00
|
|
|
COPY config/defaults.hjson /config/defaults.hjson
|
2020-06-12 09:29:50 -04:00
|
|
|
COPY --from=rust /app/server/target/x86_64-unknown-linux-musl/debug/lemmy_server /app/lemmy
|
2020-09-15 15:26:47 -04:00
|
|
|
COPY --from=docs /app/docs/book/ /app/documentation/
|
2019-12-17 16:35:48 -05:00
|
|
|
|
2019-05-13 20:46:29 -04:00
|
|
|
RUN addgroup -g 1000 lemmy
|
|
|
|
RUN adduser -D -s /bin/sh -u 1000 -G lemmy lemmy
|
|
|
|
RUN chown lemmy:lemmy /app/lemmy
|
|
|
|
USER lemmy
|
2019-04-06 19:48:54 -04:00
|
|
|
EXPOSE 8536
|
2019-05-13 20:46:29 -04:00
|
|
|
CMD ["/app/lemmy"]
|