R
Railway•2y 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•2y ago
Project ID: N/A
eirk
eirkOP•2y ago
N/A
Brody
Brody•2y ago
even erikh didnt know the answer to this question, so... dockerfile time
eirk
eirkOP•2y ago
ugh
Brody
Brody•2y ago
ask chatgpt to write you a dockerfile
eirk
eirkOP•2y 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•2y 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
eirkOP•2y ago
lol ty
root
root•2y ago
Also, Railway will respect your default_run option in Cargo.toml
eirk
eirkOP•2y ago
ye
eirk
eirkOP•2y ago
Rust | Nixpacks
App source + Nix packages + Docker = Image
eirk
eirkOP•2y ago
its there tho
root
root•2y ago
Yes I see it in the source code
Brody
Brody•2y ago
root
root•2y ago
(Although I found it in the docs) It's referenced as RUST_BIN, nixpacks has a wrapper around env vars
Brody
Brody•2y ago
interesting
eirk
eirkOP•2y ago
doesnt seem to be working i think i k nope nixpacks doesnt recognize that oh coz its cached
Brody
Brody•2y ago
NIXPACKS_NO_CACHE = 1 maybe
eirk
eirkOP•2y ago
no
Brody
Brody•2y ago
is it dockerfile time yet
eirk
eirkOP•2y ago
yes so i figured out why it finds bins by looking thru src/bins but nooo workspaces
Brody
Brody•2y ago
why is there even multiple bins being built, sounds like a waste of time
eirk
eirkOP•2y ago
no theres multiple bins my goal is to basically a monorepo multiple packages (bins) exist, one is built
Brody
Brody•2y ago
too complicated
eirk
eirkOP•2y 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•2y ago
I don't and can't have docker installed either
eirk
eirkOP•2y ago
why
Brody
Brody•2y ago
slow-ish internet, doesn't make sense for me to download docker images locally
eirk
eirkOP•2y ago
its been two minutes
eirk
eirkOP•2y ago
crashed once no twice omfg its installing cargo deps every single time bruh any way to cache this lol
Brody
Brody•2y ago
kinda
eirk
eirkOP•2y ago
chatgpt time
Brody
Brody•2y ago
do you have nixpacks installed
eirk
eirkOP•2y ago
noo
Brody
Brody•2y ago
install it, tell it to just output the dockerfile, and then you will see how it caches
eirk
eirkOP•2y 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•2y ago
thats a good step 1
eirk
eirkOP•2y ago
so that dockerfile doesnt work for workspaces u cant build without a valid cargo.toml
Brody
Brody•2y ago
sounds correct
eirk
eirkOP•2y ago
10th build rn and its been an hour im done bot and website can go die
eirk
eirkOP•2y ago
Brody
Brody•2y ago
average railway user
eirk
eirkOP•2y ago
yk what im removing the website
eirk
eirkOP•2y ago
eirk
eirkOP•2y ago
💀
Brody
Brody•2y ago
success
eirk
eirkOP•2y ago
coz i removed the original problem no more mutlti bins
Brody
Brody•2y ago
multi bins dumb anyway
eirk
eirkOP•2y ago
aka pushing the problem to a later date
Brody
Brody•2y ago
just only build 1 bin
eirk
eirkOP•2y ago
ill need to make an api then or publish a privaate crate or dupe tons of code
Brody
Brody•2y ago
too complicated
eirk
eirkOP•2y ago
or no website but that was my entire goal too bad ig
root
root•2y ago
Just use default_run
eirk
eirkOP•2y 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