Use romacs cargo-build-deps tool.

This commit is contained in:
Dessalines 2020-09-02 10:42:48 -05:00
parent dc1bc741b4
commit e3140235de
4 changed files with 25 additions and 18 deletions

24
docker/dev/Dockerfile vendored
View File

@ -10,32 +10,36 @@ RUN yarn install --pure-lockfile
COPY ui /app/ui
RUN yarn build
FROM ekidd/rust-musl-builder:1.42.0-openssl11 as rust
FROM ekidd/rust-musl-builder:nightly-2020-05-07 as rust
# Cache deps
WORKDIR /app
RUN sudo chown -R rust:rust .
RUN USER=root cargo new server
# Install cargo-build-deps
RUN cargo install --git https://github.com/romac/cargo-build-deps.git
WORKDIR /app/server
RUN mkdir -p lemmy_db/src/ lemmy_utils/src/
# Copy the cargo tomls
COPY server/Cargo.toml server/Cargo.lock ./
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 \
&& cp ./src/bin/main.rs ./lemmy_db/src/main.rs \
&& cp ./src/bin/main.rs ./lemmy_utils/src/main.rs
RUN cargo build
RUN rm -f ./target/x86_64-unknown-linux-musl/debug/deps/lemmy_server*
# Cache the deps
RUN cargo build-deps
# Copy the src folders
COPY server/src ./src/
COPY server/lemmy_db ./lemmy_db/
COPY server/lemmy_utils ./lemmy_utils/
COPY server/lemmy_db/src ./lemmy_db/src/
COPY server/lemmy_utils/src/ ./lemmy_utils/src/
COPY server/migrations ./migrations/
# Build for debug
RUN cargo build
FROM ekidd/rust-musl-builder:1.42.0-openssl11 as docs
FROM ekidd/rust-musl-builder:nightly-2020-05-07 as docs
WORKDIR /app
COPY docs ./docs
RUN sudo chown -R rust:rust .

View File

@ -10,19 +10,14 @@ 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/Cargo.toml ./lemmy_db/
COPY server/lemmy_utils/Cargo.toml ./lemmy_utils/
COPY server/lemmy_db ./lemmy_db
COPY server/lemmy_utils ./lemmy_utils
RUN mkdir -p ./src/bin \
&& 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
&& echo 'fn main() { println!("Dummy") }' > ./src/bin/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

View File

@ -3,6 +3,10 @@ name = "lemmy_db"
version = "0.1.0"
edition = "2018"
[lib]
name = "lemmy_db"
path = "src/lib.rs"
[dependencies]
diesel = { version = "1.4.4", features = ["postgres","chrono","r2d2","64-column-tables","serde_json"] }
chrono = { version = "0.4.7", features = ["serde"] }

View File

@ -3,6 +3,10 @@ name = "lemmy_utils"
version = "0.1.0"
edition = "2018"
[lib]
name = "lemmy_utils"
path = "src/lib.rs"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]