#deploy rust with multiple binaries

99 messages · Page 1 of 1 (latest)

wet harness
#

How do I choose which binary to deploy for a rust project with multiple workspaces and binaries?

random plazaBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

austere spadeBOT
#

Project ID: N/A

wet harness
#

N/A

languid rune
#

even erikh didnt know the answer to this question, so... dockerfile time

wet harness
#

ugh

languid rune
#

ask chatgpt to write you a dockerfile

wet harness
#

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)?

quiet hare
#

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

wet harness
#

lol ty

quiet hare
#

Also, Railway will respect your default_run option in Cargo.toml

wet harness
#

ye

wet harness
#

its there tho

quiet hare
#

Yes

languid rune
quiet hare
#

(Although I found it in the docs)

#

It's referenced as RUST_BIN, nixpacks has a wrapper around env vars

languid rune
#

interesting

wet harness
#

doesnt seem to be working

#

i think i k

#

nope nixpacks doesnt recognize that

#

oh coz its cached

languid rune
#

NIXPACKS_NO_CACHE = 1

#

maybe

wet harness
#

no

languid rune
#

is it dockerfile time yet

wet harness
#

yes

#

so

#

i figured out why

#

it finds bins by looking thru src/bins

#

but nooo

#

workspaces

languid rune
#

why is there even multiple bins being built, sounds like a waste of time

wet harness
#

no

#

theres multiple bins

#

my goal is to basically a monorepo

#

multiple packages (bins) exist, one is built

languid rune
#

too complicated

wet harness
#

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

languid rune
#

I don't and can't have docker installed either

wet harness
#

why

languid rune
#

slow-ish internet, doesn't make sense for me to download docker images locally

wet harness
#

its been two minutes

#

crashed once

#

no twice

#

omfg its installing cargo deps every single time bruh

#

any way to cache this lol

languid rune
#

kinda

wet harness
#

chatgpt time

languid rune
#

do you have nixpacks installed

wet harness
#

noo

languid rune
#

install it, tell it to just output the dockerfile, and then you will see how it caches

wet harness
#

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

languid rune
#

thats a good step 1

wet harness
#

so that dockerfile doesnt work for workspaces

#

u cant build without a valid cargo.toml

languid rune
#

sounds correct

wet harness
#

10th build rn

#

and its been an hour

#

im done

#

bot and website can go die

languid rune
#

average railway user

wet harness
#

yk what im removing the website

#

💀

languid rune
#

success

wet harness
#

coz i removed the original problem

#

no more mutlti bins

languid rune
#

multi bins dumb anyway

wet harness
#

aka pushing the problem to a later date

languid rune
#

just only build 1 bin

wet harness
#

ill need to make an api then

#

or publish a privaate crate

#

or dupe tons of code

languid rune
#

too complicated

wet harness
#

or

#

no website

#

but that was my entire goal

#

too bad ig

quiet hare
#

Just use default_run

wet harness
#

yeah i suppose i could modify Cargo.toml for each service i want to run

#

i also attempted to use dockerfile again but nooooo