-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
General comment: Rocket Dockerfile with Alpine latest, Rust nightly, rustup #1322
Comments
Why not start with the alpine version of the Rust docker image? |
That's a good idea. To get Rust nightly + Alpine latest, what would you use for "FROM"? |
@joelparkerhenderson Here is a list of all official Rust docker images: https://hub.docker.com/_/rust?tab=tags |
@olback Thank you. At that link, which image is Rust nightly + Alpine latest? |
@joelparkerhenderson - you'll want something like:
|
@joelparkerhenderson I didn't find a alpine nightly but threw is |
https://hub.docker.com/r/rustlang/rust/tags (there's a 3.12 + nightly there)
|
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. |
For building with postgres-connection (feature |
@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. |
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 |
We've also got #171 open, so closing in favor of that. |
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. |
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. |
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). |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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.
The text was updated successfully, but these errors were encountered: