#deploy rust with multiple binaries
99 messages · Page 1 of 1 (latest)
Project ID: N/A
N/A
even erikh didnt know the answer to this question, so... dockerfile time
ugh
ask chatgpt to write you a dockerfile
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)?
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
@wet harness
lol ty
Also, Railway will respect your default_run option in Cargo.toml
ye
Yes
I see it in the source code
(Although I found it in the docs)
It's referenced as RUST_BIN, nixpacks has a wrapper around env vars
interesting
doesnt seem to be working
i think i k
nope nixpacks doesnt recognize that
oh coz its cached
no
is it dockerfile time yet
yes
so
i figured out why
it finds bins by looking thru src/bins
but nooo
workspaces
why is there even multiple bins being built, sounds like a waste of time
no
theres multiple bins
my goal is to basically a monorepo
multiple packages (bins) exist, one is built
too complicated
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
I don't and can't have docker installed either
why
slow-ish internet, doesn't make sense for me to download docker images locally
its been two minutes
crashed once
no twice
omfg its installing cargo deps every single time bruh
any way to cache this lol
kinda
chatgpt time
do you have nixpacks installed
noo
install it, tell it to just output the dockerfile, and then you will see how it caches
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>"]
im all good
ill work on copying just the binary later
step 1: make it not error
thats a good step 1
so that dockerfile doesnt work for workspaces
u cant build without a valid cargo.toml
sounds correct
average railway user
success
multi bins dumb anyway
aka pushing the problem to a later date
just only build 1 bin
too complicated
Just use default_run