7 months ago
The Problem:
I'm using Moonrepo to manage a monorepo and deploying a service (studio) to Railway using Docker. My Dockerfile is based on Moonrepo's multi-stage build guide.
When I run the CMD in my local Docker environment, the container starts up instantly, as expected. The pnpm install step from the build process is not re-run.
However, on Railway, when I set the Start Command in the dashboard to moon run studio:start, the pnpm install task is triggered and gets stuck. This is the main issue: moon run studio:start on Railway is somehow re-running the installation step, which it shouldn't, and then it hangs.
My Assumption:
My Dockerfile has a build stage with moon docker setup and a separate start stage with CMD moon run studio:start. The start stage should inherit the fully built application from the build stage, so there should be no need to re-run pnpm install. It seems that the Start Command on Railway is bypassing the cached build image and trying to set up the project from scratch, which is causing the endless stuck in pnpm install. Note this only happens if the start command inside docker when i remove it and start it using Deploy command railway it does pnpm install and works but still i don't want that werid pnpm install
I'm trying to understand why Railway's start command behaves differently from my Dockerfile's CMD command, causing it to trigger a dependency install that should have already been completed.
38 Replies
How are you starting Docker every time on Railway! What does that even mean
The issue is not very clear. Please specify the actual problem you are facing on Railway
i rephased it better i guess
here is the dokcer
Current Full Docker
#### BASE STAGE
#### Installs moon.
FROM node:latest AS base
WORKDIR /app
# Install moon binary
RUN curl -fsSL https://moonrepo.dev/install/moon.sh | bash
ENV PATH="/root/.moon/bin:$PATH"
#### SKELETON STAGE
#### Scaffolds repository skeleton structures.
FROM base AS skeleton
# Copy entire repository and scaffold
COPY . .
RUN moon docker scaffold studio
#### BUILD STAGE
#### Builds the project.
FROM base AS build
# Copy toolchain
COPY --from=skeleton /root/.proto /root/.proto
# Copy workspace configs
COPY --from=skeleton /app/.moon/docker/workspace .
# Install dependencies
RUN moon docker setup
# Copy project sources
COPY --from=skeleton /app/.moon/docker/sources .
# Build the project
RUN moon run studio:build
# Prune extraneous dependencies
RUN moon docker prune7 months ago
You cannot run docker commands within Railway.
by command u mean CMD?
or if i wrap it in a bash or something i dont quite understand what o u mean wiht commands
7 months ago
Your build command, you are trying to run a docker command, that just isn't supported.
is that a platform limitation or something that can be supported in the future
7 months ago
Not really either, its just not how its done.
What are you trying to achieve?
'm trying to optimize a Docker build process within a monorepo managed by Moonrepo. Moonrepo offers features for creating small Docker images and manages project dependencies, but pnpm install seems to run unexpectedly when starting a Docker container, causing confusion and hindering my goal of getting the build working efficiently.
what i expect when railway go to deploy
Is see
running localhost:3000 or whatever
what i see is pnpm install getting stuck for ever
when i take it out
well i still have to face that pnpm install but deploy works at the end
#### BASE STAGE
#### Installs moon.
FROM node:latest AS base
WORKDIR /app
# Install moon binary
RUN curl -fsSL https://moonrepo.dev/install/moon.sh | bash
ENV PATH="/root/.moon/bin:$PATH"
#### SKELETON STAGE
#### Scaffolds repository skeleton structures.
FROM base AS skeleton
# Copy entire repository and scaffold
COPY . .
RUN moon docker scaffold studio
#### BUILD STAGE
#### Builds the project.
FROM base AS build
# Copy toolchain
COPY --from=skeleton /root/.proto /root/.proto
# Copy workspace configs
COPY --from=skeleton /app/.moon/docker/workspace .
# Install dependencies
RUN moon docker setup
# Copy project sources
COPY --from=skeleton /app/.moon/docker/sources .
# Build the project
RUN moon run studio:build
# Prune extraneous dependencies
RUN moon docker prune
#### START STAGE
#### Runs the project.
FROM base AS start
# Copy built sources
COPY --from=build /root/.proto /root/.proto
COPY --from=build /app /app
CMD moon run studio:starthere full docker that is not working
7 months ago
Is your build just not being done with your Dockerfile?
7 months ago
link to the service please
7 months ago
Looks like you need to adjust your studio:start script, its trying to install stuff
node build is output file of sveltkit project node build/index.js just for more context
7 months ago
Have you run the dockerfile locally?
7 months ago
I will let the community continue to help you then.
ill go talk with moonrepo devs too maybe issue is on there end or somehting incorrect with my setup acts diff between machine not sure


