Deploy Express.js on Hostim.dev
This guide shows how to deploy a Express app on Hostim.dev from a Git repository.
Quick start: Use the "Express Demo" template to skip the setup.
π Open the Console Click "+ New Project", pick Express Demo, and you're good to go.
Want to customize or start fresh? This guide walks you through the manual setup.
0. Create a Projectβ
Before deploying, create a new project:
- Go to your Hostim.dev dashboard
- Click Create Project
- Choose from:
- Scratch: start empty
- Template: use a prebuilt stack like Express Demo
- Docker Compose: paste your own Compose file
- For this guide, choose Scratch
- Name your project (e.g.
express-demo) and click Create Project
1. Use the Example Express Appβ
We'll deploy a real Express.js app from our public repository:
π https://github.com/hostimdev/demo-express
You only need to clone the code if you want to run it locally or check out how it works. In that case, follow the instructions in the project's README:
π³ This project already includes a working
Dockerfileand is ready to deploy out of the box.
2. Deploy on Hostim.devβ
β οΈ Order Matters: To ensure the app works correctly, create services in this order: Volume β Database β Redis β App. This ensures that environment variables and mounts are available when the app starts.
2.1. Create a Volume for File Storageβ
- From your project dashboard, click Create Service β New Volume
- Name your volume (e.g.,
avatar-uploads) - Choose a plan
- Click Create Volume
2.2. Add a PostgreSQL Databaseβ
- From your project dashboard, click Create Service β New PostgreSQL
- Name your database (e.g.,
db) - Choose a plan
- Click Create PostgreSQL
2.3. Add a Redis Instanceβ
- From your project dashboard, click Create Service β New Redis
- Name your Redis instance (e.g.,
redis) - Choose a plan
- Click Create Redis
2.4. Create the Express Appβ
- From your project dashboard, click Create Service β New App
- Choose Git as the deployment type
- Use the GitHub URL:
https://github.com/hostimdev/demo-express - Set a branch to
main - Leave Dockerfile path as
Dockerfile - Choose a plan and number of replicas
- Under Volume Mounts, click Attach Volume
- Select the volume you created (e.g.,
avatar-uploads) - Set mount path to
/app/public/uploads/avatars
- Select the volume you created (e.g.,
- Check "Does this app have HTTP Service?"
- Set the HTTP Port to
3000 - Check "Is this app public?" (or leave unchecked for private access)
- Click Create App
2.5. Configure Environment Variablesβ
- Open your app in the dashboard
- Go to the Envs tab
- Add the following environment variables:
NODE_ENV=development
DB_HOST=$(DB_POSTGRES_HOST)
DB_USER=$(DB_POSTGRES_USER)
DB_PASS=$(DB_POSTGRES_PASSWORD)
DB_NAME=$(DB_POSTGRES_DATABASE)
REDIS_HOST=$(REDIS_REDIS_HOST)
REDIS_PORT=$(REDIS_REDIS_PORT)
These pull in values automatically from the other services you set up.
| Variable | Description |
|---|---|
DB_* | Populated from the PostgreSQL service |
REDIS_* | Populated from the Redis service |
NODE_ENV | Set manually to development |
Click Save Changes when done.