Files
Maxence G. de Montauzan 9a8a7042b3 API to manage subscription
Adapt docker part
Improve log
Add a just target
2023-12-30 01:19:24 +01:00

72 lines
2.0 KiB
Makefile

# https://github.com/casey/just
venv := "./venv"
pip := venv / "bin/pip"
python := venv / "bin/python"
last_commit_sha1 := `git rev-parse --short HEAD`
remote_image_name := "gitea.gdemontauzan.fr/maxenceg2m/github-release-notifier"
remote_build_image := remote_image_name + ":" + last_commit_sha1
# Run the script
run: _ensure_venv_is_ok
{{ python }} notifier.py
# Launch the API
api: _ensure_venv_is_ok
{{ venv }}/bin/uvicorn notifier:app --reload
# Init python virtual env
init:
python3 -m venv venv
{{ pip }} install --requirement requirements.txt
sha256sum requirements.txt > {{ venv }}/requirements.sha
# Inspiration: https://github.com/behave/behave/blob/afb6b6716cd0f3e028829416475312db804a6aa9/justfile
_ensure_venv_is_ok:
#!/usr/bin/env python3
from subprocess import run
from os import path
if run("sha256sum -c {{ venv }}/requirements.sha", shell=True).returncode != 0:
run("just init", shell=True)
# Clean workspace - remove venv - and init
reinit: hclean init
# Remove virtual env (venv)
hclean:
rm -fr venv
# Run docker compose then show logs
dup: dbuild
docker compose up -d
docker compose logs
# Build with docker compose
dbuild:
docker compose build
# Down docker compose then build
drebuild: ddown dbuild
# Down docker compose
ddown:
docker compose down
# Docker build without cache
dforce-build:
docker compose build --no-cache
# Push a working images on registry, tagged with commit-sha1
dpush: dbuild
docker tag github-release-notifier {{ remote_build_image }}
docker push {{ remote_build_image }}
echo "To push a tagged version, do 'just release <version>'"
# Use just a number! Without 'v'! Release a version - create a tagged images, push it and create git tag.
release version: dbuild
docker tag github-release-notifier {{ remote_image_name }}:{{ version }}
docker push {{ remote_image_name }}:{{ version }}
git tag -a v{{ version }} -m ""
git push --tags