Skip to content

wafflestudio/wacruit-server

Repository files navigation

wacruit-server

Python 3.11.1 Poetry 1.5.1

Prerequisites

  • Python version 3.11 and above is required.
  • Install Poetry package manager to install all the dependencies.
  • A MySQL client is required for database operations in your local machine. On macos, you can install via brew install mysql-client or brew install mysql. Don't forget to add it to PATH.
  • This project requires wacruit-judge which is the fork version of Judge0. To test this project, you first need to clone wacruit-judge and run it using docker-compose.

Installation

Dependencies

Run the following command to install all the dependencies:

poetry config virtualenvs.in-project true
poetry install

The above command will install all the required dependencies in a virtual environment. Ensure that poetry have created .venv folder inside the project root. Otherwise pre-commit hooks won't work.

Pre-commit hooks

This repository uses pre-commit hooks to ensure consistent code quality. To install pre-commit hooks, run the following command:

pre-commit install

Convention

Migration

To generate migrations you should run:

# For automatic change detection.
alembic revision --autogenerate -m "revision summary"

# For empty file generation.
alembic revision

If you want to migrate your database, you should run following commands:

# To perform all pending migrations.
alembic upgrade head

# To run all migrations until the migration with revision_id.
alembic upgrade <revision_id>

If you want to revert migrations, you should run:

# Revert everything.
alembic downgrade base

# revert all migrations up to: revision_id.
alembic downgrade <revision_id>

Testing

MySQL Test DB

docker run --name wacruit-test \
  -e MYSQL_USER=test-user \
  -e MYSQL_PASSWORD=password \
  -e MYSQL_ROOT_PASSWORD=root-password \
  -e MYSQL_DATABASE=testdb \
  -p 3307:3306 \
  -d mysql:5.7  # or mysql:latest

Infra

  • CI/CD
    • Define a Dockerfile to run the application(wacruit-server) and expose the port(8080).
    • Using Github Actions, build and push a Docker image of main repository to ECR.
        1. Configure AWS Credentials (aws-access-key-id, aws-secret-access-key, aws-region)
        1. Login to ECR (aws-actions/amazon-ecr-login@v1)
        1. Build/Tag/Push an image to ECR
  • ecr-heimdall (link)
    • ECR push event triggers AWS Lambda function to update manifest files in waffle-world.

      docker build -t ecr-heimdall . --platform linux/amd64

      docker run --platform linux/amd64 -v ~/.aws/ccredentials:/root/.aws/credentials -it ecr-heimdall

    • ArgoCD detects the change in the manifest file and deploys the new image in waffle-cluster.

  • GitOps
    • With ArgoCD, waffle-cluster lets the new image to be deployed as a Deployment API resource.
    • Define a manifest file in waffle-world/apps/[projectName] including Deployment, ServiceAccount, Service, VirtualService, etc.
    • DevOps tools(ex. Istio, Prometheus, etc.) have been managed by Helm(/charts) and kubectl command(/misc).

About

Backend for wacruit.wafflestudio.com

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages