From ba0680f5e69ad78a466fc84c17abe282dfa41985 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Mon, 26 Oct 2020 12:18:47 -0500 Subject: [PATCH 1/4] Simplifying prod build, using musl stable. --- .dockerignore | 10 +++------- docker/prod/Dockerfile | 25 ++----------------------- 2 files changed, 5 insertions(+), 30 deletions(-) diff --git a/.dockerignore b/.dockerignore index 255caf67f..b336eeeb1 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,12 +1,8 @@ # build folders and similar which are not needed for the docker build -ui/node_modules -server/target +target docker/dev/volumes +docker/prod/volumes docker/federation/volumes -docker/federation-test/volumes +docker/travis/volumes .git ansible - -# exceptions, needed for federation-test build - -!server/target/debug/lemmy_server diff --git a/docker/prod/Dockerfile b/docker/prod/Dockerfile index 137adc462..09c542f04 100644 --- a/docker/prod/Dockerfile +++ b/docker/prod/Dockerfile @@ -1,33 +1,12 @@ -ARG RUST_BUILDER_IMAGE=shtripok/rust-musl-builder:arm +ARG RUST_BUILDER_IMAGE=ekidd/rust-musl-builder:stable FROM $RUST_BUILDER_IMAGE as rust -#ARG RUSTRELEASEDIR="debug" ARG RUSTRELEASEDIR="release" -# Cache deps -WORKDIR /app -RUN sudo chown -R rust:rust . -RUN USER=root cargo new server WORKDIR /app/server -COPY Cargo.toml Cargo.lock ./ -COPY lemmy_db ./lemmy_db -COPY lemmy_utils ./lemmy_utils -COPY lemmy_structs ./lemmy_structs -COPY lemmy_rate_limit ./lemmy_rate_limit -COPY lemmy_api ./lemmy_api -COPY lemmy_apub ./lemmy_apub -COPY lemmy_websocket ./lemmy_websocket -RUN mkdir -p ./src/bin \ - && echo 'fn main() { println!("Dummy") }' > ./src/bin/main.rs +COPY . ./ RUN cargo build --release -RUN find target/$CARGO_BUILD_TARGET/$RUSTRELEASEDIR -type f -name "$(echo "lemmy_server" | tr '-' '_')*" -exec touch -t 200001010000 {} + -COPY src ./src/ -COPY migrations ./migrations/ - -# build for release -# workaround for https://github.com/rust-lang/rust/issues/62896 -RUN cargo build --frozen --release # reduce binary size RUN strip ./target/$CARGO_BUILD_TARGET/$RUSTRELEASEDIR/lemmy_server From b42b46141857043615a497ed2d42e83363a5ea1b Mon Sep 17 00:00:00 2001 From: Dessalines Date: Mon, 26 Oct 2020 13:35:19 -0500 Subject: [PATCH 2/4] Trying a permissions fix. --- docker/prod/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/docker/prod/Dockerfile b/docker/prod/Dockerfile index 09c542f04..3b8186a21 100644 --- a/docker/prod/Dockerfile +++ b/docker/prod/Dockerfile @@ -5,6 +5,7 @@ FROM $RUST_BUILDER_IMAGE as rust ARG RUSTRELEASEDIR="release" WORKDIR /app/server +RUN sudo chown -R rust:rust . COPY . ./ RUN cargo build --release From 3100e8bf21c69d73f7e4e4d6ba08c3f343e8c45b Mon Sep 17 00:00:00 2001 From: Dessalines Date: Mon, 26 Oct 2020 15:50:37 -0500 Subject: [PATCH 3/4] Trying a target fix. --- docker/prod/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/prod/Dockerfile b/docker/prod/Dockerfile index 3b8186a21..b1a7c60d2 100644 --- a/docker/prod/Dockerfile +++ b/docker/prod/Dockerfile @@ -1,9 +1,9 @@ ARG RUST_BUILDER_IMAGE=ekidd/rust-musl-builder:stable +ARG CARGO_BUILD_TARGET=x86_64-unknown-linux-musl +ARG RUSTRELEASEDIR="release" FROM $RUST_BUILDER_IMAGE as rust -ARG RUSTRELEASEDIR="release" - WORKDIR /app/server RUN sudo chown -R rust:rust . COPY . ./ From 2e922d602d8c87495a3dd51d4dc49452b765f2b6 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Mon, 26 Oct 2020 17:32:50 -0500 Subject: [PATCH 4/4] Trying a target fix. --- docker/prod/Dockerfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docker/prod/Dockerfile b/docker/prod/Dockerfile index b1a7c60d2..b70154cd7 100644 --- a/docker/prod/Dockerfile +++ b/docker/prod/Dockerfile @@ -1,9 +1,10 @@ ARG RUST_BUILDER_IMAGE=ekidd/rust-musl-builder:stable -ARG CARGO_BUILD_TARGET=x86_64-unknown-linux-musl -ARG RUSTRELEASEDIR="release" FROM $RUST_BUILDER_IMAGE as rust +ARG CARGO_BUILD_TARGET=x86_64-unknown-linux-musl +ARG RUSTRELEASEDIR="release" + WORKDIR /app/server RUN sudo chown -R rust:rust . COPY . ./