This sample project demonstrates how to deploy a full-stack application using Svelte for the frontend, Node.js for the backend, and MySQL for the database. The project uses Docker to containerize the services, making it easy to run in both development and production environments.
This sample showcases how you could deploy a full-stack application with Defang and Svelte and NodeJS. However, it deploys mysql db as a defang service. Defang services are ephemeral and should not be used to run stateful workloads in production as they will be reset on every deployment. For production use cases you should use a managed database like RDS, Aiven, or others. In the future, Defang will help you provision and connect to managed databases.
- Download [Defang CLI] (https://github.com/DefangLabs/defang)
- (optional) If you are using [Defang BYOC] (https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html) authenticated your AWS account.
- (optional for local development) [Docker CLI] (https://docs.docker.com/engine/install/)
- Download [Defang CLI] (https://github.com/DefangLabs/defang)
- (optional) If you are using Defang BYOC make sure you have properly
- [Docker CLI] (https://docs.docker.com/engine/install/)
- [NodeJS] (https://nodejs.org/en/download/package-manager)
For development, we use a local container. This can be seen in the compose.yaml file and the server.js file where we create a pool of connections. To run the sample locally after clonging the respository, you can run on docker by doing docker compose up --build --build or run without using Docker by doing the following:
- run npm install to install the nodejs dependencies
- create an .env file on the svelte directory specifying the appropriate environment variables.
- run npm start
If you want to edit the database, such that you can deploy them to production, you should install the mySQL CLI and mySQL workbench to gain access to a GUI so that you can make your changes to the database. After running defang compose up these changes will be reflected.
- Open the terminal and type
defang login
- Type
defang compose up
in the CLI. - Your app will be running within a few minutes.
Title: Svelte & Node.js & MySQL
Short Description: A full-stack application using Svelte for the frontend, Node.js for the backend, and MySQL for the database.
Tags: Svelte, Node.js, MySQL, Full-stack, JavaScript, TypeScript, SQL
Languages: nodejs