Skip to content

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.

License

Notifications You must be signed in to change notification settings

luis122448/smart-shell-bash

Repository files navigation

Project Logo

Smart Shell - Deployment Automation

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.

Repositories

Main Repository

Related Repositories

Development Environment Setup

This describes the setup for a local development environment, where each service runs in its own Docker container.

Installation

  1. Create a new directory
sudo mkdir -p /var/www/smart-shell/configurations
  1. Change the owner of the directory
sudo chown -R $USER:$USER /var/www/smart-shell
  1. Clone the repository
cd /var/www/smart-shell/configurations
git clone https://github.com/luis122448/smart-shell-bash.git
cd smart-shell-bash
  1. 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 mypass

Override ports if needed:

bash install.sh -u myuser -p mypass -pp 5432 -rp 6379 -mp 27017 -sp 8080 -ap 4200

Note: The password provided will be used for all database configurations.

  1. Execute the installation script

See above for required parameters.

  1. Verify the installation

This will clone all the related project repositories into the deployments directory.

tree /var/www/smart-shell/deployments

Local Development Workflow

  1. Execute the deployment script

This script builds and starts the Docker containers for each service.

bash deploy.sh
  1. Verify the deployment
sudo docker ps

Deployment Options

This project offers two main ways to deploy the application stack for production or staging environments: Docker Compose and Kubernetes.

Docker Compose Deployment

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.

  1. Navigate to the docker directory:
cd docker
  1. 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 .env

Inside the .env file, you must set the passwords for the databases and can customize ports, domains for CORS, and other parameters.

  1. Deploy:

Use the deploy.sh script within the docker directory to manage the deployment.

bash deploy.sh

This script will handle the creation of necessary directories and start the services defined in docker-compose.yml.

Kubernetes Deployment

For scalable and resilient deployments, you can use the Kubernetes manifests located in the kubernetes/ directory.

  1. Navigate to the kubernetes directory:
cd kubernetes
  1. Configure the Deployment:
  • Domains: Open the configmap.yml file to configure the INGRESS_HOST (your domain) and other service-related URLs like CORS_ALLOWED_ORIGINS.
  • Passwords: The database passwords are not set here. They will be passed securely as a parameter to the deployment script.
  1. 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.

Production SSL and Nginx Configuration

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
│   │   └── ...
│   └── ...
└── ...

Contributing

All contributions are welcome. For more information, please refer to the CONTRIBUTING file.

License

This project is licensed under the terms of the Creative Commons Attribution-NonCommercial 4.0 License.

About

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.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages