| 1 | #!/bin/bash |
| 2 | |
| 3 | currDir=$(pwd) |
| 4 | version="latest" |
| 5 | if [[ ! -z "$1" ]]; then |
| 6 | version="$1" |
| 7 | fi |
| 8 | |
| 9 | # Function to check if Docker is installed |
| 10 | function check_docker_installed() { |
| 11 | if ! command -v docker &> /dev/null; then |
| 12 | echo "Docker could not be found. Please install Docker and try again." |
| 13 | exit 1 |
| 14 | fi |
| 15 | } |
| 16 | |
| 17 | function build_backend() { |
| 18 | echo "" |
| 19 | echo "Build backend (version=${version})" |
| 20 | cd $currDir/backend |
| 21 | docker build . --no-cache -t socfortress/copilot-backend:${version} |
| 22 | } |
| 23 | |
| 24 | function build_frontend() { |
| 25 | echo "" |
| 26 | echo "Build frontend (version=${version})" |
| 27 | cd $currDir/frontend |
| 28 | # Copy the .env.example to .env |
| 29 | cp .env.example .env |
| 30 | # Ask for the new Domain or IP address for the frontend URL |
| 31 | echo "Please enter the new Domain or IP address for the frontend URL (e.g., yourfrontenddomain.com):" |
| 32 | read frontendIp |
| 33 | # Replace only the IP address part in the URL |
| 34 | sed -i "s|0.0.0.0|${frontendIp}|g" .env |
| 35 | docker build . --no-cache -t socfortress/copilot-frontend:${version} |
| 36 | } |
| 37 | |
| 38 | echo "Copilot Docker" |
| 39 | echo "Version: ${version}" |
| 40 | |
| 41 | # First, ensure Docker is installed |
| 42 | check_docker_installed |
| 43 | |
| 44 | # Build processes |
| 45 | #build_backend # Function not needed as SOCFortress will provide the backend but leaving in case you want to build your own |
| 46 | build_frontend |