SvelteKit Deployment

SvelteKit is using adapters to build the app for deployment. Using adapter-node is one of the options. It will package and prepare the app for deployment inside build/ directory in the source dir. The app could be triggered by running:


    node build/
                

Build process will not create or package node_modules inside build/ dir. It assumes that dependencies will be already installed inside the deploy environment.

If you want to deploy your app as Docker/Kubernetes, you can overcome this problem by installing dependencies using "global". Here is example Dockerfile:

 
    FROM node:21-alpine
    WORKDIR /app
    COPY . .

    RUN npm install @sveltejs/adapter-node
    RUN npm run build
    RUN npm install -g 
    RUN rm -rf static/ src/ 

    USER node:node
    EXPOSE 3000
    CMD ["node", "build"]
                

You can build Docker image:

 
    docker build -t <docker image name> .
                

You can test:


    docker run -it  -p <your_port>:3000 <docker_image_name>