Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to put a Svelte app in a docker container?

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.

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.

like image 335
ticofab Avatar asked Apr 08 '20 17:04

ticofab


People also ask

How do I use svelte app Docker?

Go to https://app.netlify.com/start and select the source of you code (gitlab, github, bitbucket) then select the repository of your dockerized Svelte application. Set the branch (to master for example), the build command to "npm run build" and the publish directory to "public" and click on "Deploy Site".

How do I run flask app in Docker?

Creating the Flask app Let's proceed to create a simple Flask application that renders a message on the browser. Create a folder with the name flask_docker to contain your application. Next, cd into the flask_docker directory and run the below command to install Flask. In the code snippet above, the @app.


1 Answers

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

FROM node:14-alpine

WORKDIR /usr/src/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 svelte/myapp .

And run it:

$ docker run -p 5000:5000 svelte/myapp
like image 74
madflow Avatar answered Sep 19 '22 03:09

madflow