R
Railway•14mo ago
eirk

deploy rust with multiple binaries

How do I choose which binary to deploy for a rust project with multiple workspaces and binaries?
56 Replies
Percy
Percy•14mo ago
Project ID: N/A
eirk
eirk•14mo ago
N/A
Brody
Brody•14mo ago
even erikh didnt know the answer to this question, so... dockerfile time
eirk
eirk•14mo ago
ugh
Brody
Brody•14mo ago
ask chatgpt to write you a dockerfile
eirk
eirk•14mo ago
im looking at dockerfiles rn its not a problem how would a configuration for this look like (if railway were to add support fo rmulti binaries)?
root
root•14mo ago
maybe a NIXPACKS_RUST_BINARY option? hold up though I'm pretty sure there's a way to do this Yes There's a NIXPACKS_RUST_BIN variable @eirk
eirk
eirk•14mo ago
lol ty
root
root•14mo ago
Also, Railway will respect your default_run option in Cargo.toml
eirk
eirk•14mo ago
ye
eirk
eirk•14mo ago
Rust | Nixpacks
App source + Nix packages + Docker = Image
eirk
eirk•14mo ago
its there tho
root
root•14mo ago
Yes I see it in the source code
Brody
Brody•14mo ago
root
root•14mo ago
(Although I found it in the docs) It's referenced as RUST_BIN, nixpacks has a wrapper around env vars
Brody
Brody•14mo ago
interesting
eirk
eirk•14mo ago
doesnt seem to be working i think i k nope nixpacks doesnt recognize that oh coz its cached
Brody
Brody•14mo ago
NIXPACKS_NO_CACHE = 1 maybe
eirk
eirk•14mo ago
no
Brody
Brody•14mo ago
is it dockerfile time yet
eirk
eirk•14mo ago
yes so i figured out why it finds bins by looking thru src/bins but nooo workspaces
Brody
Brody•14mo ago
why is there even multiple bins being built, sounds like a waste of time
eirk
eirk•14mo ago
no theres multiple bins my goal is to basically a monorepo multiple packages (bins) exist, one is built
Brody
Brody•14mo ago
too complicated
eirk
eirk•14mo ago
yea too complicated for me to write patch for nixpacks to suport this dockerfile added lets see how long it takes for me to get it right coz i dont hae docker installed lol
Brody
Brody•14mo ago
I don't and can't have docker installed either
eirk
eirk•14mo ago
why
Brody
Brody•14mo ago
slow-ish internet, doesn't make sense for me to download docker images locally
eirk
eirk•14mo ago
its been two minutes
eirk
eirk•14mo ago
crashed once no twice omfg its installing cargo deps every single time bruh any way to cache this lol
Brody
Brody•14mo ago
kinda
eirk
eirk•14mo ago
chatgpt time
Brody
Brody•14mo ago
do you have nixpacks installed
eirk
eirk•14mo ago
noo
Brody
Brody•14mo ago
install it, tell it to just output the dockerfile, and then you will see how it caches
eirk
eirk•14mo ago
dw
# Use the official Rust base image
FROM rust:latest

# Set the working directory inside the container
WORKDIR /usr/src/myproject

# Copy the Cargo.toml and Cargo.lock files to the container
COPY Cargo.toml Cargo.lock ./

# Build the dependencies separately to improve caching
RUN mkdir src && echo "fn main() {}" > src/main.rs
RUN cargo build --release

# Copy the entire project to the container
COPY . .

# Build the project
RUN cargo build --release --package <your-package-name>

# Specify the entry point command to run the project
CMD ["cargo", "run", "--release", "--package", "<your-package-name>"]
# Use the official Rust base image
FROM rust:latest

# Set the working directory inside the container
WORKDIR /usr/src/myproject

# Copy the Cargo.toml and Cargo.lock files to the container
COPY Cargo.toml Cargo.lock ./

# Build the dependencies separately to improve caching
RUN mkdir src && echo "fn main() {}" > src/main.rs
RUN cargo build --release

# Copy the entire project to the container
COPY . .

# Build the project
RUN cargo build --release --package <your-package-name>

# Specify the entry point command to run the project
CMD ["cargo", "run", "--release", "--package", "<your-package-name>"]
im all good ill work on copying just the binary later step 1: make it not error
Brody
Brody•14mo ago
thats a good step 1
eirk
eirk•14mo ago
so that dockerfile doesnt work for workspaces u cant build without a valid cargo.toml
Brody
Brody•14mo ago
sounds correct
eirk
eirk•14mo ago
10th build rn and its been an hour im done bot and website can go die
eirk
eirk•14mo ago
Brody
Brody•14mo ago
average railway user
eirk
eirk•14mo ago
yk what im removing the website
eirk
eirk•14mo ago
eirk
eirk•14mo ago
💀
Brody
Brody•14mo ago
success
eirk
eirk•14mo ago
coz i removed the original problem no more mutlti bins
Brody
Brody•14mo ago
multi bins dumb anyway
eirk
eirk•14mo ago
aka pushing the problem to a later date
Brody
Brody•14mo ago
just only build 1 bin
eirk
eirk•14mo ago
ill need to make an api then or publish a privaate crate or dupe tons of code
Brody
Brody•14mo ago
too complicated
eirk
eirk•14mo ago
or no website but that was my entire goal too bad ig
root
root•14mo ago
Just use default_run
eirk
eirk•14mo ago
yeah i suppose i could modify Cargo.toml for each service i want to run i also attempted to use dockerfile again but nooooo i got it without caching but thats annoying
Want results from more Discord servers?
Add your server
More Posts