How It Works
-
Create Environment Files:
- Copy
config/example.envto a new file (e.g.,config/testing.env) and edit the variables.
- Copy
-
Run
setup.sh:- Pass the
.envfile as an argument:./setup.sh config/testing.env
- Pass the
-
Generated Output:
setup.shreplaces all{PROJECT_NAME}placeholders dynamically.- Example for
PROJECT_NAME=testing:APP_SERVICE_NAMEbecomesapp-testing.MYSQL_DATABASEbecomestesting_db.
Examples
Website
This is how you would set up a website that uses Laravel on example.com
# General Configurations
PROJECT_NAME=example
BASE_URL=com
APP_SERVICE_NAME=app-{PROJECT_NAME}
# Network
NETWORK_NAME={PROJECT_NAME}_network
# Nginx
NGINX_SERVICE_NAME=nginx-{PROJECT_NAME}
NGINX_PORT=80
# Database Configuration
MYSQL_SERVICE_NAME=mysql-{PROJECT_NAME}
MYSQL_DATABASE={PROJECT_NAME}_db
MYSQL_USER={PROJECT_NAME}_user
MYSQL_PASSWORD=my_password
MYSQL_ROOT_PASSWORD=root_password
MYSQL_PORT=3306
# Dockerfile Configurations
PHP_VERSION=8.3-fpm
PHP_EXTENSIONS=pdo_mysql mbstring exif pcntl bcmath gd
With Subdomain
For this example we'll set up a laravel site at the subdomain testing.example.com
Input: config/testing.example.com.env:
# General Configurations
PROJECT_NAME=testing
BASE_URL=example.com
APP_SERVICE_NAME=app-{PROJECT_NAME}
# Network
NETWORK_NAME={PROJECT_NAME}_network
# Nginx
NGINX_SERVICE_NAME=nginx-{PROJECT_NAME}
NGINX_PORT=4444
# Database Configuration
MYSQL_SERVICE_NAME=mysql-{PROJECT_NAME}
MYSQL_DATABASE={PROJECT_NAME}_db
MYSQL_USER={PROJECT_NAME}_user
MYSQL_PASSWORD=my_password
MYSQL_ROOT_PASSWORD=root_password
MYSQL_PORT=4445
# Dockerfile Configurations
PHP_VERSION=8.3-fpm
PHP_EXTENSIONS=pdo_mysql mbstring exif pcntl bcmath gd
Command:
./setup.sh config/testing.env
Output Directory:
testing.example.com/
├── Dockerfile
├── docker-compose.yml
├── app-volume-testing/
├── nginx-volume-testing/
│ └── default.conf
├── mysql-volume-testing/
Languages
Shell
100%