This repository provides a collection of scripts and configurations to automate the deployment of the Smart-Shell project. It offers multiple deployment strategies, including a script-based approach for local development, a Docker Compose setup for single-server deployments, and Kubernetes manifests for scalable environments.
The automation handles environment variable configuration, repository cloning, SSL certificate generation, and reverse proxy setup to streamline both development and production workflows.
- Smart-Shell-Postgres PostgreSQL: Database for storing structured data.
- Smart-Shell-Mongo MongoDB: Database for storing unstructured data.
- Smart-Shell-Redis Redis: Database for storing key-value data.
- Smart-Shell-SpringBoot SpringBoot: Backend for the business logic.
- Smart-Shell-Angular Angular: Frontend for the user interface.
This describes the setup for a local development environment, where each service runs in its own Docker container.
- Create a new directory
sudo mkdir -p /var/www/smart-shell/configurations- Change the owner of the directory
sudo chown -R $USER:$USER /var/www/smart-shell- Clone the repository
cd /var/www/smart-shell/configurations
git clone https://github.com/luis122448/smart-shell-bash.git
cd smart-shell-bash- Run the installation script with required parameters
You must provide the database username and password as parameters. Ports for each service have defaults, but can be overridden with flags.
Required parameters:
-u <username>: Database username-p <password>: Database password
Optional port parameters:
-pp <postgres_port>: PostgreSQL port (default: 10001)-rp <redis_port>: Redis port (default: 10002)-mp <mongo_port>: MongoDB port (default: 10003)-sp <springboot_port>: SpringBoot port (default: 10004)-ap <angular_port>: Angular port (default: 10005)
Example usage:
bash install.sh -u myuser -p mypassOverride ports if needed:
bash install.sh -u myuser -p mypass -pp 5432 -rp 6379 -mp 27017 -sp 8080 -ap 4200Note: The password provided will be used for all database configurations.
- Execute the installation script
See above for required parameters.
- Verify the installation
This will clone all the related project repositories into the deployments directory.
tree /var/www/smart-shell/deployments- Execute the deployment script
This script builds and starts the Docker containers for each service.
bash deploy.sh- Verify the deployment
sudo docker psThis project offers two main ways to deploy the application stack for production or staging environments: Docker Compose and Kubernetes.
The docker/ directory contains the necessary files to deploy the entire application stack using Docker Compose. This is a straightforward method for single-server deployments.
- Navigate to the docker directory:
cd docker- Configure Environment Variables:
The configuration is managed via a .env file. You should use the provided backup.env as a starting point.
# 1. Copy the backup file to a new .env file
cp backup.env .env
# 2. Open the .env file and customize it
nano .envInside the .env file, you must set the passwords for the databases and can customize ports, domains for CORS, and other parameters.
- Deploy:
Use the deploy.sh script within the docker directory to manage the deployment.
bash deploy.shThis script will handle the creation of necessary directories and start the services defined in docker-compose.yml.
For scalable and resilient deployments, you can use the Kubernetes manifests located in the kubernetes/ directory.
- Navigate to the kubernetes directory:
cd kubernetes- Configure the Deployment:
- Domains: Open the
configmap.ymlfile to configure theINGRESS_HOST(your domain) and other service-related URLs likeCORS_ALLOWED_ORIGINS. - Passwords: The database passwords are not set here. They will be passed securely as a parameter to the deployment script.
- Run the Deployment Script:
A convenience script, deploy.sh, is provided to apply all the manifests in the correct order. You must provide a password for the databases using the -p flag.
bash deploy.sh -p <your-database-password>This script will:
- Create the namespace
smart-shell-production. - Create a secret with the provided database password.
- Apply the ConfigMap with your domain configuration.
- Deploy all databases and applications.
- Dynamically configure and apply the Ingress resource based on the settings in the
configmap.yml.
For production deployments that are not on Kubernetes, you may need to configure Nginx as a reverse proxy with SSL.
Review the README.md file in ./scripts/ssh/ to generate SSL certificates for your domain. Additionally, review the instructions in ./scripts/proxy/README.md for configuring Nginx.
smart-shell-bash/
├── scripts/
│ ├── ssh/
│ │ ├── README.md
│ │ └── ...
│ ├── proxy/
│ │ ├── luis122448.com.conf (Example for Frontend)
│ │ ├── luis122448.dev.conf (Example for Backend)
│ │ ├── options-ssl-nginx.conf
│ │ ├── README.md
│ │ └── ...
│ └── ...
└── ...
All contributions are welcome. For more information, please refer to the CONTRIBUTING file.
This project is licensed under the terms of the Creative Commons Attribution-NonCommercial 4.0 License.
