MastodonTootFollower/Makefile

61 lines
2.2 KiB
Makefile
Raw Normal View History

.ONESHELL:
SHELL := bash
# https://github.com/JordanMartinez/purescript-cookbook/blob/master/makefile
# set -e = bash immediately exits if any command has a non-zero exit status.
# set -u = a reference to any shell variable you haven't previously
# defined -- with the exceptions of $* and $@ -- is an error, and causes
# the program to immediately exit with non-zero code.
# set -o pipefail = the first non-zero exit code emitted in one part of a
# pipeline (e.g. `cat file.txt | grep 'foo'`) will be used as the exit
# code for the entire pipeline. If all exit codes of a pipeline are zero,
# the pipeline will emit an exit code of 0.
.SHELLFLAGS := -eu -o pipefail -c
.PHONY: all
all: prod
.PHONY: prod
2022-12-14 18:07:22 +01:00
prod: requirements.txt ## Starts a production webserver.
source venv/bin/activate
export PYTHONPATH="${PYTHONPATH}:src"
python3 src/mastodon_toot_follower/server/waitress_server.py
.PHONY: dev
2022-12-14 18:07:22 +01:00
dev: requirements.txt ## Starts a development webserver.
source venv/bin/activate
export PYTHONPATH="${PYTHONPATH}:src"
python3 src/mastodon_toot_follower/server/flask_server.py
2023-01-07 18:47:27 +01:00
.PHONY: publish-docker-image
publish-docker-image: docker-image
sudo docker push p1st/mastodon-toot-follower:latest
sudo docker pushrm p1st/mastodon-toot-follower --file README.md --short "Follow Toots on Mastodon - don't miss new replies or edits."
2022-12-14 18:24:18 +01:00
.PHONY: docker-image
docker-image: ## Builds the mastodon-toot-follower:latest Docker image.
sudo docker build --pull \
2023-01-07 18:47:27 +01:00
--tag p1st/mastodon-toot-follower:latest .
2022-12-14 18:24:18 +01:00
2022-12-14 18:07:22 +01:00
.PHONY: cli
cli: requirements.txt ## Runs the commandline version.
source venv/bin/activate
export PYTHONPATH="${PYTHONPATH}:src"
python3 src/mastodon_toot_follower/cli.py $(MASTODON_TOOT_URL)
.PHONY: requirements.txt
2022-12-14 18:07:22 +01:00
requirements.txt: ## Creates a virtual environment including the python dependencies.
if ! [ -d venv ]; then
python3 -m venv venv
source venv/bin/activate
python3 -m pip install -r requirements.txt
fi
.PHONY: clean
2022-12-14 18:07:22 +01:00
clean: ## Removes all created files.
rm -rf venv ~/.MastodonTootFollower
sudo rm -rf data
.PHONY: help
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'