Svelte Tutorial: How to Dockerize A Svelte App
By default, Svelte loads the app from the local host. We need to map ports and bind the container.
1. We can create Dockerfile
in our app directory:
FROM node:14-alpine
# install dependencies
WORKDIR /app
COPY rollup.config.js ./
COPY package*.json ./
RUN npm install
COPY ./src ./src
COPY ./public ./public
RUN npm run-script build
EXPOSE 5000
ENV HOST=0.0.0.0
CMD [ "npm", "start" ]
2. Build a local image:
docker build -t myapp .
3. Finally, run it:
docker run -p 5000:5000 myapp