From 3a33697aa346dfe42100bb2ba2775eaa5f54af60 Mon Sep 17 00:00:00 2001 From: Paul Kuruvilla Date: Thu, 23 Sep 2021 20:33:32 +0100 Subject: [PATCH] Syncing with codecrafters-io/languages Created by https://github.com/codecrafters-io/languages --- Dockerfile | 13 ++++++++----- README.md | 3 +++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 353571d..e2da308 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM rust:1.43-buster +FROM rust:1.54-buster # Download docker-explorer ARG docker_explorer_version=v18 @@ -6,14 +6,17 @@ RUN curl --fail -Lo /usr/local/bin/docker-explorer https://github.com/codecrafte RUN chmod +x /usr/local/bin/docker-explorer # Grab the dependencies and compile them as they dont change much -WORKDIR /app COPY Cargo.toml /app/Cargo.toml COPY Cargo.lock /app/Cargo.lock -RUN mkdir src && echo "fn main() {}" > "src/main.rs" -RUN cargo build --release + +RUN mkdir /app/src +RUN echo 'fn main() { println!("Hello World!"); }' > /app/src/main.rs + +WORKDIR /app +RUN cargo build --release --target-dir=/tmp/codecrafters-docker-target +RUN cargo clean -p docker-starter-rust --release --target-dir=/tmp/codecrafters-docker-target # Grab the real code ADD . /app -WORKDIR /app ENTRYPOINT ["/app/your_docker.sh"] diff --git a/README.md b/README.md index 2bd67c3..899faa0 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,9 @@ You can then execute your program like this: mydocker run ubuntu:latest /usr/local/bin/docker-explorer echo hey ``` +This command compiles your Rust project, so it might be slow the first time you +run it. Subsequent runs will be fast. + # Passing the first stage CodeCrafters runs tests when you do a `git push`. Make an empty commit and push