From: Dessalines Date: Mon, 31 Aug 2020 21:47:31 +0000 (-0500) Subject: Fixing docker caching. X-Git-Url: http://these/git/%22https:/image.com/readmes/%7B%60%24%7BarchiveUrl%7D/%7Bnode.comment.attributed_to%7D?a=commitdiff_plain;h=dc1bc741b4643f25d1120461a67e68c05aa34fab;p=lemmy.git Fixing docker caching. --- diff --git a/docker/dev/Dockerfile b/docker/dev/Dockerfile index afbdbbbe..4688e2dd 100644 --- a/docker/dev/Dockerfile +++ b/docker/dev/Dockerfile @@ -17,14 +17,19 @@ WORKDIR /app RUN sudo chown -R rust:rust . RUN USER=root cargo new server WORKDIR /app/server +RUN mkdir -p lemmy_db/src/ lemmy_utils/src/ COPY server/Cargo.toml server/Cargo.lock ./ -COPY server/lemmy_db ./lemmy_db -COPY server/lemmy_utils ./lemmy_utils +COPY server/lemmy_db/Cargo.toml ./lemmy_db/ +COPY server/lemmy_utils/Cargo.toml ./lemmy_utils/ RUN mkdir -p ./src/bin \ - && echo 'fn main() { println!("Dummy") }' > ./src/bin/main.rs + && 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 RUN cargo build -RUN find target/debug -type f -name "$(echo "lemmy_server" | tr '-' '_')*" -exec touch -t 200001010000 {} + +RUN rm -f ./target/x86_64-unknown-linux-musl/debug/deps/lemmy_server* COPY server/src ./src/ +COPY server/lemmy_db ./lemmy_db/ +COPY server/lemmy_utils ./lemmy_utils/ COPY server/migrations ./migrations/ # Build for debug diff --git a/docker/prod/Dockerfile b/docker/prod/Dockerfile index 845df88d..6e4de2be 100644 --- a/docker/prod/Dockerfile +++ b/docker/prod/Dockerfile @@ -10,14 +10,19 @@ WORKDIR /app RUN sudo chown -R rust:rust . RUN USER=root cargo new server WORKDIR /app/server +RUN mkdir -p lemmy_db/src/ lemmy_utils/src/ COPY server/Cargo.toml server/Cargo.lock ./ -COPY server/lemmy_db ./lemmy_db -COPY server/lemmy_utils ./lemmy_utils +COPY server/lemmy_db/Cargo.toml ./lemmy_db/ +COPY server/lemmy_utils/Cargo.toml ./lemmy_utils/ RUN mkdir -p ./src/bin \ - && echo 'fn main() { println!("Dummy") }' > ./src/bin/main.rs + && 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 RUN cargo build --release RUN find target/$CARGO_BUILD_TARGET/$RUSTRELEASEDIR -type f -name "$(echo "lemmy_server" | tr '-' '_')*" -exec touch -t 200001010000 {} + COPY server/src ./src/ +COPY server/lemmy_db ./lemmy_db/ +COPY server/lemmy_utils ./lemmy_utils/ COPY server/migrations ./migrations/ # build for release