React Initialization Script

Get Organized

What needs to happen for the React project to be deployed?

VirtualBox

  1. VirtualBox Image created
  2. VirtualBox First time setup completed

Machine State

  1. git must be installed
  2. web server must be installed

Project Artifacts

The artifacts are already built, they just need to be installed onto the machine with git.

  1. use git to clone build artifacts
Note

Build artifacts for this script: https://github.com/LaunchCodeTechnicalTraining/react-tic-tac-toe-build-artifacts

Web Server Configuration

caddy or nginx must be configured to catch HTTP requests and respond as a file_server, and then must be reloaded.

At this point the react project should be accessible in your browser.

Full Script Solution

Click Here for Solution
#!/bin/bash

# Install Dependencies

## Update Package Repositories
sudo apt update -y

## Install Git
sudo apt install git

## Install Caddy

### Install Curl (Needed to install Caddy)
sudo apt install -y curl

curl -1sLf \
  'https://dl.cloudsmith.io/public/caddy/stable/cfg/setup/bash.deb.sh' \
  | sudo bash

sudo apt update -y
sudo apt install caddy

## Cloning Build Artifacts

git clone https://github.com/LaunchCodeTechnicalTraining/react-tic-tac-toe-build-artifacts

## Configure Web Server

(
cat <<'EOF'
https://localhost {
        root * /home/student/react-tic-tac-toe-build-artifacts/
        file_server
}
EOF
) > Caddyfile

sudo mv Caddyfile /etc/caddy/Caddyfile

sudo systemctl stop caddy

sudo caddy start

## Reload Caddy
sudo caddy reload --config /etc/caddy/Caddyfile

Check Browser

React-Project-Browser-Validation React-Project-Browser-Validation