2019-04-06 05:29:20 +00:00
|
|
|
FROM node:10-jessie as node
|
2019-08-29 02:26:42 +00:00
|
|
|
|
2019-04-10 04:45:10 +00:00
|
|
|
WORKDIR /app/ui
|
2019-04-17 23:55:57 +00:00
|
|
|
|
2019-05-14 00:46:29 +00:00
|
|
|
# Cache deps
|
2019-04-17 23:55:57 +00:00
|
|
|
COPY ui/package.json ui/yarn.lock ./
|
2019-05-14 00:46:29 +00:00
|
|
|
RUN yarn install --pure-lockfile
|
|
|
|
|
|
|
|
# Build
|
2019-04-17 23:55:57 +00:00
|
|
|
COPY ui /app/ui
|
2019-04-10 04:45:10 +00:00
|
|
|
RUN yarn build
|
2019-04-06 05:29:20 +00:00
|
|
|
|
2020-09-02 15:42:48 +00:00
|
|
|
FROM ekidd/rust-musl-builder:nightly-2020-05-07 as rust
|
2019-04-10 18:10:57 +00:00
|
|
|
|
2019-05-14 00:46:29 +00:00
|
|
|
# Cache deps
|
2019-04-10 18:10:57 +00:00
|
|
|
WORKDIR /app
|
2019-11-02 06:41:57 +00:00
|
|
|
RUN sudo chown -R rust:rust .
|
2019-04-10 18:10:57 +00:00
|
|
|
RUN USER=root cargo new server
|
2020-09-02 15:42:48 +00:00
|
|
|
|
|
|
|
# Install cargo-build-deps
|
|
|
|
RUN cargo install --git https://github.com/romac/cargo-build-deps.git
|
2019-04-09 22:33:49 +00:00
|
|
|
WORKDIR /app/server
|
2020-08-31 21:47:31 +00:00
|
|
|
RUN mkdir -p lemmy_db/src/ lemmy_utils/src/
|
2020-09-02 15:42:48 +00:00
|
|
|
|
|
|
|
# Copy the cargo tomls
|
2019-04-10 18:10:57 +00:00
|
|
|
COPY server/Cargo.toml server/Cargo.lock ./
|
2020-08-31 21:47:31 +00:00
|
|
|
COPY server/lemmy_db/Cargo.toml ./lemmy_db/
|
|
|
|
COPY server/lemmy_utils/Cargo.toml ./lemmy_utils/
|
2020-09-02 15:42:48 +00:00
|
|
|
|
|
|
|
# Cache the deps
|
|
|
|
RUN cargo build-deps
|
|
|
|
|
|
|
|
# Copy the src folders
|
2019-04-10 18:10:57 +00:00
|
|
|
COPY server/src ./src/
|
2020-09-02 15:42:48 +00:00
|
|
|
COPY server/lemmy_db/src ./lemmy_db/src/
|
|
|
|
COPY server/lemmy_utils/src/ ./lemmy_utils/src/
|
2019-04-10 18:10:57 +00:00
|
|
|
COPY server/migrations ./migrations/
|
|
|
|
|
2020-06-12 13:29:50 +00:00
|
|
|
# Build for debug
|
2020-06-14 20:36:18 +00:00
|
|
|
RUN cargo build
|
2020-01-01 17:01:49 +00:00
|
|
|
|
2020-09-02 15:42:48 +00:00
|
|
|
FROM ekidd/rust-musl-builder:nightly-2020-05-07 as docs
|
2020-01-01 17:01:49 +00:00
|
|
|
WORKDIR /app
|
|
|
|
COPY docs ./docs
|
|
|
|
RUN sudo chown -R rust:rust .
|
|
|
|
RUN mdbook build docs/
|
|
|
|
|
2020-06-14 20:36:18 +00:00
|
|
|
FROM alpine:3.12
|
2019-05-14 00:46:29 +00:00
|
|
|
|
|
|
|
# Install libpq for postgres
|
|
|
|
RUN apk add libpq
|
|
|
|
|
2020-07-29 13:02:46 +00:00
|
|
|
# Install Espeak for captchas
|
|
|
|
RUN apk add espeak
|
|
|
|
|
2019-05-14 00:46:29 +00:00
|
|
|
# Copy resources
|
2019-12-26 19:48:13 +00:00
|
|
|
COPY server/config/defaults.hjson /config/defaults.hjson
|
2020-06-12 13:29:50 +00:00
|
|
|
COPY --from=rust /app/server/target/x86_64-unknown-linux-musl/debug/lemmy_server /app/lemmy
|
2020-01-01 17:01:49 +00:00
|
|
|
COPY --from=docs /app/docs/book/ /app/dist/documentation/
|
2019-04-06 05:29:20 +00:00
|
|
|
COPY --from=node /app/ui/dist /app/dist
|
2019-12-17 21:35:48 +00:00
|
|
|
|
2019-05-14 00:46:29 +00: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 23:48:54 +00:00
|
|
|
EXPOSE 8536
|
2019-05-14 00:46:29 +00:00
|
|
|
CMD ["/app/lemmy"]
|