lemmy/docker/dev/Dockerfile

64 lines
1.6 KiB
Docker
Raw Normal View History

FROM node:10-jessie as node
2019-08-28 22:26:42 -04:00
2019-04-10 00:45:10 -04:00
WORKDIR /app/ui
2019-04-17 19:55:57 -04:00
# Cache deps
2019-04-17 19:55:57 -04:00
COPY ui/package.json ui/yarn.lock ./
RUN yarn install --pure-lockfile
# Build
2019-04-17 19:55:57 -04:00
COPY ui /app/ui
2019-04-10 00:45:10 -04:00
RUN yarn build
FROM ekidd/rust-musl-builder:1.42.0-openssl11 as rust
2019-04-10 14:10:57 -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
2019-04-09 18:33:49 -04:00
WORKDIR /app/server
2020-08-31 17:47:31 -04:00
RUN mkdir -p lemmy_db/src/ lemmy_utils/src/
2019-04-10 14:10:57 -04:00
COPY server/Cargo.toml server/Cargo.lock ./
2020-08-31 17:47:31 -04:00
COPY server/lemmy_db/Cargo.toml ./lemmy_db/
COPY server/lemmy_utils/Cargo.toml ./lemmy_utils/
2019-11-02 02:41:57 -04:00
RUN mkdir -p ./src/bin \
2020-08-31 17:47:31 -04:00
&& echo 'fn main() { println!("Dummy") }' > ./src/bin/main.rs \
&& cp ./src/bin/main.rs ./lemmy_db/src/main.rs \
&& cp ./src/bin/main.rs ./lemmy_utils/src/main.rs
2020-06-14 16:36:18 -04:00
RUN cargo build
2020-08-31 17:47:31 -04:00
RUN rm -f ./target/x86_64-unknown-linux-musl/debug/deps/lemmy_server*
2019-04-10 14:10:57 -04:00
COPY server/src ./src/
2020-08-31 17:47:31 -04:00
COPY server/lemmy_db ./lemmy_db/
COPY server/lemmy_utils ./lemmy_utils/
2019-04-10 14:10:57 -04:00
COPY server/migrations ./migrations/
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
FROM ekidd/rust-musl-builder:1.42.0-openssl11 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
# Install libpq for postgres
RUN apk add libpq
# Install Espeak for captchas
RUN apk add espeak
# Copy resources
2019-12-26 14:48:13 -05:00
COPY server/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-01-01 12:01:49 -05:00
COPY --from=docs /app/docs/book/ /app/dist/documentation/
COPY --from=node /app/ui/dist /app/dist
RUN addgroup -g 1000 lemmy
RUN adduser -D -s /bin/sh -u 1000 -G lemmy lemmy
RUN chown lemmy:lemmy /app/lemmy
USER lemmy
EXPOSE 8536
CMD ["/app/lemmy"]