问题
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