heartwood every commit a ring

Add makefile

eba4be85 by Isaac Bythewood · 3 years ago

modified .editorconfig
@@ -14,3 +14,7 @@ indent_size = 4[*.md]trim_trailing_whitespace = falseindent_size = 4[Makefile]indent_style = tabindent_size = 4
modified Dockerfile
@@ -1,16 +1,6 @@# A dockerfile to run a blog server## Blog can run very simply as long as we have a few basics:# - python w/ pipenv# - node w/ yarn# - sqlite3# - chromiumFROM alpine:3.16RUN apk add --update --no-cache \      sqlite \      python3 py3-pip \      nodejs yarn \      chromium libstdc++ nss harfbuzz freetype font-noto font-noto-extra font-noto-emoji && \
@@ -27,7 +17,7 @@ RUN yarn install && pipenv install --systemCOPY . .RUN yarn webpack:production && \RUN yarn build && \    rm -rf node_modules && \    python3 manage.py collectstatic --noinput
added Makefile
@@ -0,0 +1,83 @@.PHONY: run runserver webpack check clean push pull.DEFAULT: runSERVER_URL = $(shell git config --get remote.origin.url | cut -d ':' -f 1)INSTALLED_PYTHON_VERSIONS = $(shell ls ~/.pyenv/versions/)REQUIRED_PYTHON_VERSION = $(shell cat Pipfile | grep "^python_version " | cut -d '"' -f 2)run: check install	@echo "run ----------------------------------------------------------------"	${MAKE} -j2 runserver webpackrunserver:	pipenv run python manage.py runserverwebpack:	npx nodemon --watch webpack.config.js --exec \		'webpack --config webpack.config.js --mode development --watch --devtool source-map'check:	@echo "check --------------------------------------------------------------"	@if ! which pipenv > /dev/null; then\		echo "> pipenv not found in PATH, please make sure it's installed along with pyenv";\		echo "> see https://github.com/pyenv/pyenv and install the latest version of python";\		echo "> if you have docker installed you can use https://github.com/overshard/dockerfiles/blob/master/webdev/Dockerfile";\		exit 1;\	fi	@if ! which yarn > /dev/null; then\		echo "> yarn not found in PATH, please make sure it's installed along with node";\		echo "> see https://github.com/nvm-sh/nvm and install the latest version of node";\		echo "> if you have docker installed you can use https://github.com/overshard/dockerfiles/blob/master/webdev/Dockerfile";\		exit 1;\	fi	@if ! echo $(INSTALLED_PYTHON_VERSIONS) | grep -q $(REQUIRED_PYTHON_VERSION); then\		echo "> python $(REQUIRED_PYTHON_VERSION) not found in ~/.pyenv/versions";\		echo "> trying to install it for you via pyenv";\		pyenv install $(REQUIRED_PYTHON_VERSION);\	fi	@echo "> all checks passed"install: node_modules/touchfile .venv/touchfile db.sqlite3node_modules/touchfile: package.json	@echo "install node deps --------------------------------------------------"	yarn install	touch $@	@echo "> all node deps installed".venv/touchfile: Pipfile	@echo "install python deps ------------------------------------------------"	mkdir -p .venv	pipenv install --dev	touch $@	@echo "> all python deps installed"db.sqlite3:	@echo "create database ----------------------------------------------------"	pipenv run python manage.py migrate	@echo "> database created"push:	@echo "push ---------------------------------------------------------------"	git remote | xargs -L1 -I R git push R masterpull:	@echo "pull ---------------------------------------------------------------"	git pull	rsync -avz $(SERVER_URL):/srv/data/blog/db/db.sqlite3 db.sqlite3	rsync -avz $(SERVER_URL):/srv/data/blog/media media	@echo "> all files copied"clean:	@echo "clean --------------------------------------------------------------"	rm -rf node_modules	rm -rf .venv	rm -rf db.sqlite3	rm -rf media	@echo "> all files removed"
modified README.md
@@ -46,6 +46,15 @@ look up any Django tutorial on how to run Django, you shouldn't have a problemgetting this project running on almost anything.## Running locallyIf you have all of the above dependencies installed you can use my Makefile torun and install python and node dependencies locally. Running `make` will checkthat you have the proper dependencies installed and if not it will try andinstall them for you. It will then create you a fresh database and runeverything.## Checking outdated dependenciesThis can be done in both yarn and pipenv with the following two commands:
@@ -66,7 +75,7 @@ I recommend testing everything after this to make sure it's all working.My development system runs Ubuntu so I installed the official webp utils fromGoogle with `apt install webp`.    cwebp -q 85 -m 6 -o /path/to/image.webp /path/to/image.png    cwebp -q 90 -m 6 -o output.webp input.png## Using docker-compose
modified docker-compose.yml
@@ -1,8 +1,3 @@# A docker compose file to run a blog server## We need to make sure the db.sqlite3 database is stored on the host machine# to maintain the data across rebuilds.version: "3"services:
modified package.json
@@ -1,19 +1,7 @@{  "private": true,  "scripts": {    "start": "concurrently --raw yarn:manage:runserver yarn:manage:scheduler yarn:webpack:development",    "manage:scheduler": "pipenv run python manage.py scheduler",    "manage:runserver": "pipenv run python manage.py runserver",    "manage:makemigrations": "pipenv run python manage.py makemigrations",    "manage:migrate": "pipenv run python manage.py migrate",    "manage:createsuperuser": "pipenv run python manage.py createsuperuser",    "webpack:development": "nodemon --watch webpack.config.js --exec 'webpack --config webpack.config.js --mode development --watch --devtool source-map'",    "webpack:production": "webpack --config webpack.config.js --mode production",    "pull": "concurrently --raw yarn:pull:db yarn:pull:media",    "pull:db": "scp `git config --get remote.origin.url | cut -d ':' -f 1`:/srv/data/blog/db/db.sqlite3 .",    "pull:media": "scp -r `git config --get remote.origin.url | cut -d ':' -f 1`:/srv/data/blog/media .",    "format": "concurrently --raw yarn:format:python",    "format:python": "pipenv run black --exclude '/(\\.venv|\\.git|migrations|node_modules)/' ."    "build": "webpack --config webpack.config.js --mode production"  },  "dependencies": {    "@popperjs/core": "^2.11.5",
@@ -24,7 +12,6 @@  "devDependencies": {    "browser-sync": "^2.27.10",    "browser-sync-webpack-plugin": "^2.3.0",    "concurrently": "^7.1.0",    "css-loader": "^6.7.1",    "css-minimizer-webpack-plugin": "^4.0.0",    "eslint": "^8.15.0",
modified yarn.lock
@@ -749,21 +749,6 @@ concat-map@0.0.1:  resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"  integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==concurrently@^7.1.0:  version "7.2.2"  resolved "https://registry.yarnpkg.com/concurrently/-/concurrently-7.2.2.tgz#4ad4a4dfd3945f668d727379de2a29502e6a531c"  integrity sha512-DcQkI0ruil5BA/g7Xy3EWySGrFJovF5RYAYxwGvv9Jf9q9B1v3jPFP2tl6axExNf1qgF30kjoNYrangZ0ey4Aw==  dependencies:    chalk "^4.1.0"    date-fns "^2.16.1"    lodash "^4.17.21"    rxjs "^7.0.0"    shell-quote "^1.7.3"    spawn-command "^0.0.2-1"    supports-color "^8.1.0"    tree-kill "^1.2.2"    yargs "^17.3.1"configstore@^5.0.1:  version "5.0.1"  resolved "https://registry.yarnpkg.com/configstore/-/configstore-5.0.1.tgz#d365021b5df4b98cdd187d6a3b0e3f6a7cc5ed96"
@@ -934,11 +919,6 @@ csso@^4.2.0:  dependencies:    css-tree "^1.1.2"date-fns@^2.16.1:  version "2.28.0"  resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.28.0.tgz#9570d656f5fc13143e50c975a3b6bbeb46cd08b2"  integrity sha512-8d35hViGYx/QH0icHYCeLmsLmMUheMmTyV9Fcm6gvNwdw31yXXH+O85sOBJ+OLnLQMKZowvpKb6FgMIQjcpvQw==debug@2.6.9, debug@^2.2.0:  version "2.6.9"  resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"
@@ -1928,7 +1908,7 @@ lodash.uniq@^4.5.0:  resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773"  integrity sha512-xfBaXQd9ryd9dlSDvnvI0lvxfLJlYAZzXomUYzLKtUeOQvOP5piqAWuGtrhWeqaXK9hhoM/iyJc5AV+XfsX3HQ==lodash@^4, lodash@^4.17.10, lodash@^4.17.14, lodash@^4.17.21:lodash@^4, lodash@^4.17.10, lodash@^4.17.14:  version "4.17.21"  resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"  integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
@@ -2672,13 +2652,6 @@ rxjs@^5.5.6:  dependencies:    symbol-observable "1.0.1"rxjs@^7.0.0:  version "7.5.5"  resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-7.5.5.tgz#2ebad89af0f560f460ad5cc4213219e1f7dd4e9f"  integrity sha512-sy+H0pQofO95VDmFLzyaw9xNJU4KTRSwQIGM6+iG3SypAtCiLDzpeG8sJrNCWn2Up9km+KhkvTdbkrdy+yzZdw==  dependencies:    tslib "^2.1.0"safe-buffer@^5.1.0:  version "5.2.1"  resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6"
@@ -2832,11 +2805,6 @@ shebang-regex@^3.0.0:  resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172"  integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==shell-quote@^1.7.3:  version "1.7.3"  resolved "https://registry.yarnpkg.com/shell-quote/-/shell-quote-1.7.3.tgz#aa40edac170445b9a431e17bb62c0b881b9c4123"  integrity sha512-Vpfqwm4EnqGdlsBFNmHhxhElJYrdfcxPThu+ryKS5J8L/fhAwLazFZtq+S+TWZ9ANj2piSQLGj6NQg+lKPmxrw==signal-exit@^3.0.2:  version "3.0.7"  resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.7.tgz#a9a1767f8af84155114eaabd73f99273c8f59ad9"
@@ -2904,11 +2872,6 @@ source-map@^0.6.0, source-map@^0.6.1:  resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"  integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==spawn-command@^0.0.2-1:  version "0.0.2-1"  resolved "https://registry.yarnpkg.com/spawn-command/-/spawn-command-0.0.2-1.tgz#62f5e9466981c1b796dc5929937e11c9c6921bd0"  integrity sha512-n98l9E2RMSJ9ON1AKisHzz7V42VDiBQGY6PB1BwRglz99wpVsSuGzQ+jOi6lFXBGVTCrRpltvjm+/XA+tpeJrg==stable@^0.1.8:  version "0.1.8"  resolved "https://registry.yarnpkg.com/stable/-/stable-0.1.8.tgz#836eb3c8382fe2936feaf544631017ce7d47a3cf"
@@ -3002,7 +2965,7 @@ supports-color@^7.1.0:  dependencies:    has-flag "^4.0.0"supports-color@^8.0.0, supports-color@^8.1.0:supports-color@^8.0.0:  version "8.1.1"  resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-8.1.1.tgz#cd6fc17e28500cff56c1b86c0a7fd4a54a73005c"  integrity sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==
@@ -3095,16 +3058,6 @@ touch@^3.1.0:  dependencies:    nopt "~1.0.10"tree-kill@^1.2.2:  version "1.2.2"  resolved "https://registry.yarnpkg.com/tree-kill/-/tree-kill-1.2.2.tgz#4ca09a9092c88b73a7cdc5e8a01b507b0790a0cc"  integrity sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==tslib@^2.1.0:  version "2.4.0"  resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.4.0.tgz#7cecaa7f073ce680a05847aa77be941098f36dc3"  integrity sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==type-check@^0.4.0, type-check@~0.4.0:  version "0.4.0"  resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.4.0.tgz#07b8203bfa7056c0657050e3ccd2c37730bab8f1"