Skip to content

Deploying the application

Alexandre Henrique Afonso Campos edited this page Jan 30, 2022 · 5 revisions

This project is still in progress so things can change until we have a stable version.

Deploying the frontend

You can deploy the frontend by simply merging code into the main branch. GH Actions will take care of the rest for you. But if you really want to deploy manually, you can

  • cd client to navigate to the client folder

  • Set environment variables

      export PUBLIC_URL='https://statistics.worldcubeassociation.org/'
      export REACT_APP_BASE_URL='https://statistics-api.worldcubeassociation.org'
    
  • Install and package with yarn install && yarn build

  • Deploy with aws s3 cp build s3://{{BUCKET-NAME}} --recursive

  • Create an invalidation for cloudfront replication

      aws cloudfront create-invalidation --distribution-id ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }} --paths '/*'
    

Deploying the backend

Backend runs as an ECS task.

  • Build a new server image

      cd server
      ./gradlew build -x test
      docker build -t thewca/statistics-server .
    
  • Push a new image to Docker Hub

  • Create a deploy

        aws deploy create-deployment \
          --application-name ${{ secrets.APPLICATION_NAME }} \
          --deployment-group-name ${{ secrets.DEPLOYMENT_GROUP }} \
          --s3-location ${{ secrets.S3_LOCATION }}
    

Deploying cron

Cron image is really simple and it probably won't change much. The image is built on top of the cron script. It clones this repository and executes some scripts. Changes to the other scripts will be reflected to the cron, even using the same image, because it clones the repository and executes scripts from the main branch.

  • Build a new cron image (from the root)

      docker build -t thewca/statistics-cron .
    
  • Push the new image to Docker Hub