4

I'm trying to deploy my Sveltekit App in Railway Whenever I try to run

docker run --publish 8000:8000 my_project

I get back

> my-project@0.0.1 build
> vite build

sh: vite: not found

This is my dockerfile

# syntax=docker/dockerfile:1

FROM node:19.4.0-alpine3.16
ENV NODE_ENV=production

WORKDIR /app

COPY ["package.json", "package-lock.json*", "./"]

RUN npm install 
RUN npm install dotenv 
RUN npm install @directus/sdk
RUN npm install vite

COPY . .

CMD [ "npm", "run", "build" ]

This is my package.json file

"scripts": {
            "dev": "vite dev",
            "build": "vite build",
            "preview": "vite preview",
            "check": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json",
            "check:watch": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json --watch",
            "test": "playwright test",
            "test:unit": "vitest",
            "lint": "prettier --plugin-search-dir . --check . && eslint .",
            "format": "prettier --plugin-search-dir . --write ."
        },
        
        "dependencies": {
            "@directus/sdk": "^10.3.1",
            "dotenv": "^16.0.3"
        }
    }

Script and dependencies above

The devDependencies are the following, at least the ones I found competent

"devDependencies": {
        "@sveltejs/adapter-auto": "^1.0.0",
        "@sveltejs/kit": "^1.0.0",
        "svelte": "^3.54.0",
        "svelte-check": "^2.9.2",
        "vite": "^4.0.0",
        "vitest": "^0.25.3"
    },
  • Please edit your post and add your package.json file to it. If it's too big, then at least the dependencies and scripts parts. – Hans Kilian Jan 26 '23 at 14:12
  • 1
    [You can find a SvelteKit Docker production deployment example in Trading Strategy frontend repository](https://github.com/tradingstrategy-ai/frontend/blob/master/Dockerfile). – Mikko Ohtamaa Jan 26 '23 at 14:24
  • you are trying to use vite from your `PATH` but the way you install it it will be in you local node_modules folder. Either use the path the the vite entrypoint or install it globally and make sure your global node installations are in `PATH`. – The Fool Jan 26 '23 at 16:13

0 Answers0