Hosting a Svelte Static Site on Railway

henrychris
HOBBY

4 months ago

I have a static site built with SvelteKit. Currently, I deploy it on GH Pages with a workflow including a build step to generate the production assets.
However, this requires my repository to be public, and I don't want that. I recently moved my other products to Railway (launch week and metal sold me), and I'm currently trying to set up a workflow for this static site.

I've tried a bunch of stuff. This is what "works". By that, I mean the workflow completes successfully:

jobs:
  build:
    runs-on: ubuntu-latest
        steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Install Bun
        uses: oven-sh/setup-bun@v2
        with:
          bun-version: 1.2.0

      - name: Install dependencies
        run: bun install

      - name: build project
        run: |
          bun run build

  deploy:
    needs: build
    runs-on: ubuntu-latest
    container: ghcr.io/railwayapp/cli:latest
    env:
      SVC_ID: 786074b6-26f3-433c-b5ec-72aae24483f1
      ENV_ID: 48d6c7a1-1657-4d58-b083-14ccfcecc59a
      RAILWAY_TOKEN: ${{ secrets.RAILWAY_QBALL_TOKEN }}

    steps:
      - uses: actions/checkout@v4
      - run: ls && railway up --service ${{ env.SVC_ID }} --environment ${{env.ENV_ID}} --detach

I configured the service to deploy the build folder, created in the build job. But of course, the build folder can't be found. Is there anything I can do? Or do I look for other solutions?

Project Id: ae360c46-b915-453f-bae1-b19230e7fdda

Solved

0 Replies

4 months ago

why not just connect your github repo to a railway service and let us build and deploy it?


henrychris
HOBBY

4 months ago

i did try that. first, it says there's no start command. but it's a static site, there's not supposed to be.

then, when i specify the build/ folder as where to deploy from, i get a root directory not found.


4 months ago

theres definitely supposed to be a start command, vercel just abstracts that away for you, but we should also abstract that away


4 months ago

what is the output dir of your static files


henrychris
HOBBY

4 months ago

build


4 months ago

try setting a service variable RAILPACK_SPA_OUTPUT_DIR=build


henrychris
HOBBY

4 months ago

okay. before that, i did try using bun run preview as the start command. that generates a production build and exposes on 4173. The deploy completes, but I get a 502 when i visit the domain generated.


henrychris
HOBBY

4 months ago

i'll try this now


henrychris
HOBBY

4 months ago

no luck.


4 months ago

you definitely don't want to be running a development server


4 months ago

oh you are still using nixpacks, please switch to railpack


henrychris
HOBBY

4 months ago

deployed on railpack, still a 502. i glanced through the docs, and thought it would work fine. is there anything i am missing?


4 months ago

is your target port set correctly?


henrychris
HOBBY

4 months ago

yeah that was it. The old build had set it to 4173. it's back on 8080, and all is well now. Thanks a lot


4 months ago

awsome!


henrychris
HOBBY

4 months ago

do i mark as solved, or you got it?


4 months ago

!s


Status changed to Solved brody 4 months ago


Hosting a Svelte Static Site on Railway - Railway Help Station