I installed the svelte app with vite with the command npm init vite. Then i did my programming stuff and build a simple todo app.
The svelte dev server starts on port 3000
package.json:
{
"name": "package",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview",
"start": "vite serve"
},
"devDependencies": {
"@sveltejs/vite-plugin-svelte": "^1.0.0-next.30",
"autoprefixer": "^10.4.7",
"postcss": "^8.4.14",
"svelte": "^3.44.0",
"tailwindcss": "^3.1.4",
"vite": "^2.9.9"
},
"dependencies": {
"uuidv4": "^6.2.13"
}
}
This is my Dockerfile
FROM node:16-alpine
WORKDIR /app
COPY ./ ./
RUN npm install
RUN npm i -g vite
RUN npm run build
EXPOSE 3000
CMD [ "npm", "start" ]
then i type in my terminal
docker build -t todo . following with docker run -p 80:3000 todo
In the Dockercontainer everything works and it says it is started:
The problem now is I can't access it over localhost port 80. I also tried it with port 3000 to be sure but it still doesn't work.
What am I missing?
Posts i tested and saw: https://devlinduldulao.pro/svelte-in-docker/ https://svelte-recipes.netlify.app/publishing/ How to put a Svelte app in a docker container?
Thanks in advance!