General comment: Rocket Dockerfile with Alpine latest, Rust nightly, rustup #1738
Replies: 15 comments
-
Why not start with the alpine version of the Rust docker image? |
Beta Was this translation helpful? Give feedback.
-
That's a good idea. To get Rust nightly + Alpine latest, what would you use for "FROM"? |
Beta Was this translation helpful? Give feedback.
-
@joelparkerhenderson Here is a list of all official Rust docker images: https://hub.docker.com/_/rust?tab=tags |
Beta Was this translation helpful? Give feedback.
-
@olback Thank you. At that link, which image is Rust nightly + Alpine latest? |
Beta Was this translation helpful? Give feedback.
-
@joelparkerhenderson - you'll want something like:
|
Beta Was this translation helpful? Give feedback.
-
@joelparkerhenderson I didn't find a alpine nightly but threw is |
Beta Was this translation helpful? Give feedback.
-
https://hub.docker.com/r/rustlang/rust/tags (there's a 3.12 + nightly there)
|
Beta Was this translation helpful? Give feedback.
-
Thanks all! Right, I agree that link is the place to look. It doesn't seem to have Alpine latest + Rust nightly. I want the newest Alpine and newest Rust i.e. free of version numbers. |
Beta Was this translation helpful? Give feedback.
-
For building with postgres-connection (feature |
Beta Was this translation helpful? Give feedback.
-
@joelparkerhenderson I just run FROM rust:1.46 as build
RUN rustup default nightly
WORKDIR /usr/src/app
# Caches build dependencies by writing placeholder lib and main files.
COPY Cargo.toml Cargo.lock ./
COPY database/Cargo.toml database/
RUN mkdir -p database/src && echo '' > database/src/lib.rs
COPY server/Cargo.toml server/
RUN mkdir -p server/src && echo 'fn main() {}' > server/src/main.rs
RUN cargo build --package aries_api --release
COPY ./ ./
# Without these lines cargo won't recompile.
RUN touch database/src/lib.rs
RUN touch server/src/main.rs
RUN cargo build --package server --release
FROM debian:buster-slim
RUN apt-get update
RUN apt-get install -y libpq-dev
COPY --from=build /usr/src/app/target/release/server /usr/local/bin/server
CMD ["server"] Not sure if doing these things is a good idea but it has been working quite well for me. |
Beta Was this translation helpful? Give feedback.
-
You guys may eventually find this link below useful. It's not a Dockerfile, it's a shell script which employs https://github.com/frgomes/bash-scripts/blob/master/bin/miniglue |
Beta Was this translation helpful? Give feedback.
-
We've also got #171 open, so closing in favor of that. |
Beta Was this translation helpful? Give feedback.
-
Would it be OK to reopen this for now? This issue #1322 focuses on local development via a custom Docker file which aims for one local solution, whereas #171 focuses on remote deployment via a standard Docker file and aims for many cloud providers. My guess is this issue #1322 is likely to be a helpful step toward #171. So it makes sense to me to keep both issues open because this issue's surface area is much smaller, i.e. this issue doesn't need any comments about remote providers, or cloud services, or service company policies, or deployment kits, etc. Thanks for your consideration. |
Beta Was this translation helpful? Give feedback.
-
Sure! Is the hope that we would add a blessed sort of configuration of this sort to Rocket's official documentation? Besides avoiding a local Rust installation, what advantage does this setup give you? While I understand why you might want to dockerize development for other projects, I don't quite see the advantages in this case given the self-contained nature of cargo. It seems to me that local development without the introduction of an intermediary is bound to be the least error prone and most efficient path forward, and officially instructing otherwise may lead users down a more complicated, error-prone path. |
Beta Was this translation helpful? Give feedback.
-
Thank you for reopening. Yes you're correct, my first hope is for some sort of documentation of a minimal docker install of Rocket.
The containerized environment ensures all the developers have the same Rocket setup, versions, paths, etc., and don't have stable, so the environment is guaranteed to be accurate and consistent among all the developers-- and can be created and destroyed at will without affecting the local user directories such as ~/.cargo.
The use case for me is being able to extend a minimal install docker file, to distribute an entire Rocket app and development environment, to help coders who are in resource-controlled organizations where the person can't install Rust locally. I'm aiming for a docker file that includes a bunch of developer-oriented CLI tools (e.g. ripgrep) and servers (e.g. postgresql). |
Beta Was this translation helpful? Give feedback.
-
Here's my first attempt at a Rocket Dockerfile with Alpine latest, Rust nightly, rustup, and related dependencies.
I am sharing it here to help others, and also to seek feedback on how to do it better. Because Rocket needs nightly, and because Alpine has compatibility quirks, I would like to suggest adding this Dockerfile (or something like it) to the Rocket documentation. My understanding is this will likely change when Rocket is available on stable.
Beta Was this translation helpful? Give feedback.
All reactions