2019-04-05 22:29:20 -07:00
|
|
|
FROM node:10-jessie as node
|
2019-08-28 19:26:42 -07:00
|
|
|
|
2019-04-09 21:45:10 -07:00
|
|
|
WORKDIR /app/ui
|
2019-04-17 16:55:57 -07:00
|
|
|
|
2019-05-13 17:46:29 -07:00
|
|
|
# Cache deps
|
2019-04-17 16:55:57 -07:00
|
|
|
COPY ui/package.json ui/yarn.lock ./
|
2019-05-13 17:46:29 -07:00
|
|
|
RUN yarn install --pure-lockfile
|
|
|
|
|
|
|
|
# Build
|
2019-04-17 16:55:57 -07:00
|
|
|
COPY ui /app/ui
|
2019-04-09 21:45:10 -07:00
|
|
|
RUN yarn build
|
2019-04-05 22:29:20 -07:00
|
|
|
|
2020-01-11 19:07:44 -05:00
|
|
|
FROM ekidd/rust-musl-builder:1.40.0-openssl11 as rust
|
2019-04-10 11:10:57 -07:00
|
|
|
|
2019-05-13 17:46:29 -07:00
|
|
|
# Cache deps
|
2019-04-10 11:10:57 -07:00
|
|
|
WORKDIR /app
|
2019-11-01 23:41:57 -07:00
|
|
|
RUN sudo chown -R rust:rust .
|
2019-04-10 11:10:57 -07:00
|
|
|
RUN USER=root cargo new server
|
2019-04-09 15:33:49 -07:00
|
|
|
WORKDIR /app/server
|
2019-04-10 11:10:57 -07:00
|
|
|
COPY server/Cargo.toml server/Cargo.lock ./
|
2019-11-01 23:41:57 -07:00
|
|
|
RUN sudo chown -R rust:rust .
|
|
|
|
RUN mkdir -p ./src/bin \
|
2019-04-10 11:10:57 -07:00
|
|
|
&& echo 'fn main() { println!("Dummy") }' > ./src/bin/main.rs
|
2019-11-19 18:07:10 +01:00
|
|
|
RUN cargo build --release
|
2019-05-13 17:46:29 -07:00
|
|
|
RUN rm -f ./target/x86_64-unknown-linux-musl/release/deps/lemmy_server*
|
2019-04-10 11:10:57 -07:00
|
|
|
COPY server/src ./src/
|
|
|
|
COPY server/migrations ./migrations/
|
|
|
|
|
2019-11-01 23:41:57 -07:00
|
|
|
# Build for release
|
|
|
|
RUN cargo build --frozen --release
|
2019-04-10 11:10:57 -07:00
|
|
|
|
2019-04-21 16:37:54 -07:00
|
|
|
# Get diesel-cli on there just in case
|
2019-04-24 10:33:17 -07:00
|
|
|
# RUN cargo install diesel_cli --no-default-features --features postgres
|
2019-04-21 16:37:54 -07:00
|
|
|
|
2020-01-01 18:01:49 +01:00
|
|
|
|
2020-01-11 19:07:44 -05:00
|
|
|
FROM ekidd/rust-musl-builder:1.40.0-openssl11 as docs
|
2020-01-01 18:01:49 +01:00
|
|
|
WORKDIR /app
|
|
|
|
COPY docs ./docs
|
|
|
|
RUN sudo chown -R rust:rust .
|
|
|
|
RUN mdbook build docs/
|
|
|
|
|
|
|
|
|
2019-08-28 19:26:42 -07:00
|
|
|
FROM alpine:3.10
|
2019-05-13 17:46:29 -07:00
|
|
|
|
|
|
|
# Install libpq for postgres
|
|
|
|
RUN apk add libpq
|
|
|
|
|
|
|
|
# Copy resources
|
2019-12-26 20:48:13 +01:00
|
|
|
COPY server/config/defaults.hjson /config/defaults.hjson
|
2019-05-13 17:46:29 -07:00
|
|
|
COPY --from=rust /app/server/target/x86_64-unknown-linux-musl/release/lemmy_server /app/lemmy
|
2020-01-01 18:01:49 +01:00
|
|
|
COPY --from=docs /app/docs/book/ /app/dist/documentation/
|
2019-04-05 22:29:20 -07:00
|
|
|
COPY --from=node /app/ui/dist /app/dist
|
2019-12-17 22:35:48 +01:00
|
|
|
|
2019-05-13 17:46:29 -07: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 16:48:54 -07:00
|
|
|
EXPOSE 8536
|
2019-05-13 17:46:29 -07:00
|
|
|
CMD ["/app/lemmy"]
|