Docker Deployment

Follow these instructions to to deploy a Skulljs project with Docker.

Requirements

  • Working project — check that your project works locally
  • Node.js on local computer — latest LTS version or newer
  • Skulljs-cli on local computer — the version you used to create the project or a newer version
  • Docker and Docker Compose installed on the remote server — the latest LTS
  • (Optional: HTTPS) An SSL Certificate

Deploy your app

Set up SSL certificate

(Optional) Set up SSL certificate for HTTPS

  1. Put your certificate key in sslcert/xxx.key.pem, you are only able to rename the xxx part.
  2. Put your certificate file in sslcert/xxx.cert.pem, you are only able to rename the xxx part.

Build the project

sk build
  1. Enter the name of the app
  2. Enter the ip address or the name of the remote server where you wish to deploy your application.
  3. Enter the port of the remote server where you wish to deploy your application.
  4. Select which hypertext transfer protocol do you would like to use.
  5. Select DOCKER when the CLI prompts you to select a manager

Setup the folder on the remote server

  1. Create a folder with the name of your choice in your server. Ex: my-awesome-app
  2. Copy the dist folder in that folder
  3. Edit the database config in .env and docker-compose.yml
- MYSQL_ROOT_USER=root
- MYSQL_ROOT_PASSWORD=
- MYSQL_USER=
- MYSQL_PASSWORD=
- MYSQL_DATABASE=

Use Docker

We use docker to manage and keep our application online 24/7.

Start an app

In the dist folder, use the following command.

npm run docker:up

Managing process

You can use the following commands to manage your processes.

npm run docker:build
npm run docker:up
npm run docker:down
npm run docker:logs

Initialize the database in the docker container

  1. Wait for the docker containers to boot up
  2. Init the database

Ex: Prisma

# Enter docker container
docker compose exec <app_name> bash

# Classic
npx prisma db push
npx prisma db seed
or
# With migration
npx prisma migrate deploy
npx prisma db seed

# Exit docker container
exit

Go to the app

Well done ! Your app is now deployed and available at:

http(s)://[the name or the ip of the server]:[port of the server]

Troubleshooting

Permissions problem

Please manually create the folder used in Docker volumes and ensure that it has appropriate permissions.