a year ago
Looking at the docs I see commands like npm run start:backend so how does railway now which service is which? https://docs.railway.app/guides/monorepo#deploying-a-shared-monorepo
I have a turborepo with golang services in the following directory structure
/root
--/services
-- (golang services 1 folder each)
--/packages
--/apps
So now I am not sure how to start each monorepo service in each railway service
81 Replies
@Brody This is what I have:
root package.json
"kangiten:start": "pnpm --filter kangiten start"a year ago
yes you do, like a start:backend and start:frontend etc
a year ago
ERR_PNPM_NO_LOCKFILE Cannot install with "frozen-lockfile" because pnpm-lock.yaml is absenta year ago
beat you
a year ago
is pnpm-lock.yaml absent?
a year ago
does the go app need to access code from any other folder?
a year ago
okay, do you have a kangiten:build script?
a year ago
go apps need to be built
a year ago
youd want app specfic build scripts
a year ago
do you have this set too? -
a year ago
you may have added the new build script but you didnt configure the railway service to use it
ahh this errorWARN Local package.json exists, but node_modules missing, did you mean to install?
ive had it before
actually its a go error
```sh: 1: go: not found
/app/services/kangiten:
ERRPNPMRECURSIVERUNFIRST_FAIL kangiten@0.0.0 build: go build -o bin/kangiten main.go
spawn ENOENT
WARN Local package.json exists, but node_modules missing, did you mean to install?
ELIFECYCLE Command failed with exit code 1.
error building image: error building stage: failed to execute command: waiting for process to exit: exit status 1
exit status 1```
a year ago
looks like it didnt take, try removing and readding node and go
a year ago
your providers list is only go though
a year ago
you want to set it to node and go
a year ago
might be time to move to a nixpacks.toml, i dont think you can pass in providers when you use the v2 builder
Is this the correct way to do it. I added a railway.toml to the root of my monorepo with the following:
[build]
builder = "NIXPACKS"
providers = ["node", "go"]a year ago
tbh i dont know the syntax for the railway.toml file off the top of my head.
so cant hurt to try
a year ago
yeah its not being used anyway
a year ago
under a key?
a year ago
syntax might be wrong, or you placed the file in the wrong location (need to be on root)
a year ago
i forgot, the v2 builder does not support nixpack configs in a railway.toml/json
a year ago
use a nixpacks.toml file
a year ago
alright, Dockerfile time
a year ago
or disable the v2 builder
do yall have any docs or examples for monorepos? i dont have a lot experience with dockerfiles in monorepo. disabling v2 didnt work
from what im seeing i guess i could make a dockerfile for each service with custom docker file path https://docs.railway.app/guides/dockerfiles
a year ago
you switched the runtime back to legacy, that should stay on v2.
you wanted to switch off the new builder
a year ago
but docs on how to write a Dockerfile would not be specific to railway so it would be out of the scope of our docs
a year ago
yeah
a year ago
but that looks like its not going to work, so dockerfile for sure
@Brody I see some people having the Cache mount ID is not prefixed with cache key which I am myself having but don't see the issue <:Thonk:264701195573133315>
# Build stage
FROM golang:1.22.5 AS builder
# Set working directory
WORKDIR /app
# Copy go mod and sum files
COPY go.mod go.sum ./
# Set the service name (change this for each service)
ARG SERVICE_NAME=kangiten
ARG SERVICE_ID=fc824b79-e4db-4095-9801-b99985b8f4c8
# Download dependencies
RUN --mount=type=cache,id=s/${SERVICE_ID}-/root/cache/go-build,target=/root/.cache/go-build \
go mod download
# Copy source code
COPY . .
# Build the application
RUN --mount=type=cache,id=s/${SERVICE_ID}-/root/cache/go-build,target=/root/.cache/go-build \
CGO_ENABLED=0 GOOS=linux go build -o /app/main ./services/${SERVICE_NAME}
# Final stage
FROM alpine:3.18
# Set working directory
WORKDIR /app
# Copy the binary from the builder stage
COPY --from=builder /app/main .
# Run the binary
CMD ["./main"]a year ago
unfortunately you need to hardcode the service id
a year ago
awesome
a year ago
no problem, dockerfiles imo are better for most things than doing a dance with nixpacks
Can't this be fixed? it is very annoying that we have to create separate dockerfiles for each service; it's a huge time waste especially for those who don't know they have to hardcode it.
I just completely removed cache mounts (at the expense of +2min build times). I honestly think we (users) are not meant to go through such hacky processes. Perhaps many other power users (that like running things efficiently) will share the same
10 months ago
Railpack is a great option for you then!
10 months ago
!s
Status changed to Solved brody • 10 months ago










