Deploy Your Application
Recommendations
- Replace the default favicon using realfavicongenerator.net
- Update
package.jsonwith a new version number or usenpm version patch/minor/major. - Harden your configuration for security. See Advanced: Environment Variables and Configurations.
- Disable CORS if applicable
- Configure
trust_proxiesso it only fits your reverse proxy, never set this totrueas it allows bypassing rate limits - Find a balance between security and user comfort
- Reduce
token_ttl - Set
token_autorefreshto false - Set
token_permanent_enabledto false
- Reduce
- Set
api_docsto false if you do not need it
WARNING
Clean up your .env.example file. It should not contain sensitive credentials or deployment-specific configuration like APP_URL. See Advanced: Environment Variables.
Build Your Docker Image
bash
docker build -t myapp .Build the Docker image from your project root. Replace 'myapp' with your preferred tag name.
Orchestrate with Docker Compose
Create a .env file in your deployment folder to manage sensitive credentials:
MYSQL_DATABASE=myapp
MYSQL_USER=myapp
MYSQL_PASSWORD=supersecret
MYSQL_ROOT_PASSWORD=verysupersecretDefine your services and networking in a compose.yaml file:
yaml
services:
app:
image: myapp
restart: always
environment:
APP_URL: http://myapp.com
DATABASE_URL: "mysql://${MYSQL_USER}:${MYSQL_PASSWORD}@app-db:3306/${MYSQL_DATABASE}"
volumes:
- "./files:/var/files"
- "./logs:/var/logs"
ports:
- "3000:3000"
depends_on:
app-db:
condition: service_healthy
app-db:
image: "mysql:9"
restart: always
environment:
MYSQL_ROOT_PASSWORD: "${MYSQL_ROOT_PASSWORD}"
MYSQL_DATABASE: "${MYSQL_DATABASE}"
MYSQL_USER: "${MYSQL_USER}"
MYSQL_PASSWORD: "${MYSQL_PASSWORD}"
volumes:
- "./var/mysql:/var/lib/mysql"
healthcheck:
test:
[
"CMD-SHELL",
"mysqladmin ping -h localhost -u ${MYSQL_USER} -p${MYSQL_PASSWORD} || exit 1",
]
interval: 5s
timeout: 5s
retries: 5
start_period: 30s
start_interval: 1sStart your application and database in detached mode by running:
bash
docker compose up -d