mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-26 14:21:19 +00:00
Docker image now down to 35 MB, using alpine.
This commit is contained in:
parent
73a129a24d
commit
61bb201448
3 changed files with 27 additions and 20 deletions
45
Dockerfile
45
Dockerfile
|
@ -1,43 +1,50 @@
|
||||||
FROM node:10-jessie as node
|
FROM node:10-jessie as node
|
||||||
#If encounter Invalid cross-device error -run on host 'echo N | sudo tee /sys/module/overlay/parameters/metacopy'
|
|
||||||
WORKDIR /app/ui
|
WORKDIR /app/ui
|
||||||
|
|
||||||
|
# Cache deps
|
||||||
COPY ui/package.json ui/yarn.lock ./
|
COPY ui/package.json ui/yarn.lock ./
|
||||||
RUN yarn install --pure-lockfile # This caches your deps
|
RUN yarn install --pure-lockfile
|
||||||
|
|
||||||
|
# Build
|
||||||
COPY ui /app/ui
|
COPY ui /app/ui
|
||||||
RUN yarn build
|
RUN yarn build
|
||||||
|
|
||||||
FROM rust:1.33 as rust
|
FROM rust:latest as rust
|
||||||
|
|
||||||
# create a new empty shell project
|
# Install musl
|
||||||
|
RUN apt-get update
|
||||||
|
RUN apt-get install musl-tools -y
|
||||||
|
RUN rustup target add x86_64-unknown-linux-musl
|
||||||
|
|
||||||
|
# Cache deps
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
RUN USER=root cargo new server
|
RUN USER=root cargo new server
|
||||||
WORKDIR /app/server
|
WORKDIR /app/server
|
||||||
|
|
||||||
# copy over your manifests
|
|
||||||
COPY server/Cargo.toml server/Cargo.lock ./
|
COPY server/Cargo.toml server/Cargo.lock ./
|
||||||
|
|
||||||
# this build step will cache your dependencies
|
|
||||||
RUN mkdir -p ./src/bin \
|
RUN mkdir -p ./src/bin \
|
||||||
&& echo 'fn main() { println!("Dummy") }' > ./src/bin/main.rs
|
&& echo 'fn main() { println!("Dummy") }' > ./src/bin/main.rs
|
||||||
RUN cargo build --release
|
RUN RUSTFLAGS=-Clinker=musl-gcc cargo build --release --target=x86_64-unknown-linux-musl
|
||||||
RUN rm -r ./target/release/.fingerprint/lemmy_server-*
|
RUN rm -f ./target/x86_64-unknown-linux-musl/release/deps/lemmy_server*
|
||||||
|
|
||||||
# copy your source tree
|
|
||||||
# RUN rm -rf ./src/
|
|
||||||
COPY server/src ./src/
|
COPY server/src ./src/
|
||||||
COPY server/migrations ./migrations/
|
COPY server/migrations ./migrations/
|
||||||
|
|
||||||
# build for release
|
# build for release
|
||||||
RUN cargo build --frozen --release
|
RUN RUSTFLAGS=-Clinker=musl-gcc cargo build --frozen --release --target=x86_64-unknown-linux-musl
|
||||||
RUN mv /app/server/target/release/lemmy_server /app/lemmy
|
|
||||||
|
|
||||||
# Get diesel-cli on there just in case
|
# Get diesel-cli on there just in case
|
||||||
# RUN cargo install diesel_cli --no-default-features --features postgres
|
# RUN cargo install diesel_cli --no-default-features --features postgres
|
||||||
|
|
||||||
# The output image
|
FROM alpine:latest
|
||||||
# FROM debian:stable-slim
|
|
||||||
# RUN apt-get -y update && apt-get install -y postgresql-client
|
# Install libpq for postgres
|
||||||
# COPY --from=rust /app/server/target/release/lemmy /app/lemmy
|
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
|
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
|
EXPOSE 8536
|
||||||
|
CMD ["/app/lemmy"]
|
||||||
|
|
|
@ -16,7 +16,6 @@ services:
|
||||||
lemmy:
|
lemmy:
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
command: /bin/sh -c /app/lemmy
|
|
||||||
ports:
|
ports:
|
||||||
- "8536:8536"
|
- "8536:8536"
|
||||||
environment:
|
environment:
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
- [Classification types.](https://www.reddit.com/r/ModeratorDuck/wiki/subreddit_classification)
|
- [Classification types.](https://www.reddit.com/r/ModeratorDuck/wiki/subreddit_classification)
|
||||||
- [RES expando - Possibly make this into a switching react component.](https://github.com/honestbleeps/Reddit-Enhancement-Suite/tree/d21f55c21e734f47d8ed03fe0ebce5b16653b0bd/lib/modules/hosts)
|
- [RES expando - Possibly make this into a switching react component.](https://github.com/honestbleeps/Reddit-Enhancement-Suite/tree/d21f55c21e734f47d8ed03fe0ebce5b16653b0bd/lib/modules/hosts)
|
||||||
- [Temp Icon](https://www.flaticon.com/free-icon/mouse_194242)
|
- [Temp Icon](https://www.flaticon.com/free-icon/mouse_194242)
|
||||||
|
- [Rust docker build](https://shaneutt.com/blog/rust-fast-small-docker-image-builds/)
|
||||||
- Activitypub guides
|
- Activitypub guides
|
||||||
- https://blog.joinmastodon.org/2018/06/how-to-implement-a-basic-activitypub-server/
|
- https://blog.joinmastodon.org/2018/06/how-to-implement-a-basic-activitypub-server/
|
||||||
- https://raw.githubusercontent.com/w3c/activitypub/gh-pages/activitypub-tutorial.txt
|
- https://raw.githubusercontent.com/w3c/activitypub/gh-pages/activitypub-tutorial.txt
|
||||||
|
|
Loading…
Reference in a new issue