Git Product home page Git Product logo

twitch-snapper's Introduction

Twitch Snapper

sudo apt install python3.11-distutils
curl -sS https://bootstrap.pypa.io/get-pip.py | python3.11
pipenv install
pipenv shell
python -m snapper.main
# just serve frontend
python -m snapper.main no_serve
docker compose -f docker-compose.dev.yaml up -d

MariaDB is running on port 3306 phpMyAdmin is running on port 8080

Testing

docker compose -f docker-compose.test.yaml up -d
python -m unittest test.triggerTest

This will start a dev MariaDB database on port 3307 with test credentials. The test script will load the default .env file and then override existing keys like APP_ENV and DATABASE_URI from the .env.test file.

Alembic

alembic init -t async alembic

Empty database, save the first revision:

alembic revision --autogenerate -m "Initial migration"

Apply Migration:

alembic upgrade head

Deployment Strategy

We utilize GitOps (as Dirk calls it) to deploy on the remote server. The deployment is kicked of when a new tag is pushed to the git repository. The Github Action Ci pipeline will just call the deployment/update_via_ci.sh script in the repo, everything will be built on the remote server. Hence, the process will look like this:

First, on the remote server, we have to git clone this repository and place the age private key in the deployment/ folder. Then, for every tag pushed to this repository, the deployment/update_via_ci.sh is called from within the github pipeline on the remote server via ssh (a private ssh key is stored in the secrets on github for the snapper user that just has the permissions to call this specific script via the setuid-bit). The first argument for the script is the current tag, extracted by the pipeline. This tag is also used to build a docker container for the application. Additionally, age will decrypt the secrets for the docker.env and .env.compose which includes all secrets for the database and twitchAPI. Finally, docker compose up -d restarts the whole application.

Encrypt

cat deployment/docker.env | age -r age1r55yqzcf0qahgn54g3n6y7wncqxx9d80f024l3ck4kn36adw8gfspcnp4e | base64 > deployment/docker.env.encrypted

Decrypt

cat deployment/.env.compose.encrypted | base64 -d | age --decrypt -i key.txt > deployment/.env.compose

twitch-snapper's People

Contributors

kono94 avatar helyux avatar

Stargazers

 avatar

Watchers

Dirk L avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.