How to put a Svelte app in a docker container?

折月煮酒 提交于 2020-06-14 15:01:54

问题


The title pretty much says it all. I am very new to web development.

I created a Svelte app using npx degit sveltejs/template .... Now I run it locally using npm run dev or npm start.

To my understanding, this is a Node server, but adapting their official tutorial didn't get me very far. Thanks.

I found a blog post about this, but it doesn't quite explain how to dockerize an existing Svelte app, instead points to a fork of the official template.


回答1:


You can place a Dockerfile in your app directory (where package.json is):

FROM node:12-alpine

WORKDIR /usr/src/app

COPY package*.json ./

RUN npm install

COPY . .

EXPOSE 5000

ENV HOST=0.0.0.0

CMD [ "npm", "start" ]

Build a local image:

$ docker build -t svelte/myapp .

And run it:

$ docker run -p 5000:5000 svelte/myapp


来源:https://stackoverflow.com/questions/61106423/how-to-put-a-svelte-app-in-a-docker-container

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!