Skip to content

Latest commit

 

History

History
109 lines (78 loc) · 4.02 KB

deployment.md

File metadata and controls

109 lines (78 loc) · 4.02 KB

Deployment setup

All CI/CD pipelines are implemented as GitHub workflow actions in .github/workflows. Details regarding the deployed infrastructure is available at coursetable/infra.

Available Environments:

  • Preview
    • PR-specific Vercel frontend deployments that use the Staging backend environment.
    • URL: [branch-name].preview.coursetable.com
  • Staging
  • Production

Runs formatting, linting, and dependency checks. Required as a check for merging PRs.

  • Trigger: PR and master commit
  • Environment: Preview, Staging, Production

Deploys frontend only to Vercel and assigns unique preview link to each commit and each PR. Required as a check for merging PRs.

  • Trigger: PR commit
  • Environment: Preview

Deploys both frontend to Vercel and backend to the staging API Docker Network. Builds latest Docker images and refreshes containers in-place. Allows for sanity-checking and robust testing of new commits before deploying to production.

  • Trigger: master commit
  • Environment: Staging

Deploys both frontend to Vercel and backend to production API Docker Network. Builds latest Docker images and refreshes containers in-place.

  • Trigger: master commit with team lead approval
  • Environment: Production

Manual deployment

Bootstrapping a new server

Ensure that doppler is properly configured with access to the environment configs. We assume that all following commands will be run with root unless otherwise specified.

# Fetch everything.
git clone git@github.com:coursetable/coursetable.git
git clone git@github.com:coursetable/infra.git

# Setup infra.
pushd infra
./deploy.sh
popd

# Setup coursetable.
cd coursetable/api
./start.sh -p

# Setup cron.
echo This should be the contents of the crontab:
cat <<EOF
23 7 * * * bash -l -c "source $HOME/.profile && cd $HOME/infra/db && ./cron_script.sh" 2>&1
EOF
read -p "Add to crontab. Press [enter] when done..."

GitHub Actions Self-Hosted Runner

# Create new user that GitHub Actions assumes as an identity
useradd -m app
usermod -aG sudo app
passwd app

# Make sure to install the self-hosted runner application as the `app` user
su app

Setup the new server as a self-hosted runner for GitHub Actions by following the instructions provided when adding a new self-hosted runner. Be sure to install the runner application as a service as well.

Deploying to the server

Important

On the current CourseTable server, ~ refers to /home/app. If you logged in using any other user, you'll need to change the paths below.

The following instructions are only for manual deployments. Only use this in the case that the GitHub Actions CD workflow fails.

# Run these on the prod server.
cd ~/coursetable/api
git pull # Get changes onto server
./start.sh -p # Deploy the new version in prod