Created
February 26, 2020 07:36
-
-
Save cbzehner/d6419589ac1345b0532d197406796c03 to your computer and use it in GitHub Desktop.
Rocket Dockerfile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM rustlang/rust:nightly | |
MAINTAINER "[email protected]" | |
ENV BUILD_DIR=/usr/src/<app_name> | |
RUN mkdir -p $BUILD_DIR | |
WORKDIR $BUILD_DIR | |
# TODO: Confirm this is actually needed to run `diesel setup` | |
# RUN cargo install diesel_cli --no-default-features --features postgres | |
# Cache the cargo build process using the Docker cache | |
# For details see "Fixing the docker cache utilization" (https://blog.sedrik.se/posts/my-docker-setup-for-rust/) | |
COPY Cargo.toml Cargo.lock rust-toolchain ./ | |
RUN mkdir src && echo "fn main() {}" > src/main.rs | |
RUN cargo test | |
RUN cargo build | |
COPY . . | |
RUN echo "Current directory: `pwd`" \ | |
&& echo "Directory contents: " && ls \ | |
&& echo "Add files to .dockerignore to exclude them" | |
# Touch the real main.rs file or else Docker will use the cached one | |
RUN touch src/main.rs | |
RUN cargo build | |
EXPOSE 8000 | |
ENTRYPOINT ["./target/debug/<app_name>"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment