This is a boilerplate for deploying applications using Nginx, Docker Compose, Portainer, Strapi, Vite + React, and GitHub Workflows.
- Nginx: Acts as the primary server and reverse proxies requests to backend and frontend services, consolidating them on a single port.
- Docker Compose: Orchestrates the deployment of the backend, frontend, and additional services like Portainer.
- Portainer: A web-based interface for managing Docker environments.
- Strapi: A powerful backend CMS for managing content.
- Vite + React: A modern frontend build system for fast and efficient development.
- GitHub Workflows: Automates the deployment process via CI/CD pipelines.
Clone this repository to your remote server:
git clone https://github.com/your-repository-name.git
cd simple-deploy-boilerplate
Navigate to Settings > Secrets and Variables > Actions. Add the following secrets: SERVER_IP: The IP address of your server. SERVER_PASSWORD: The password for your server's root user. SERVER_USER: The username (e.g., root). DOMAIN_NAME: The domain name (e.g., example.com).
Before deploying, create a PostgreSQL database on your Linux server
sudo apt update
sudo apt install postgresql postgresql-contrib
sudo -u postgres psql
CREATE DATABASE your_database_name;
CREATE USER your_user_name WITH PASSWORD 'your_password';
GRANT ALL PRIVILEGES ON DATABASE your_database_name TO your_user_name;
install all requiered programs in remote server
./setup.sh
Install Certbot and generate SSL certificates for your domain:
sudo apt update
sudo apt install certbot python3-certbot-nginx
Run Certbot to generate certificates:
sudo certbot --nginx -d your-domain.com -d www.your-domain.com
Verify certificate renewal: Certbot automatically sets up renewal, but you can test it:
sudo certbot renew --dry-run
On your server, create a .env file in the root of the project directory with the following variables:
DB_HOST=localhost
DB_PORT=5432
DB_NAME=your_database_name
DB_USER=your_user_name
DB_PASSWORD=your_password
FRONTEND_URL=https://your-domain.com
BACKEND_URL=https://your-domain.com/core
Modify the backend/config/server.ts file in the backend directory. Add the following line to the configuration object:
url: 'https://your-domain.com/core',
Ensure the frontend sends requests to the backend at:
const base_url = 'https://your-domain.com/core',
After configuring the project, commit your changes and push with a tag to trigger deployment:
git add .
git commit -m "Initial deployment setup"
git tag -a v1.0.0 -m "Deployment v1.0.0"
git push origin main --tags
Nginx Reverse Proxy: Nginx routes requests to the backend, frontend, and Portainer, consolidating them through a single exposed port. Portainer Access: You can access Portainer at https://your-domain.com/portainer.