Deployment Overview of Strapi on Server¶
Prerequisites and Basic Requirements¶
The following requirements must be met on the server before the application is operational:
-
Operating System: Ubuntu
-
Privileges: Root access is required for Docker installation and configuration management.
-
Domain: The application is configured for the
hostkey.inzone. -
Ports:
-
Port
1337for the Strapi application. -
Port
5432for the PostgreSQL database. -
Port
443for HTTPS traffic via the proxy.
FQDN of the Final Panel¶
The application is accessible via the following Fully Qualified Domain Name (FQDN) format:
strapi<Server ID>.hostkey.in
File and Directory Structure¶
The deployment utilizes the following directory structure for configuration, data, and certificates:
-
/opt/strapi: Main volume directory for Strapi application data. -
/root/nginx: Directory containing Nginx and Certbot configuration files. -
/root/nginx/compose.yml: Docker Compose file for the proxy and SSL services. -
/data/nginx/nginx-certbot.env: Environment file for Nginx Certbot configuration. -
/data/nginx/user_conf.d: Directory for custom Nginx user configurations. -
/var/lib/postgresql/data: Persistent storage for the PostgreSQL database.
Application Installation Process¶
The application is deployed using Docker containers. The installation involves the following components and versions:
-
Strapi: Deployed using the image
docker-repo.hostkey.com/docker-anonymous/strapi:latest. -
PostgreSQL: Deployed using the image
postgres:15. -
Nginx/Certbot: Deployed using the image
jonasal/nginx-certbot:latestto handle SSL termination and reverse proxying.
The deployment creates a dedicated Docker network named strapi_network to facilitate communication between the Strapi application and the database.
Access Rights and Security¶
Security and access are managed through the following mechanisms:
-
Firewall: External access to the Strapi application is routed through Nginx on port
443(HTTPS). Direct access to the internal ports (1337and5432) is restricted to the Docker network or localhost unless explicitly exposed. -
Users: The Strapi volume directory (
/opt/strapi) is owned by user ID1000and group ID1000. -
Restrictions: The Nginx service runs in
hostnetwork mode to manage SSL certificates and reverse proxy rules.
Databases¶
The application uses a PostgreSQL database with the following configuration:
-
Connection Method: Internal Docker network connection.
-
Storage Location:
/var/lib/postgresql/data. -
Database Settings:
-
Database Name:
strapi -
Database User:
strapi_user -
Database Host:
strapi-db -
Database Port:
5432
Docker Containers and Their Deployment¶
The system deploys three primary containers using Docker:
-
PostgreSQL Container
-
Name:
strapi-db -
Image:
postgres:15 -
Restart Policy:
always -
Network:
strapi_network -
Volumes: Maps
/var/lib/postgresql/datato the container's data directory. -
Ports: Exposes
5432internally. -
Strapi Container
-
Name:
strapi -
Image:
docker-repo.hostkey.com/docker-anonymous/strapi:latest -
Restart Policy:
always -
Network:
strapi_network -
Volumes: Maps
/opt/strapito/srv/appinside the container. -
Ports: Exposes
1337internally. -
Environment Variables:
-
DATABASE_CLIENT:postgres -
DATABASE_NAME:strapi -
DATABASE_HOST:strapi-db -
DATABASE_PORT:5432 -
DATABASE_USERNAME:strapi_user -
DATABASE_PASSWORD:strapi_password
-
-
Nginx/Certbot Container
-
Name: Defined in
/root/nginx/compose.yml -
Image:
jonasal/nginx-certbot:latest -
Restart Policy:
unless-stopped -
Network Mode:
host -
Volumes:
-
nginx_secrets(external) mapped to/etc/letsencrypt. -
/data/nginx/user_conf.dmapped to/etc/nginx/user_conf.d.
-
-
Environment:
CERTBOT_EMAIL:[email protected]
Proxy Servers¶
The deployment includes an Nginx reverse proxy with SSL support managed by Certbot:
-
Software: Nginx with Certbot integration.
-
Configuration Location:
/root/nginx/compose.yml. -
SSL Certificates: Stored in the
nginx_secretsvolume at/etc/letsencrypt. -
Custom Domains: Configured to handle the
hostkey.inzone. -
Email for Certbot:
[email protected].
Permission Settings¶
File and directory permissions are set as follows:
-
/opt/strapi: Owner1000:1000, Mode0755. -
/root/nginx: Ownerroot:root, Mode0755. -
/root/nginx/compose.yml: Ownerroot:root, Mode0644.
Location of Configuration Files and Data¶
-
Strapi Data:
/opt/strapi -
Nginx Configuration:
/root/nginx/compose.yml -
Nginx Environment:
/data/nginx/nginx-certbot.env -
Nginx User Config:
/data/nginx/user_conf.d -
Database Data:
/var/lib/postgresql/data -
SSL Certificates:
/etc/letsencrypt(via Docker volumenginx_secrets)
Available Ports for Connection¶
The following ports are configured for the application:
-
Port 1337: Internal Strapi application port.
-
Port 5432: Internal PostgreSQL database port.
-
Port 443: External HTTPS port for the Nginx proxy.
Starting, Stopping, and Updating¶
The services are managed using Docker and Docker Compose commands:
-
Start Nginx/Certbot:
-
Check Running Containers:
-
Restart Strapi Container:
-
Restart Database Container:
-
Update Images: Pull the latest images using
docker pullfor the respective image names, then restart the containers.