Deployment Overview of Strapi on Server¶
Prerequisites and Basic Requirements¶
To ensure a successful deployment, the following requirements must be met:
-
Operating System: Ubuntu.
-
Privileges: Root or sudo access is required for installing Docker and managing system directories.
-
Network/Ports:
-
1337: Internal application port. -
5432: Database connection port. -
80/443: Standard HTTP/HTTPS ports (managed via Nginx).
FQDN of the final panel on the hostkey.in domain¶
The access URL for the administration panel is determined by the following template:
| Parameter | Value |
|---|---|
| Prefix | strapi |
| Domain | hostkey.in |
| Full template | strapi{Server_ID}.hostkey.in/admin |
File and Directory Structure¶
The application uses the following directory structure for configuration and data persistence:
-
/opt/strapi: Main application volume for Strapi data. -
/var/lib/postgresql/data: Persistent storage for the PostgreSQL database. -
/root/nginx: Configuration directory for the Nginx reverse proxy. -
/data/nginx/user_conf.d: Custom Nginx configuration files. -
/data/nginx/nginx-certbot.env: Environment variables for SSL certificate management.
Application Installation Process¶
The application is deployed using a combination of Docker containers and system directory setup:
-
System Preparation: The installer creates the necessary directories on the host, specifically
/opt/strapiwith ownership set to user1000. -
Network Setup: A dedicated Docker network named
strapi_networkis created to facilitate communication between the application and the database. -
Database Deployment: A PostgreSQL 15 container is initialized to serve as the backend storage.
-
Application Deployment: The Strapi application is deployed using the
vshadbolt/strapi:latestDocker image. During this process, several security secrets (APP_KEYS, JWT_SECRET, etc.) are automatically generated and injected into the environment. -
Proxy Configuration: An Nginx container is configured via Docker Compose to handle SSL termination and reverse proxying using Certbot for automated certificate management.
Access Rights and Security¶
-
File Permissions: The application data directory (
/opt/strapi) is restricted to UID/GID1000. -
Network Isolation: The application and database communicate over a private Docker network (
strapi_network). -
Reverse Proxy: Nginx acts as the entry point, securing the connection via SSL.
Databases¶
The application uses PostgreSQL for data persistence.
| Parameter | Value |
|---|---|
| Engine | postgres:15 |
| Database Name | strapi |
| Hostname | strapi-db (internal) |
| Port | 5432 |
Docker Containers and Their Deployment¶
The deployment consists of the following containers:
PostgreSQL Container¶
-
Image:
postgres:15 -
Container Name:
strapi-db -
Restart Policy:
always -
Networks:
strapi_network -
Environment Variables:
-
POSTGRES_DB:strapi -
POSTGRES_USER:strapi_user -
POSTGRES_PASSWORD:strapi_password -
Volumes:
/var/lib/postgresql/data:/var/lib/postgresql/data
Strapi Container¶
-
Image:
vshadbolt/strapi:latest -
Container Name:
strapi -
Restart Policy:
always -
Networks:
strapi_network -
Environment Variables:
-
NODE_ENV:production -
DATABASE_CLIENT:postgres -
DATABASE_HOST:strapi-db -
DATABASE_PORT:5432 -
(Various auto-generated security tokens)
-
Volumes:
/opt/strapi:/srv/app
Nginx Container¶
-
Image:
jonasal/nginx-certbot:latest -
Restart Policy:
unless-stopped -
Network Mode:
host -
Environment Variables:
-
CERTBOT_EMAIL:[email protected] -
Volumes:
-
nginx_secrets:/etc/letsencrypt -
/data/nginx/user_conf.d:/etc/nginx/user_conf.d
Application Update Instructions¶
To update the Strapi application, perform the following steps:
-
Navigate to the directory containing the deployment files (if applicable).
-
Pull the latest image and restart the service: