November 10, 2020
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.
- 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" ]
- Build a local image:
docker build -t myapp .
- Finally, run it:
docker run -p 5000:5000 myapp