1
0
Fork 0
mirror of https://github.com/LemmyNet/lemmy.git synced 2025-01-24 06:37:57 +00:00
lemmy/docker/dev/Dockerfile

52 lines
1.3 KiB
Text
Raw Normal View History

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
# Cache deps
2019-04-17 16:55:57 -07:00
COPY ui/package.json ui/yarn.lock ./
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-08-28 19:26:42 -07:00
FROM rust:1.37 as rust
# Install musl
RUN apt-get update
RUN apt-get install musl-tools -y
RUN rustup target add x86_64-unknown-linux-musl
2019-04-10 11:10:57 -07:00
# Cache deps
2019-04-10 11:10:57 -07:00
WORKDIR /app
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 ./
RUN mkdir -p ./src/bin \
&& echo 'fn main() { println!("Dummy") }' > ./src/bin/main.rs
RUN RUSTFLAGS=-Clinker=musl-gcc cargo build --release --target=x86_64-unknown-linux-musl
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/
# build for release
RUN RUSTFLAGS=-Clinker=musl-gcc cargo build --frozen --release --target=x86_64-unknown-linux-musl
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
2019-08-28 19:26:42 -07:00
FROM alpine:3.10
# Install libpq for postgres
RUN apk add libpq
# Copy resources
COPY --from=rust /app/server/target/x86_64-unknown-linux-musl/release/lemmy_server /app/lemmy
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"]