Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/coadler/cargo-bug-repro
https://github.com/coadler/cargo-bug-repro
Last synced: 13 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/coadler/cargo-bug-repro
- Owner: coadler
- Created: 2021-03-27T01:26:30.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2021-03-27T01:38:11.000Z (almost 4 years ago)
- Last Synced: 2024-12-23T16:44:33.490Z (16 days ago)
- Language: Shell
- Size: 1.95 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# cargo-bug-repro
In a Dockerfile, when a COPY directive replaces an existing file, `cargo`
still seems to think it's the same file. Only after `touch`ing it does the
cache reset.See the example Dockerfile:
```Dockerfile
FROM rust:1.51WORKDIR /src
RUN cargo init
COPY Cargo.toml Cargo.lock ./
RUN cargo buildCOPY . .
RUN cargo build
``````txt
$ docker run -it cargo-bug-broken /bin/bash
root@cbe6d78de04c:/src# ls
Cargo.lock Cargo.toml Dockerfile.broken Dockerfile.fixed src target test.shroot@cbe6d78de04c:/src# cat src/main.rs
fn main() {
println!("Goodbye, world!");
}root@cbe6d78de04c:/src# cargo build
Finished dev [unoptimized + debuginfo] target(s) in 0.00sroot@cbe6d78de04c:/src# ./target/debug/cargo-bug-repro
Hello, world!root@cbe6d78de04c:/src# touch src/main.rs
root@cbe6d78de04c:/src# cargo build
Compiling cargo-bug-repro v0.1.0 (/src)
Finished dev [unoptimized + debuginfo] target(s) in 0.23sroot@cbe6d78de04c:/src# ./target/debug/cargo-bug-repro
Goodbye, world!root@cbe6d78de04c:/src#
```As you can see, touching the file causes the cache to reset. A fixed
Dockerfile looks like this:```Dockerfile
FROM rust:1.51WORKDIR /src
RUN cargo init
COPY Cargo.toml Cargo.lock ./
RUN cargo buildCOPY . .
RUN touch src/main.rs && cargo build
```See test.sh for a comparison of running both the broken and fixed
Dockerfiles.