bonfire-app/justfile

950 lines
35 KiB
Makefile
Raw Permalink Normal View History

2022-05-23 02:20:39 +00:00
# recipes for the `just` command runner: https://just.systems
# how to install: https://github.com/casey/just#packages
2023-04-03 01:18:16 +00:00
# we load all vars from .env file into the env of just commands
set dotenv-load
# and export just vars as env vars
set export
2022-05-23 02:20:39 +00:00
## Main configs - override these using env vars
# what flavour do we want?
2023-11-08 08:50:23 +00:00
FLAVOUR := env_var_or_default('FLAVOUR', "classic")
FLAVOUR_PATH := env_var_or_default('FLAVOUR_PATH', "flavours/" + FLAVOUR)
2022-05-23 02:20:39 +00:00
# do we want to use Docker? set as env var:
# - WITH_DOCKER=total : use docker for everything (default)
2023-11-08 08:50:23 +00:00
# - WITH_DOCKER=partial : use docker for services like the DB
2023-04-16 22:13:10 +00:00
# - WITH_DOCKER=easy : use docker for services like the DB & compiled utilities (deprecated, now same as partial)
2022-05-23 02:20:39 +00:00
# - WITH_DOCKER=no : please no
2023-11-08 08:50:23 +00:00
WITH_DOCKER := env_var_or_default('WITH_DOCKER', "total")
2022-05-23 02:20:39 +00:00
2023-11-08 08:50:23 +00:00
MIX_ENV := env_var_or_default('MIX_ENV', "dev")
2022-05-23 02:20:39 +00:00
2023-03-15 19:46:55 +00:00
APP_NAME := "bonfire"
2023-03-15 19:46:55 +00:00
APP_DOCKER_REPO := "bonfirenetworks/"+APP_NAME
APP_DOCKER_REPO_ALT := "ghcr.io/bonfire-networks/bonfire-app"
APP_DOCKER_IMAGE := env_var_or_default('APP_DOCKER_IMAGE', APP_DOCKER_REPO+":latest-" +FLAVOUR)
2023-11-08 08:50:23 +00:00
DB_DOCKER_IMAGE := if arch() == "aarch64" { "ghcr.io/baosystems/postgis:12-3.3" } else { env_var_or_default('DB_DOCKER_IMAGE', "postgis/postgis:12-3.3-alpine") }
# DB_DOCKER_IMAGE := env_var_or_default('DB_DOCKER_IMAGE', "supabase/postgres")
2022-10-17 01:02:24 +00:00
2024-01-16 16:59:30 +00:00
# GRAPH_DB_URL := if WITH_DOCKER != "total" { env_var_or_default('GRAPH_DB_URL', "bolt://localhost:7687") } else { env_var_or_default('GRAPH_DB_URL', "bolt://graph:7687") }
2022-05-23 02:20:39 +00:00
## Other configs - edit these here if necessary
2023-02-05 02:33:36 +00:00
EXT_PATH := "extensions/"
2022-11-29 22:59:22 +00:00
EXTRA_FORKS_PATH := "forks/"
2022-06-24 21:42:35 +00:00
APP_VSN_EXTRA := "beta"
2022-05-23 02:20:39 +00:00
APP_REL_DOCKERFILE :="Dockerfile.release"
APP_REL_DOCKERCOMPOSE :="docker-compose.release.yml"
APP_REL_CONTAINER := APP_NAME + "_release"
WEB_CONTAINER := APP_NAME +"_web"
APP_VSN := `grep -m 1 'version:' mix.exs | cut -d '"' -f2`
2023-11-08 08:50:23 +00:00
APP_BUILD := env_var_or_default('APP_BUILD', `git rev-parse --short HEAD || echo unknown`)
2022-05-23 02:20:39 +00:00
CONFIG_PATH := FLAVOUR_PATH + "/config"
UID := `id -u`
GID := `id -g`
2023-09-17 14:39:53 +00:00
PUBLIC_PORT := env_var_or_default('PUBLIC_PORT', '4000')
DOCKER_EXT_NETWORK := env_var_or_default('DOCKER_EXT_NETWORK', 'bonfire_default')
DOCKER_EXT_NETWORK_BOOL := if DOCKER_EXT_NETWORK == "bonfire_default" { "false" } else { "true" }
2024-01-15 09:52:33 +00:00
TUNNEL_SUBDOMAIN := env_var_or_default('TUNNEL_SUBDOMAIN', 'bonfire-test')
2022-05-23 02:20:39 +00:00
2023-11-08 08:50:23 +00:00
PROXY_CADDYFILE_PATH := if PUBLIC_PORT == "443" { "./config/deploy/Caddyfile2-https" } else { "./config/deploy/Caddyfile2" }
2023-04-03 01:18:16 +00:00
2023-11-08 08:50:23 +00:00
ENV_ENV := if MIX_ENV == "test" { "dev" } else { MIX_ENV }
2022-12-10 20:55:29 +00:00
2022-06-16 22:34:16 +00:00
## Configure just
# choose shell for running recipes
set shell := ["bash", "-uc"]
2023-11-08 08:50:23 +00:00
# set shell := ["bash", "-uxc"]
2022-06-16 22:34:16 +00:00
# support args like $1, $2, etc, and $@ for all args
2022-05-23 02:20:39 +00:00
set positional-arguments
#### GENERAL SETUP RELATED COMMANDS ####
help:
@echo "Just commands for Bonfire:"
@just --list
# Initialise env files, and create some required folders, files and softlinks
2023-11-08 08:50:23 +00:00
config:
2022-06-20 02:30:53 +00:00
@just flavour $FLAVOUR
# Initialise a specific flavour, with its env files, and create some required folders, files and softlinks
2023-11-08 08:50:23 +00:00
@flavour select_flavour:
2023-08-13 10:32:00 +00:00
echo "Switching to flavour '$select_flavour' in $MIX_ENV env..."
2024-04-16 09:59:51 +00:00
just _pre-config $select_flavour
just _pre-setup-env $select_flavour
2024-02-07 22:29:17 +00:00
printf "\nNow make sure to finish the flavour setup with 'just setup'. You can also edit your config for flavour '$select_flavour' in /.env and ./config/ more generally.\n"
setup:
2023-03-29 06:38:11 +00:00
{{ if MIX_ENV == "prod" { "just setup-prod" } else { "just setup-dev" } }}
2024-04-16 09:59:51 +00:00
init services="db": _pre-init
@just services $services
@echo "Light that fire! $APP_NAME with $FLAVOUR flavour in $MIX_ENV - docker:$WITH_DOCKER - $APP_VSN - $APP_BUILD - $FLAVOUR_PATH - {{os_family()}}/{{os()}} on {{arch()}}"
2022-05-23 02:20:39 +00:00
2023-11-08 08:50:23 +00:00
@config-basic select_flavour=FLAVOUR:
2023-08-13 10:32:00 +00:00
echo "Setting up flavour '$select_flavour' in $MIX_ENV env..."
2024-04-16 09:59:51 +00:00
just _pre-config $select_flavour
just setup
echo "Setup done."
2024-04-16 09:59:51 +00:00
@_pre-config select_flavour=FLAVOUR:
rm -rf ./priv/repo/*
2023-08-13 10:32:00 +00:00
-rm ./config/deps.flavour.* 2> /dev/null
-rm ./config/flavour_* 2> /dev/null
2024-04-16 09:59:51 +00:00
just _pre-setup $select_flavour
2024-04-16 09:59:51 +00:00
@_pre-setup flavour='classic':
mkdir -p config
mkdir -p ./flavours/$flavour/config/prod/
mkdir -p ./flavours/$flavour/config/dev/
2024-04-16 09:59:51 +00:00
just _ln-spark-deps
cd config && ln -sfn ../flavours/classic/config/* ./ && ln -sfn ../flavours/$flavour/config/* ./
touch ./config/deps.path
mkdir -p data
mkdir -p data/uploads/
mkdir -p data/search/dev
mkdir -p priv/static/data
mkdir -p extensions/
mkdir -p forks/
chmod 700 .erlang.cookie
2024-04-16 09:59:51 +00:00
_ln-spark-deps:
2024-02-20 20:16:09 +00:00
cd config && (find ../extensions/bonfire/ -type f -name "deps.*" -exec ln -sfn {} ./ \; || find ../deps/bonfire/ -type f -name "deps.*" -exec ln -sfn {} ./ \; || echo "Could not symlink the bonfire_spark deps") && ls -la ./
2024-02-20 19:34:51 +00:00
2024-04-16 09:59:51 +00:00
@_pre-setup-env flavour='classic':
echo "Using flavour '$flavour' at flavours/$flavour with env '$MIX_ENV' with vars from ./flavours/$flavour/config/$ENV_ENV/.env "
2024-04-16 09:59:51 +00:00
test -f ./flavours/$flavour/config/$ENV_ENV/.env || just _pre-setup-env-init flavours/$flavour/config flavours/$flavour/config || just _pre-setup-env-init flavours/classic/config flavours/$flavour/config
-rm .env
ln -sf ./config/$ENV_ENV/.env ./.env
2024-04-16 09:59:51 +00:00
@_pre-setup-env-init from to:
cat {{from}}/templates/public.env {{from}}/templates/not_secret.env > {{to}}/$ENV_ENV/.env && echo "MIX_ENV=$MIX_ENV" >> {{to}}/$ENV_ENV/.env && echo "FLAVOUR=$flavour" >> {{to}}/$ENV_ENV/.env
2023-08-13 10:32:00 +00:00
2024-04-16 09:59:51 +00:00
@_pre-init: _assets-ln
2023-02-05 03:03:44 +00:00
mkdir -p data
2024-02-13 11:43:16 +00:00
mkdir -p ./priv/repo/
cp -rf $FLAVOUR_PATH/repo/* ./priv/repo/
2022-11-30 06:37:19 +00:00
rm -rf ./data/current_flavour
ln -sf ../$FLAVOUR_PATH ./data/current_flavour
mkdir -p priv/static/public
echo "Using $MIX_ENV env, with flavour: $FLAVOUR at path: $FLAVOUR_PATH"
2024-04-16 12:09:33 +00:00
# ulimit -n 524288
2022-05-23 02:20:39 +00:00
#### COMMON COMMANDS ####
2023-11-08 08:50:23 +00:00
setup-dev:
2023-03-29 06:38:11 +00:00
just build
2023-03-23 22:48:45 +00:00
just deps-clean-data
just deps-clean-api
just deps-clean-unused
2024-02-20 19:55:59 +00:00
WITH_GIT_DEPS=0 just mix deps.get
2024-04-16 09:59:51 +00:00
just _ln-spark-deps
2023-03-23 22:48:45 +00:00
just deps-get
2024-02-13 17:07:18 +00:00
extension-post-install:
2024-04-16 09:59:51 +00:00
just _ext-migrations-copy
2024-02-13 17:07:18 +00:00
2024-04-16 09:59:51 +00:00
_ext-migrations-copy:
just mix bonfire.extension.copy_migrations --force
2023-03-23 22:48:45 +00:00
2023-11-08 08:50:23 +00:00
setup-prod:
2022-05-23 02:20:39 +00:00
just build
2023-03-29 06:39:57 +00:00
just deps-get --only prod
2024-04-16 09:59:51 +00:00
just _deps-post-get
2022-05-23 02:20:39 +00:00
# Prepare environment and dependencies
2023-11-08 08:50:23 +00:00
prepare:
2024-04-16 09:59:51 +00:00
just _pre-setup $FLAVOUR
2022-05-23 02:20:39 +00:00
just build
# Run the app in development
2023-11-08 08:50:23 +00:00
@dev *args='':
MIX_ENV=dev just dev-run "db" {{args}}
2022-05-23 02:20:39 +00:00
2023-11-08 08:50:23 +00:00
@dev-extra:
2023-10-17 10:21:18 +00:00
iex --sname extra --remsh localenv
2023-02-04 04:50:23 +00:00
dev-run services="db" *args='':
@just init $services
2023-10-17 10:21:18 +00:00
{{ if WITH_DOCKER == "total" { "just dev-docker $args" } else { "iex --sname localenv -S mix phx.server $args" } }}
2023-02-16 01:38:03 +00:00
# TODO: pass args to docker as well
2022-05-23 02:20:39 +00:00
2022-11-30 00:20:49 +00:00
@dev-remote: init
2023-03-24 02:23:18 +00:00
{{ if WITH_DOCKER == "total" { "just dev-docker -e WITH_FORKS=0" } else { "WITH_FORKS=0 iex -S mix phx.server" } }}
dev-search:
just dev-run search
dev-graph:
just dev-run graph
dev-proxy:
just dev-profile proxy
dev-proxy-iex:
just dev-profile-iex proxy
dev-profile profile: docker-stop-web
docker compose --profile $profile up -d
2023-03-24 03:24:10 +00:00
docker logs bonfire_web -f
dev-profile-iex profile:
docker compose --profile $profile exec web iex --sname extra --remsh localenv
2023-03-24 02:23:18 +00:00
2023-11-08 08:50:23 +00:00
dev-federate:
2024-02-24 14:26:34 +00:00
FEDERATE=yes HOT_CODE_RELOAD=0 HOSTNAME=`just local-tunnel-hostname` PUBLIC_PORT=443 just dev
2023-09-17 13:57:41 +00:00
2023-11-08 08:50:23 +00:00
dev-docker *args='': docker-stop-web
2024-03-04 14:28:24 +00:00
docker compose $args run -e HOT_CODE_RELOAD=0 --name $WEB_CONTAINER --service-ports web
2022-11-30 00:20:49 +00:00
2022-05-23 02:20:39 +00:00
# Generate docs from code & readmes
2023-11-08 08:50:23 +00:00
docs:
2022-11-29 06:48:46 +00:00
just mix docs
2022-05-23 02:20:39 +00:00
2022-09-06 20:59:28 +00:00
# Analyse the codebase and generate some reports. Requires Graphviz and SQLite
arch:
2023-11-08 08:50:23 +00:00
just mix arch.explore.static
2022-09-06 20:59:28 +00:00
just mix arch.explore.xrefs
just mix arch.explore.apps
2022-09-08 02:50:23 +00:00
-MIX_ENV=test just mix arch.explore.coverage
2022-09-06 20:59:28 +00:00
just mix arch.dsm
2022-09-08 02:50:23 +00:00
just mix arch.report.html
mkdir -p reports/dev/static/html/data/
just mix arch.apps.xref --format mermaid --out reports/dev/static/html/data/apps.mermaid
just mix arch.apps.xref --format svg --out reports/dev/static/html/data/apps.svg
2023-11-08 08:50:23 +00:00
# just mix arch.xref --format svg --out reports/dev/static/modules.png Bonfire.Web.Router Bonfire.UI.Social.Routes Bonfire.UI.Me.Routes
2022-09-06 20:59:28 +00:00
2023-02-16 01:38:03 +00:00
# Compile the app + extensions
2023-11-08 08:50:23 +00:00
compile *args='':
just mix bonfire.extension.compile $args
2023-02-16 01:38:03 +00:00
just mix compile $args
# Force the app + extensions to recompile
2023-11-08 08:50:23 +00:00
recompile *args='':
2023-02-16 01:38:03 +00:00
just compile --force $args
2022-05-23 02:20:39 +00:00
2023-11-08 08:50:23 +00:00
dev-test:
2024-02-08 09:22:43 +00:00
@MIX_ENV=test PHX_SERVER=yes just dev-run
2022-05-23 02:20:39 +00:00
# Run the app in dev mode, as a background service
2023-11-08 08:50:23 +00:00
dev-bg: init
2023-03-23 22:36:30 +00:00
{{ if WITH_DOCKER == "total" { "just docker-stop-web && docker compose run --detach --name $WEB_CONTAINER --service-ports web elixir -S mix phx.server" } else { 'elixir --erl "-detached" -S mix phx.server" && echo "Running in background..." && (ps au | grep beam)' } }}
2022-05-23 02:20:39 +00:00
# Run latest database migrations (eg. after adding/upgrading an app/extension)
2023-11-08 08:50:23 +00:00
db-migrate:
2022-06-23 01:16:54 +00:00
just mix "ecto.migrate"
# just mix "excellent_migrations.migrate"
db-migration-checks:
just mix "excellent_migrations.migrate"
2022-05-23 02:20:39 +00:00
# Run latest database seeds (eg. inserting required data after adding/upgrading an app/extension)
2022-06-23 01:16:54 +00:00
db-seeds: db-migrate
just mix "ecto.seeds"
2022-05-23 02:20:39 +00:00
# Reset the DB (caution: this means DATA LOSS)
2023-11-08 08:50:23 +00:00
db-reset: init dev-search-reset db-pre-migrations
2022-06-23 01:16:54 +00:00
just mix "ecto.reset"
2022-05-23 02:20:39 +00:00
2022-06-23 01:16:54 +00:00
dev-search-reset: dev-search-reset-docker
2022-05-23 02:20:39 +00:00
rm -rf data/search/dev
2022-06-23 01:16:54 +00:00
dev-search-reset-docker:
2023-03-23 22:36:30 +00:00
{{ if WITH_DOCKER != "no" { "docker compose rm -s -v search" } else {""} }}
2022-06-23 01:16:54 +00:00
2022-05-23 02:20:39 +00:00
# Rollback previous DB migration (caution: this means DATA LOSS)
2023-11-08 08:50:23 +00:00
db-rollback:
2022-06-23 01:16:54 +00:00
just mix "ecto.rollback"
2022-05-23 02:20:39 +00:00
# Rollback ALL DB migrations (caution: this means DATA LOSS)
2023-11-08 08:50:23 +00:00
db-rollback-all:
2022-05-23 02:20:39 +00:00
just mix "ecto.rollback --all"
#### UPDATE COMMANDS ####
# Update the dev app and all dependencies/extensions/forks, and run migrations
update: init update-repo
just prepare
2023-11-08 08:50:23 +00:00
just update-forks
2022-05-23 02:20:39 +00:00
just update-deps
2023-11-08 08:50:23 +00:00
just mix deps.get
2024-04-16 09:59:51 +00:00
just _deps-post-get
2023-01-04 21:19:59 +00:00
just js-deps-get
2023-11-22 19:22:56 +00:00
# just mix compile
# just db-migrate
2022-05-23 02:20:39 +00:00
# Update the app and Bonfire extensions in ./deps
2023-11-08 08:50:23 +00:00
update-app: update-repo update-deps
2022-05-23 02:20:39 +00:00
2024-04-16 09:59:51 +00:00
_pre-update-deps:
2022-05-23 02:20:39 +00:00
@rm -rf deps/*/assets/pnpm-lock.yaml
@rm -rf deps/*/assets/yarn.lock
2022-12-01 21:47:46 +00:00
@rm -rf deps/bonfire/priv/repo
2022-09-15 19:43:27 +00:00
# Update Bonfire extensions in ./deps
2024-04-16 09:59:51 +00:00
update-deps: _pre-update-deps
2023-11-08 08:50:23 +00:00
just mix-remote updates
2022-05-23 02:20:39 +00:00
2024-04-16 09:59:51 +00:00
update-repo: _pre-contrib-hooks
2022-05-23 02:20:39 +00:00
@chmod +x git-publish.sh && ./git-publish.sh . pull || git pull
2023-11-08 08:50:23 +00:00
update-repo-pull:
2022-05-23 02:20:39 +00:00
@chmod +x git-publish.sh && ./git-publish.sh . pull only
2023-11-08 08:50:23 +00:00
# Update to the latest Bonfire extensions in ./deps
update-deps-bonfire:
2022-11-04 10:18:59 +00:00
just mix-remote bonfire.deps.update
2022-05-23 02:20:39 +00:00
# Update every single dependency (use with caution)
2024-04-16 09:59:51 +00:00
update-deps-all: _pre-update-deps
2023-07-18 08:31:52 +00:00
just update-forks
2022-06-22 06:59:10 +00:00
just mix-remote "deps.update --all"
2024-04-16 09:59:51 +00:00
just _deps-post-get
2024-04-21 13:04:24 +00:00
just update-deps-js
2024-04-16 09:59:51 +00:00
just _assets-ln
2022-09-15 06:40:33 +00:00
just js-ext-deps outdated
2023-07-30 14:02:14 +00:00
-just mix "hex.outdated --all"
2022-05-23 02:20:39 +00:00
2024-04-21 13:04:24 +00:00
# Update every single dependency (use with caution)
update-deps-js:
just js-ext-deps
just js-ext-deps upgrade
2023-12-30 22:30:56 +00:00
# Update a specify dep (eg. `just update.dep needle`)
2024-04-16 09:59:51 +00:00
update-dep dep: _pre-update-deps
2023-11-08 08:50:23 +00:00
just update-fork $dep pull
2022-05-23 02:20:39 +00:00
just mix-remote "deps.update $dep"
2024-04-16 09:59:51 +00:00
just _deps-post-get
2022-11-29 20:16:45 +00:00
./js-deps-get.sh $dep
2022-05-23 02:20:39 +00:00
# Pull the latest commits from all forks
2023-11-08 08:50:23 +00:00
@update-forks:
2023-07-18 12:02:41 +00:00
(jungle git fetch && just update-forks-all rebase) || (echo "Jungle not available, will fetch one by one instead." && just update-forks-all pull)
2023-07-18 08:36:23 +00:00
2023-11-08 08:50:23 +00:00
update-forks-all cmd='pull':
just update-fork-path $EXT_PATH $cmd
just update-fork-path $EXTRA_FORKS_PATH $cmd
2022-05-23 02:20:39 +00:00
# Pull the latest commits from all forks
2023-11-08 08:50:23 +00:00
update-fork dep cmd='pull' mindepth='0' maxdepth='0':
2023-07-23 15:20:02 +00:00
-just update-fork-path $EXT_PATH/$dep $cmd $mindepth $maxdepth
-just update-fork-path $EXTRA_FORKS_PATH/$dep $cmd $mindepth $maxdepth
2023-07-18 08:36:23 +00:00
2023-11-08 08:50:23 +00:00
update-fork-path path cmd='pull' mindepth='0' maxdepth='1':
2023-07-18 08:31:52 +00:00
@chmod +x git-publish.sh
2023-11-08 08:50:23 +00:00
find $path -mindepth $mindepth -maxdepth $maxdepth -type d -exec ./git-publish.sh {} $cmd \;
2022-05-23 02:20:39 +00:00
# Fetch locked version of non-forked deps
2024-01-16 15:48:42 +00:00
@deps-get *args='':
2023-03-29 06:38:11 +00:00
just mix deps.get $@
-just mix-remote deps.get $@ || echo "Oops, could not download mix deps"
2024-04-16 09:59:51 +00:00
just _deps-post-get
2022-09-15 06:40:33 +00:00
just js-deps-get
2022-05-23 02:20:39 +00:00
2024-04-16 09:59:51 +00:00
@_deps-post-get: extension-post-install
2022-12-06 11:24:40 +00:00
ln -sf ../../../priv/static extensions/bonfire/priv/static || ln -sf ../../../priv/static deps/bonfire/priv/static || echo "Could not find a priv/static dir to use"
-cd deps/bonfire/priv && ln -sf ../../../priv/repo
2022-11-30 08:58:25 +00:00
-cd extensions/bonfire/priv && ln -sf ../../../priv/repo
2023-02-05 04:11:06 +00:00
mkdir -p priv/static/data
2023-11-08 08:50:23 +00:00
mkdir -p data
mkdir -p data/uploads
-cd priv/static/data && ln -s ../../../data/uploads
2022-11-30 06:24:55 +00:00
2023-11-08 08:50:23 +00:00
deps-clean dep:
2023-07-17 18:33:02 +00:00
just mix deps.clean $dep --build
2022-06-03 23:58:37 +00:00
2023-11-08 08:50:23 +00:00
@deps-clean-data:
2022-05-23 02:20:39 +00:00
just mix bonfire.deps.clean.data
2023-11-08 08:50:23 +00:00
@deps-clean-api:
2022-05-23 02:20:39 +00:00
just mix bonfire.deps.clean.api
2023-11-08 08:50:23 +00:00
@deps-clean-web:
2023-07-17 18:33:02 +00:00
just deps-clean plug
just deps-clean phoenix_html
2023-05-01 04:40:54 +00:00
just deps-clean bonfire_ui_common
2022-05-23 02:20:39 +00:00
#### DEPENDENCY & EXTENSION RELATED COMMANDS ####
2024-04-16 09:59:51 +00:00
js-deps-get: js-ext-deps _assets-ln
2022-05-23 02:20:39 +00:00
@js-ext-deps yarn_args='':
2023-11-08 08:50:23 +00:00
chmod +x ./config/deps.js.sh
2022-09-15 06:40:33 +00:00
just cmd ./config/deps.js.sh $yarn_args
2022-05-23 02:20:39 +00:00
2024-04-16 09:59:51 +00:00
@_assets-ln:
2023-03-24 03:31:08 +00:00
{{ if path_exists("extensions/bonfire_ui_common")=="true" { "ln -sf extensions/bonfire_ui_common/assets && echo Assets served from the local UI.Common extension will be used" } else {"ln -sf deps/bonfire_ui_common/assets "} }}
2022-11-30 00:20:49 +00:00
deps-outdated: deps-unlock-unused
2022-05-23 02:20:39 +00:00
@just mix-remote "hex.outdated --all"
2022-08-19 20:23:18 +00:00
deps-clean-unused:
2023-11-08 08:50:23 +00:00
@just mix "deps.clean --build --unused"
deps-unlock-unused:
2023-11-08 08:50:23 +00:00
@just mix "deps.clean --unlock --unused"
2022-08-19 20:23:18 +00:00
2022-05-23 02:20:39 +00:00
dep-clean dep:
2023-11-08 08:50:23 +00:00
@just mix "deps.clean $dep --build"
2024-02-19 20:29:42 +00:00
@just mix "deps.clean bonfire --build"
2022-05-23 02:20:39 +00:00
# Clone a git dep and use the local version, eg: `just dep-clone-local bonfire_me https://github.com/bonfire-networks/bonfire_me`
2023-11-08 08:50:23 +00:00
dep-clone-local dep repo:
2023-02-05 02:33:36 +00:00
git clone $repo $EXT_PATH$dep 2> /dev/null || (cd $EXT_PATH$dep ; git pull)
2022-05-23 02:20:39 +00:00
just dep.go.local dep=$dep
# Clone all bonfire deps / extensions
2023-11-08 08:50:23 +00:00
deps-clone-local-all:
2022-06-16 22:34:16 +00:00
curl -s https://api.github.com/orgs/bonfire-networks/repos?per_page=500 | ruby -rrubygems -e 'require "json"; JSON.load(STDIN.read).each { |repo| %x[just dep.clone.local dep="#{repo["name"]}" repo="#{repo["ssh_url"]}" ]}'
2022-05-23 02:20:39 +00:00
2023-12-30 22:30:56 +00:00
# Switch to using a local path, eg: just dep.go.local needle
2023-11-08 08:50:23 +00:00
dep-go-local dep:
2023-02-05 02:33:36 +00:00
just dep-go-local-path $dep $EXT_PATH$dep
2022-05-23 02:20:39 +00:00
2023-12-30 22:30:56 +00:00
# Switch to using a local path, specifying the path, eg: just dep.go.local dep=needle path=./libs/needle
2023-11-08 08:50:23 +00:00
dep-go-local-path dep path:
2022-05-23 02:20:39 +00:00
just dep-local add $dep $path
just dep-local enable $dep $path
2023-12-30 22:30:56 +00:00
# Switch to using a git repo, eg: just dep.go.git needle https://github.com/bonfire-networks/needle (specifying the repo is optional if previously specified)
2023-11-08 08:50:23 +00:00
dep-go-git dep repo:
-just dep-git add $dep $repo
2022-05-23 02:20:39 +00:00
just dep-git enable $dep NA
just dep-local disable $dep NA
2023-12-30 22:30:56 +00:00
# Switch to using a library from hex.pm, eg: just dep.go.hex dep="needle" version="_> 0.2" (specifying the version is optional if previously specified)
2023-11-08 08:50:23 +00:00
dep-go-hex dep version:
-just dep-hex add dep=$dep version=$version
2022-05-23 02:20:39 +00:00
just dep-hex enable $dep NA
just dep-git disable $dep NA
just dep-local disable $dep NA
2023-12-30 22:30:56 +00:00
# add/enable/disable/delete a hex dep with messctl command, eg: `just dep-hex enable needle 0.2`
2023-11-08 08:50:23 +00:00
dep-hex command dep version:
2022-05-23 02:20:39 +00:00
just messctl "$command $dep $version"
2023-11-08 08:50:23 +00:00
just mix "deps.clean $dep"
2022-05-23 02:20:39 +00:00
2024-04-14 19:08:12 +00:00
# add/enable/disable/delete a git dep with messctl command, eg: `just dep-hex enable needle https://github.com/bonfire-networks/needle
2023-11-08 08:50:23 +00:00
dep-git command dep repo:
2022-05-23 02:20:39 +00:00
just messctl "$command $dep $repo config/deps.git"
2023-11-08 08:50:23 +00:00
just mix "deps.clean $dep"
2022-05-23 02:20:39 +00:00
2023-12-30 22:30:56 +00:00
# add/enable/disable/delete a local dep with messctl command, eg: `just dep-hex enable needle ./libs/needle`
2023-11-08 08:50:23 +00:00
dep-local command dep path:
2022-05-23 02:20:39 +00:00
just messctl "$command $dep $path config/deps.path"
2023-11-08 08:50:23 +00:00
just mix "deps.clean $dep"
2022-05-23 02:20:39 +00:00
# Utility to manage the deps in deps.hex, deps.git, and deps.path (eg. `just messctl help`)
2023-11-08 08:50:23 +00:00
messctl *args='': init
2023-03-23 22:36:30 +00:00
{{ if WITH_DOCKER == "no" { "messctl $@" } else { "docker compose run web messctl $@" } }}
2022-05-23 02:20:39 +00:00
#### CONTRIBUTION RELATED COMMANDS ####
2024-04-16 09:59:51 +00:00
_pre-push-hooks: _pre-contrib-hooks
2022-09-15 06:40:33 +00:00
just mix format
just icons-uniq
2023-07-23 10:42:20 +00:00
just deps-clean bonfire
2023-11-08 08:50:23 +00:00
# just mix changelog
2024-04-16 09:59:51 +00:00
_pre-contrib-hooks:
2022-12-10 01:55:18 +00:00
-ex +%s,/extensions/,/deps/,e -scwq config/deps_hooks.js
rm -rf forks/*/data/uploads/favicons/
rm -rf extensions/*/data/uploads/favicons/
2022-12-10 01:55:18 +00:00
# -sed -i '' 's,/extensions/,/deps/,' config/deps_hooks.js
2022-07-09 04:20:00 +00:00
icons-uniq:
sort -u -o assets/static/images/icons/icons.css assets/static/images/icons/icons.css
2022-05-23 02:20:39 +00:00
# Push all changes to the app and extensions in ./forks
2024-04-16 09:59:51 +00:00
contrib: _pre-push-hooks contrib-forks-publish git-publish
2022-05-23 02:20:39 +00:00
# Push all changes to the app and extensions in forks, increment the app version number, and push a new version/release
2024-04-16 09:59:51 +00:00
contrib-release: _pre-push-hooks contrib-forks-publish update contrib-app-release
2022-05-23 02:20:39 +00:00
2022-06-05 21:59:24 +00:00
# Rebase app's repo and push all changes to the app
2024-04-16 09:59:51 +00:00
contrib-app-only: _pre-push-hooks update-repo git-publish
2022-05-23 02:20:39 +00:00
2022-06-05 21:59:24 +00:00
# Increment the app version number and commit/push
2024-04-16 09:59:51 +00:00
contrib-app-release: _pre-push-hooks contrib-app-release-increment git-publish
2022-05-23 02:20:39 +00:00
2023-11-08 08:50:23 +00:00
# Increment the app version number
@contrib-app-release-increment:
2024-02-14 14:03:42 +00:00
mkdir -p lib/mix
cd lib/mix/ && (ln -sf ../../extensions/bonfire_common/lib/mix_tasks tasks || ln -sf ../../deps/bonfire_common/lib/mix_tasks tasks)
cd lib/mix/tasks/release/ && mix escript.build && ./release ../../../../../ $APP_VSN_EXTRA
2022-05-23 02:20:39 +00:00
2022-07-29 00:47:21 +00:00
contrib-forks-publish: update-forks
2022-05-23 02:20:39 +00:00
2023-11-08 08:50:23 +00:00
contrib-rel-push: contrib-release rel-build-release rel-push
2022-09-30 06:15:36 +00:00
2022-09-19 07:53:42 +00:00
# Count lines of code (requires cloc: `brew install cloc`)
2023-11-08 08:50:23 +00:00
cloc:
cloc lib config extensions/*/lib extensions/*/test test
2022-09-19 07:53:42 +00:00
2022-05-23 02:20:39 +00:00
# Run the git add command on each fork
2023-11-08 08:50:23 +00:00
git-forks-add: deps-git-fix
2023-02-05 02:33:36 +00:00
find $EXT_PATH -mindepth 1 -maxdepth 1 -type d -exec echo add {} \; -exec git -C '{}' add --all . \;
2022-05-23 02:20:39 +00:00
# Run a git status on each fork
2023-11-08 08:50:23 +00:00
git-forks-status:
2023-02-05 02:33:36 +00:00
@jungle git status || find $EXT_PATH -mindepth 1 -maxdepth 1 -type d -exec echo {} \; -exec git -C '{}' status \;
2022-05-23 02:20:39 +00:00
# Run a git command on each fork (eg. `just git-forks pull` pulls the latest version of all local deps from its git remote
2023-11-08 08:50:23 +00:00
git-forks command:
2023-02-05 02:33:36 +00:00
@find $EXT_PATH -mindepth 1 -maxdepth 1 -type d -exec echo $command {} \; -exec git -C '{}' $command \;
2022-05-23 02:20:39 +00:00
# List all diffs in forks
2023-11-08 08:50:23 +00:00
git-diff:
2023-02-05 02:33:36 +00:00
@find $EXT_PATH -mindepth 1 -maxdepth 1 -type d -exec echo {} \; -exec git -C '{}' --no-pager diff --color --exit-code \;
2022-05-23 02:20:39 +00:00
# Run a git command on each dep, to ignore chmod changes
2023-11-08 08:50:23 +00:00
deps-git-fix:
2022-05-23 02:20:39 +00:00
find ./deps -mindepth 1 -maxdepth 1 -type d -exec git -C '{}' config core.fileMode false \;
find ./forks -mindepth 1 -maxdepth 1 -type d -exec git -C '{}' config core.fileMode false \;
# Draft-merge another branch, eg `just git-merge with-valueflows-api` to merge branch `with-valueflows-api` into the current one
2023-11-08 08:50:23 +00:00
@git-merge branch:
2022-05-23 02:20:39 +00:00
git merge --no-ff --no-commit $branch
# Find any git conflicts in forks
2023-11-08 08:50:23 +00:00
@git-conflicts:
2023-02-05 02:33:36 +00:00
find $EXT_PATH -mindepth 1 -maxdepth 1 -type d -exec echo add {} \; -exec git -C '{}' diff --name-only --diff-filter=U \;
2022-05-23 02:20:39 +00:00
2022-06-16 22:34:16 +00:00
@git-publish:
2022-05-23 02:20:39 +00:00
chmod +x git-publish.sh
./git-publish.sh
#### TESTING RELATED COMMANDS ####
# Run tests. You can also run only specific tests, eg: `just test extensions/bonfire_social/test`
2023-11-08 08:50:23 +00:00
test *args='':
2022-10-25 03:02:49 +00:00
@echo "Testing $@..."
2022-06-16 22:34:16 +00:00
MIX_ENV=test just mix test $@
2022-05-23 02:20:39 +00:00
# Run only stale tests
2023-11-08 08:50:23 +00:00
test-stale *args='':
2022-10-25 03:02:49 +00:00
@echo "Testing $@..."
2022-06-16 22:34:16 +00:00
MIX_ENV=test just mix test --stale $@
2022-05-23 02:20:39 +00:00
# Run tests (ignoring changes in local forks)
2023-11-08 08:50:23 +00:00
test-remote *args='':
2022-10-25 03:02:49 +00:00
@echo "Testing $@..."
2022-06-16 22:34:16 +00:00
MIX_ENV=test just mix-remote test $@
2022-05-23 02:20:39 +00:00
# Run stale tests, and wait for changes to any module code, and re-run affected tests
2023-11-08 08:50:23 +00:00
test-watch *args='':
2022-10-25 03:02:49 +00:00
@echo "Testing $@..."
2022-06-16 22:34:16 +00:00
MIX_ENV=test just mix test.watch --stale $@
2022-05-23 02:20:39 +00:00
# Run stale tests, and wait for changes to any module code, and re-run affected tests, and interactively choose which tests to run
2023-11-08 08:50:23 +00:00
test-interactive *args='':
2022-05-23 02:20:39 +00:00
@MIX_ENV=test just mix test.interactive --stale $@
2023-09-11 15:25:30 +00:00
ap_lib := "forks/activity_pub/test/activity_pub"
ap_integration := "extensions/bonfire_federate_activitypub/test/activity_pub_integration"
ap_boundaries := "extensions/bonfire_federate_activitypub/test/ap_boundaries"
ap_ext := "extensions/*/test/*federat* extensions/*/test/*/*federat* extensions/*/test/*/*/*federat*"
2022-10-29 10:30:21 +00:00
# ap_two := "forks/bonfire_federate_activitypub/test/dance"
2023-02-28 03:43:45 +00:00
test-federation: test-federation-dance-positions
2022-10-25 03:02:49 +00:00
just test-stale {{ ap_lib }}
just test-stale {{ ap_integration }}
just test-stale {{ ap_ext }}
2022-12-12 23:14:35 +00:00
just test-federation-dance-positions
2022-10-25 03:02:49 +00:00
TEST_INSTANCE=yes just test-stale --only test_instance
2022-12-12 23:14:35 +00:00
just test-federation-dance-positions
2023-02-28 03:43:45 +00:00
test-federation-lib *args=ap_lib: test-federation-dance-positions
2022-10-25 03:02:49 +00:00
just test-watch $@
2023-09-18 18:58:37 +00:00
test-federation-bonfire *args=ap_integration: test-federation-dance-positions
2022-10-25 03:02:49 +00:00
just test-watch $@
2023-09-18 18:58:37 +00:00
test-federation-boundaries *args="extensions/bonfire_federate_activitypub/test/boundaries": test-federation-dance-positions
2022-10-25 03:02:49 +00:00
just test-watch $@
2023-09-18 18:58:37 +00:00
test-federation-in-extensions *args=ap_ext: test-federation-dance-positions
just test-watch $@
test-federation-dance *args='': test-federation-dance-positions
2023-11-26 18:41:57 +00:00
TEST_INSTANCE=yes just test --only test_instance $@
2022-12-12 23:14:35 +00:00
just test-federation-dance-positions
2023-04-21 23:37:27 +00:00
2023-09-18 18:58:37 +00:00
test-federation-dance-unsigned *args='': test-federation-dance-positions
2023-11-26 18:41:57 +00:00
ACCEPT_UNSIGNED_ACTIVITIES=1 TEST_INSTANCE=yes just test --only test_instance $@
2023-04-21 23:37:27 +00:00
just test-federation-dance-positions
2022-12-12 23:14:35 +00:00
2023-11-08 08:50:23 +00:00
test-federation-dance-positions:
2022-12-12 23:14:35 +00:00
TEST_INSTANCE=yes MIX_ENV=test just mix deps.clean bonfire --build
2023-11-08 08:50:23 +00:00
test-federation-live-DRAGONS *args='':
2024-02-24 14:26:34 +00:00
FEDERATE=yes PHX_SERVER=yes HOSTNAME=`just local-tunnel-hostname` PUBLIC_PORT=443 just test --only live_federation $@
2023-09-17 14:39:53 +00:00
load_testing:
TEST_INSTANCE=yes just mix bonfire.load_testing
2022-05-23 02:20:39 +00:00
# dev-test-watch: init ## Run tests
2023-03-23 22:36:30 +00:00
# docker compose run --service-ports -e MIX_ENV=test web iex -S mix phx.server
2022-05-23 02:20:39 +00:00
# Create or reset the test DB
2023-11-08 08:50:23 +00:00
test-db-reset: init db-pre-migrations
2023-11-26 09:58:42 +00:00
{{ if WITH_DOCKER == "total" { "docker compose run -e MIX_ENV=test web mix ecto.drop --force" } else { "MIX_ENV=test just mix ecto.drop --force" } }}
2022-05-23 02:20:39 +00:00
#### RELEASE RELATED COMMANDS (Docker-specific for now) ####
2024-04-16 09:59:51 +00:00
_rel-init:
MIX_ENV=prod just _pre-init
2022-05-23 02:20:39 +00:00
2024-04-16 11:04:52 +00:00
rel-config: config _rel-init _rel-prepare
2022-05-23 02:20:39 +00:00
# copy current flavour's config, without using symlinks
2024-04-16 09:59:51 +00:00
@_rel-config-prepare:
2022-07-22 00:24:21 +00:00
rm -rf data/current_flavour
mkdir -p data
rm -rf flavours/*/config/*/dev
2023-03-12 00:28:07 +00:00
cp -rfL flavours/classic data/current_flavour
2024-02-16 23:19:05 +00:00
cp -rfL $FLAVOUR_PATH/* data/current_flavour/
2024-02-20 18:51:38 +00:00
cp -rfL extensions/bonfire/deps.* data/current_flavour/config/ || cp -rfL deps/bonfire/deps.* data/current_flavour/config/ || echo "Could not copy the deps definitions from the bonfire_spark dep"
2022-05-23 02:20:39 +00:00
# copy current flavour's config, without using symlinks
2024-04-16 09:59:51 +00:00
@_rel-prepare: _rel-config-prepare
mkdir -p extensions/
2022-07-22 00:24:21 +00:00
mkdir -p forks/
mkdir -p data/uploads/
mkdir -p data/null/
touch data/current_flavour/config/deps.path
2022-05-23 02:20:39 +00:00
2022-06-23 01:16:54 +00:00
# Build the Docker image (with no caching)
2023-11-08 08:50:23 +00:00
rel-rebuild:
2023-02-05 02:33:36 +00:00
just rel-build {{EXT_PATH}} --no-cache
2022-06-23 07:11:32 +00:00
# Build the Docker image (NOT including changes to local forks)
2023-11-08 08:50:23 +00:00
rel-build-release ARGS="":
@echo "Please note that the build will not include any changes in forks that haven't been committed and pushed, you may want to run just contrib-release first."
2023-03-06 19:50:39 +00:00
@just rel-build remote {{ ARGS }}
2022-05-23 02:20:39 +00:00
2023-11-08 08:50:23 +00:00
# Build the release
rel-build USE_EXT="local" ARGS="":
2024-04-16 11:04:52 +00:00
@just {{ if WITH_DOCKER != "no" {"rel-build-docker"} else {"rel-build-OTP"} }} {{ USE_EXT }} {{ ARGS }}
2023-02-05 02:33:36 +00:00
2023-11-08 08:50:23 +00:00
# Build the OTP release
2024-04-16 11:04:52 +00:00
rel-build-OTP USE_EXT="local" ARGS="": _rel-init _rel-prepare
2024-04-16 09:59:51 +00:00
WITH_DOCKER=no just _rel-build-OTP {{ USE_EXT }} {{ ARGS }}
2024-04-16 11:04:52 +00:00
_rel-build-OTP USE_EXT="local" ARGS="":
2024-04-16 12:37:21 +00:00
just _rel-compile-OTP {{ USE_EXT }} {{ ARGS }}
just _rel-compile-assets {{ USE_EXT }}
just _rel-release-OTP {{ USE_EXT }}
_rel-compile-OTP USE_EXT="local" ARGS="":
2024-04-16 10:18:28 +00:00
just rel-mix {{ USE_EXT }} "compile --return-errors {{ ARGS }}"
2024-04-16 12:37:21 +00:00
_rel-compile-assets USE_EXT="local" ARGS="":
2023-02-05 04:49:08 +00:00
-rm -rf priv/static
2024-04-16 13:26:01 +00:00
yarn -v || npm install --global yarn
2024-04-16 13:45:02 +00:00
just js-ext-deps
cd ./assets && yarn && yarn build && cd ..
2024-04-16 12:37:21 +00:00
just rel-mix {{ USE_EXT }} phx.digest {{ ARGS }}
_rel-release-OTP USE_EXT="local" ARGS="":
just rel-mix {{ USE_EXT }} release {{ ARGS }}
2023-02-05 02:33:36 +00:00
2023-11-08 08:50:23 +00:00
rel-mix USE_EXT="local" ARGS="":
2023-02-05 02:33:36 +00:00
@echo {{ ARGS }}
@MIX_ENV=prod CI=1 just {{ if USE_EXT=="remote" {"mix-remote"} else {"mix"} }} {{ ARGS }}
2023-11-08 08:50:23 +00:00
# Build the Docker image
2024-04-16 09:59:51 +00:00
@rel-build-docker USE_EXT="local" ARGS="": _rel-init _rel-prepare assets-prepare
2023-10-14 13:11:19 +00:00
export $(./tool-versions-to-env.sh 3 | xargs) && export $(grep -v '^#' .tool-versions.env | xargs) && export ELIXIR_DOCKER_IMAGE="${ELIXIR_VERSION}-erlang-${ERLANG_VERSION}-alpine-${ALPINE_VERSION}" && echo $ELIXIR_DOCKER_IMAGE && just rel-build-path {{ if USE_EXT=="remote" {"data/null"} else {EXT_PATH} }} {{ ARGS }}
2023-11-08 08:50:23 +00:00
rel-build-path FORKS_TO_COPY_PATH ARGS="":
2023-07-03 09:49:43 +00:00
@echo "Building $APP_NAME with flavour $FLAVOUR for arch {{arch()}} with image $ELIXIR_DOCKER_IMAGE."
2023-02-05 02:33:36 +00:00
@MIX_ENV=prod docker build {{ ARGS }} --progress=plain \
2024-04-01 11:19:53 +00:00
--build-arg FLAVOUR=$FLAVOUR \
2022-05-23 02:20:39 +00:00
--build-arg FLAVOUR_PATH=data/current_flavour \
2023-07-31 21:17:04 +00:00
--build-arg ALPINE_VERSION=$ALPINE_VERSION \
--build-arg ELIXIR_DOCKER_IMAGE=$ELIXIR_DOCKER_IMAGE \
2022-12-09 01:49:21 +00:00
--build-arg FORKS_TO_COPY_PATH={{ FORKS_TO_COPY_PATH }} \
2023-08-08 20:52:08 +00:00
-t $APP_DOCKER_REPO:release-$FLAVOUR-$APP_VSN-$APP_BUILD-{{arch()}} \
2022-05-23 02:20:39 +00:00
-f $APP_REL_DOCKERFILE .
2023-11-08 08:50:23 +00:00
@echo Build complete, tagged as: $APP_DOCKER_REPO:release-$FLAVOUR-$APP_VSN-$APP_BUILD-{{arch()}}
@echo "Remember to run just rel-tag or just rel-push"
2022-05-23 02:20:39 +00:00
2022-07-06 01:39:47 +00:00
2022-05-23 02:20:39 +00:00
# Add latest tag to last build
2023-11-08 08:50:23 +00:00
@rel-tag label='latest':
just rel-tag-commit $APP_BUILD {{label}}
2022-05-23 02:20:39 +00:00
2024-04-16 09:59:51 +00:00
@rel-tag-commit build label='latest': _rel-init
2023-08-08 20:52:08 +00:00
docker tag $APP_DOCKER_REPO:release-$FLAVOUR-$APP_VSN-{{build}}-{{arch()}} $APP_DOCKER_REPO:{{label}}-$FLAVOUR-{{arch()}}
docker tag $APP_DOCKER_REPO:release-$FLAVOUR-$APP_VSN-{{build}}-{{arch()}} $APP_DOCKER_REPO_ALT:release-$FLAVOUR-$APP_VSN-{{build}}
docker tag $APP_DOCKER_REPO:release-$FLAVOUR-$APP_VSN-{{build}}-{{arch()}} $APP_DOCKER_REPO_ALT:{{label}}-$FLAVOUR-{{arch()}}
2022-05-23 02:20:39 +00:00
# Add latest tag to last build and push to Docker Hub
2023-11-08 08:50:23 +00:00
rel-push label='latest':
2022-07-06 01:39:47 +00:00
@just rel-tag {{label}}
2023-06-18 15:34:36 +00:00
@echo just rel-push-only $APP_BUILD {{label}}
2023-03-15 19:46:55 +00:00
@just rel-push-only $APP_BUILD {{label}}
2022-05-23 02:20:39 +00:00
2023-11-08 08:50:23 +00:00
rel-push-only build label='latest':
2023-04-30 08:42:52 +00:00
@echo "Pushing to $APP_DOCKER_REPO"
2023-08-08 21:56:43 +00:00
@docker login && docker push $APP_DOCKER_REPO:release-$FLAVOUR-$APP_VSN-{{build}}-{{arch()}} && docker push $APP_DOCKER_REPO:{{label}}-$FLAVOUR-{{arch()}}
2023-06-19 11:35:56 +00:00
# @just rel-push-only-alt {{build}} {{label}}
2023-03-16 02:11:10 +00:00
2023-11-08 08:50:23 +00:00
rel-push-only-alt build label='latest':
2023-04-30 08:42:52 +00:00
@echo $GITHUB_TOKEN | docker login ghcr.io -u $GITHUB_USER --password-stdin
@echo "Pushing to $APP_DOCKER_REPO_ALT"
2023-08-08 21:56:43 +00:00
@docker push $APP_DOCKER_REPO_ALT:release-$FLAVOUR-$APP_VSN-{{build}}-{{arch()}} && docker push $APP_DOCKER_REPO_ALT:{{label}}-$FLAVOUR-{{arch()}}
2022-07-04 23:22:56 +00:00
2022-05-23 02:20:39 +00:00
# Run the app in Docker & starts a new `iex` console
2024-04-16 09:59:51 +00:00
rel-run services="db proxy": _rel-init docker-stop-web
just rel-services $services
2023-02-25 01:56:55 +00:00
echo Run with Docker based on image $APP_DOCKER_IMAGE
2023-03-23 22:36:30 +00:00
@docker compose -p $APP_REL_CONTAINER -f $APP_REL_DOCKERCOMPOSE run --name $WEB_CONTAINER --service-ports --rm web bin/bonfire start_iex
2022-05-23 02:20:39 +00:00
# Run the app in Docker, and keep running in the background
2024-04-16 09:59:51 +00:00
rel-run-bg services="db proxy": _rel-init docker-stop-web
just rel-services $services
2023-03-23 22:36:30 +00:00
@docker compose -p $APP_REL_CONTAINER -f $APP_REL_DOCKERCOMPOSE up -d
2022-05-23 02:20:39 +00:00
# Stop the running release
2023-11-08 08:50:23 +00:00
rel-stop:
2023-03-23 22:36:30 +00:00
@docker compose -p $APP_REL_CONTAINER -f $APP_REL_DOCKERCOMPOSE stop
2022-05-23 02:20:39 +00:00
2022-05-23 03:04:46 +00:00
rel-update: update-repo-pull
2023-03-23 22:36:30 +00:00
@docker compose -p $APP_REL_CONTAINER -f $APP_REL_DOCKERCOMPOSE pull
2022-05-23 02:20:39 +00:00
@echo Remember to run migrations on your DB...
rel-logs:
2023-03-23 22:36:30 +00:00
@docker compose -p $APP_REL_CONTAINER -f $APP_REL_DOCKERCOMPOSE logs
2022-05-23 02:20:39 +00:00
# Stop the running release
2023-11-08 08:50:23 +00:00
rel-down: rel-stop
2023-03-23 22:36:30 +00:00
@docker compose -p $APP_REL_CONTAINER -f $APP_REL_DOCKERCOMPOSE down
2022-05-23 02:20:39 +00:00
# Runs a the app container and opens a simple shell inside of the container, useful to explore the image
2024-04-16 09:59:51 +00:00
rel-shell services="db proxy": _rel-init docker-stop-web
just rel-services $services
2023-03-23 22:36:30 +00:00
@docker compose -p $APP_REL_CONTAINER -f $APP_REL_DOCKERCOMPOSE run --name $WEB_CONTAINER --service-ports --rm web /bin/bash
2022-05-23 02:20:39 +00:00
# Runs a simple shell inside of the running app container, useful to explore the image
2024-04-16 09:59:51 +00:00
rel-shell-bg services="db proxy": _rel-init
just rel-services $services
2023-03-23 22:36:30 +00:00
@docker compose -p $APP_REL_CONTAINER -f $APP_REL_DOCKERCOMPOSE exec web /bin/bash
2022-05-23 02:20:39 +00:00
# Runs a simple shell inside of the DB container, useful to explore the image
2024-04-16 09:59:51 +00:00
rel-db-shell-bg: _rel-init
just rel-services db
2023-03-23 22:36:30 +00:00
@docker compose -p $APP_REL_CONTAINER -f $APP_REL_DOCKERCOMPOSE exec db /bin/bash
2022-05-23 02:20:39 +00:00
2024-04-16 09:59:51 +00:00
rel-db-dump: _rel-init
just rel-services db
2023-03-23 22:36:30 +00:00
docker compose -p $APP_REL_CONTAINER -f $APP_REL_DOCKERCOMPOSE exec db /bin/bash -c "PGPASSWORD=$POSTGRES_PASSWORD pg_dump --username $POSTGRES_USER $POSTGRES_DB" > data/db_dump.sql
2022-05-23 02:20:39 +00:00
2024-04-16 09:59:51 +00:00
rel-db-restore: _rel-init
just rel-services db
2022-05-23 02:20:39 +00:00
cat $file | docker exec -i bonfire_release_db_1 /bin/bash -c "PGPASSWORD=$POSTGRES_PASSWORD psql -U $POSTGRES_USER $POSTGRES_DB"
rel-services services="db":
{{ if WITH_DOCKER != "no" { "echo Starting docker services to run in the background: $services && docker compose -p $APP_REL_CONTAINER -f $APP_REL_DOCKERCOMPOSE up -d $services" } else {""} }}
2022-05-23 02:20:39 +00:00
#### DOCKER-SPECIFIC COMMANDS ####
2023-11-08 08:50:23 +00:00
dc *args='':
2023-03-23 22:36:30 +00:00
docker compose $@
2022-10-17 01:02:24 +00:00
2022-05-23 02:20:39 +00:00
# Start background docker services (eg. db and search backends).
@services services="db":
{{ if MIX_ENV == "prod" { "just rel-services $services" } else { "just dev-services $services" } }}
2022-05-23 02:20:39 +00:00
@dev-services services="db":
{{ if WITH_DOCKER != "no" { "(echo Starting docker services to run in the background: $services && docker compose up -d $services) || echo \"WARNING: You may want to make sure the docker daemon is started or run 'colima start' first.\"" } else { "echo Skipping docker services"} }}
2022-05-23 02:20:39 +00:00
# Build the docker image
2024-01-16 15:48:42 +00:00
@build: init
2023-04-16 22:13:10 +00:00
mkdir -p deps
{{ if WITH_DOCKER != "no" { "docker compose pull || echo Oops, could not download the Docker images!" } else { "just mix hex_setup" } }}
2023-10-14 13:14:00 +00:00
{{ if WITH_DOCKER == "total" { "export $(./tool-versions-to-env.sh 3 | xargs) && export $(grep -v '^#' .tool-versions.env | xargs) && export ELIXIR_DOCKER_IMAGE=${ELIXIR_VERSION}-erlang-${ERLANG_VERSION}-alpine-${ALPINE_VERSION} && docker compose build" } else { "echo ." } }}
2022-05-23 02:20:39 +00:00
# Build the docker image
2023-11-08 08:50:23 +00:00
rebuild: init
2023-03-23 22:36:30 +00:00
{{ if WITH_DOCKER != "no" { "mkdir -p deps && docker compose build --no-cache" } else { "echo Skip building container..." } }}
2022-05-23 02:20:39 +00:00
# Run a specific command in the container (if used), eg: `just cmd messclt` or `just cmd time` or `just cmd "echo hello"`
@cmd *args='': init docker-stop-web
{{ if WITH_DOCKER == "total" { "echo Run $@ in docker && docker compose run --name $WEB_CONTAINER --service-ports web $@" } else {" echo Run $@ && $@"} }}
2022-05-23 02:20:39 +00:00
cwd *args:
cd {{invocation_directory()}}; $@
cwd-test *args:
cd {{invocation_directory()}}; MIX_ENV=test mix test $@
2022-05-23 02:20:39 +00:00
# Open the shell of the web container, in dev mode
2023-11-08 08:50:23 +00:00
shell:
2022-06-16 22:34:16 +00:00
just cmd bash
2022-05-23 02:20:39 +00:00
2023-11-08 08:50:23 +00:00
@docker-stop-web:
2022-06-16 22:34:16 +00:00
-docker stop $WEB_CONTAINER
-docker rm $WEB_CONTAINER
2022-05-23 02:20:39 +00:00
2023-11-08 08:50:23 +00:00
@docker *args='':
docker $@
2023-11-08 08:50:23 +00:00
@docker-compose *args='':
docker compose $@
2022-05-23 02:20:39 +00:00
#### MISC COMMANDS ####
# Open an interactive console
2023-11-08 08:50:23 +00:00
@imix *args='':
just cmd iex -S mix $@
2023-12-30 22:30:56 +00:00
# Run a specific mix command, eg: `just mix deps.get` or `just mix "deps.update needle"`
2023-11-08 08:50:23 +00:00
@mix *args='':
2023-02-05 02:33:36 +00:00
echo % mix $@
2023-03-29 07:03:08 +00:00
{{ if MIX_ENV == "prod" { "just mix-maybe-prod $@" } else { "just cmd mix $@" } }}
2024-04-16 11:04:52 +00:00
@mix-eval *args='': init
echo % mix eval "$@"
{{ if MIX_ENV == "prod" {"echo Skip"} else { 'mix eval "$@"' } }}
2023-11-08 08:50:23 +00:00
@mix-maybe-prod *args='':
2023-03-29 07:03:08 +00:00
{{ if WITH_DOCKER != "no" { "echo Ignoring mix commands when using docker in prod" } else { "just mix-maybe-prod-pre-release $@" } }}
2023-11-08 08:50:23 +00:00
@mix-maybe-prod-pre-release *args='':
2023-03-29 07:03:08 +00:00
{{ if path_exists("./_build/prod/rel/bonfire/bin/bonfire")=="true" { "echo Ignoring mix commands since we already have a prod release (delete _build/prod/rel/bonfire/bin/bonfire if you want to build a new release)" } else { "just cmd mix $@" } }}
2022-05-23 02:20:39 +00:00
2023-12-30 22:30:56 +00:00
# Run a specific mix command, while ignoring any deps cloned into forks, eg: `just mix-remote deps.get` or `just mix-remote deps.update needle`
2023-11-08 08:50:23 +00:00
mix-remote *args='': init
2023-02-05 02:33:36 +00:00
echo % WITH_FORKS=0 mix $@
2023-03-23 22:36:30 +00:00
{{ if WITH_DOCKER == "total" { "docker compose run -e WITH_FORKS=0 web mix $@" } else {"WITH_FORKS=0 mix $@"} }}
2022-05-23 02:20:39 +00:00
xref-dot:
just mix xref graph --format dot --include-siblings
(awk '{if (!a[$0]++ && $1 != "}") print}' extensions/*/xref_graph.dot; echo }) > docs/xref_graph.dot
dot -Tsvg docs/xref_graph.dot -o docs/xref_graph.svg
2022-05-23 02:20:39 +00:00
# Run a specific exh command, see https://github.com/rowlandcodes/exhelp
2023-11-08 08:50:23 +00:00
exh *args='':
2022-06-16 22:34:16 +00:00
just cmd "exh -S mix $@"
2022-05-23 02:20:39 +00:00
2023-11-08 08:50:23 +00:00
licenses:
2022-05-23 02:20:39 +00:00
@mkdir -p docs/DEPENDENCIES/
just mix-remote licenses && mv DEPENDENCIES.md docs/DEPENDENCIES/$FLAVOUR.md
2023-01-16 08:14:25 +00:00
audit:
AS_UMBRELLA=1 just mix sobelow
2022-05-23 02:20:39 +00:00
# Extract strings to-be-localised from the app and installed extensions
2023-11-08 08:50:23 +00:00
localise-extract:
2022-06-16 22:34:16 +00:00
just mix "bonfire.localise.extract"
2022-06-01 01:04:22 +00:00
cd priv/localisation/ && for f in *.pot; do mv -- "$f" "${f%.pot}.po"; done
2023-12-16 19:26:07 +00:00
# TODO: copy .pot strings from extensions/deps
# cp extensions/*/priv/gettext/* priv/localisation/
# cp forks/*/priv/gettext/* priv/localisation/
2022-05-23 02:20:39 +00:00
2022-06-23 07:11:32 +00:00
@localise-tx-init:
pip install transifex-client
2023-11-08 08:50:23 +00:00
tx config mapping-bulk -p bonfire --source-language en --type PO -f '.po' --source-file-dir priv/localisation/ -i fr -i es -i it -i de --expression 'priv/localisation/<lang>/LC_MESSAGES/{filename}{extension}' --execute
2022-06-23 07:11:32 +00:00
# curl -o- https://raw.githubusercontent.com/transifex/cli/master/install.sh | bash
@localise-tx-pull:
tx pull --all --minimum-perc=5 --force
just mix deps.compile bonfire_common --force
2022-06-23 07:11:32 +00:00
@localise-tx-push:
tx push --source
@localise-extract-push: localise-extract localise-tx-push
2022-06-03 23:58:37 +00:00
2023-07-31 20:00:38 +00:00
@assets-prepare:
2023-02-05 03:27:33 +00:00
-mkdir -p priv/static
-mkdir -p priv/static/data
2022-07-19 23:40:50 +00:00
-mkdir -p priv/static/data/uploads
-mkdir -p rel/overlays/
2023-11-08 08:50:23 +00:00
-cp lib/*/*/overlay/* rel/overlays/
2022-05-23 02:20:39 +00:00
# Workarounds for some issues running migrations
2023-11-08 08:50:23 +00:00
@db-pre-migrations:
2022-06-16 22:34:16 +00:00
-touch deps/*/lib/migrations.ex
-touch extensions/*/lib/migrations.ex
2022-06-16 22:34:16 +00:00
-touch forks/*/lib/migrations.ex
-touch priv/repo/*
2022-05-23 02:20:39 +00:00
# Generate secrets
2023-11-08 08:50:23 +00:00
@secrets:
2023-03-24 00:06:24 +00:00
{{ if MIX_ENV == "prod" { "just rands" } else if WITH_DOCKER=="total" { "just rands" } else { "just mix-secrets" } }}
2023-03-23 23:49:51 +00:00
@rands:
2023-11-08 08:50:23 +00:00
just rand
just rand
just rand
2023-03-23 23:49:51 +00:00
2023-03-23 23:58:03 +00:00
@mix-secrets: ln-mix-tasks
2023-01-30 06:45:44 +00:00
cd lib/mix/tasks/secrets/ && mix escript.build && ./secrets 128 3
2023-11-08 08:50:23 +00:00
@ln-mix-tasks:
2023-03-23 23:58:03 +00:00
just mix deps.get
cd lib/mix/ && {{ if path_exists("../../extensions/bonfire_common/lib/mix_tasks")=="true" { "ln -sf ../../extensions/bonfire_common/lib/mix_tasks tasks" } else {"ln -sf ../../deps/bonfire_common/lib/mix_tasks tasks"} }}
2023-03-23 23:58:03 +00:00
2023-11-08 08:50:23 +00:00
@rand:
2023-03-23 23:49:51 +00:00
echo {{ uuid() }}-{{ uuid() }}-{{ uuid() }}-{{ uuid() }}
# note: doesn't work in github CI ^
2022-05-23 02:20:39 +00:00
2022-07-30 21:05:55 +00:00
# Start or stop nix postgres server
@nix-db pg_cmd:
2022-07-30 21:05:55 +00:00
pg_ctl -D ${PGDATA} -l ${PGDATA}/all.log -o "--unix_socket_directories='${PGDATA}'" $pg_cmd
# Initialize postgres database. Only need to run the first time!
nix-db-init: (nix-db "start")
2022-07-30 21:05:55 +00:00
createdb ${PGDATABASE}
createuser -dlsw ${PGUSERNAME}
2022-09-06 20:59:28 +00:00
2024-01-15 09:52:33 +00:00
# to test federation locally you can use `just dev-federate` or `just test-federation-live-DRAGONS`
2024-03-04 22:29:40 +00:00
# and run this in seperate terminal to start the above tunnel: `just tunnel`
tunnel: tunnel-localhost-run
@tunnel-localhost-run:
2024-04-27 09:39:40 +00:00
ssh -R 80:localhost:4000 localhost.run
2024-03-04 22:29:40 +00:00
# this requires `cargo install tunnelto` (the homebrew version of tunnelto doesn't work)
2024-03-04 22:29:40 +00:00
@tunnel-tunnelto:
2024-01-15 09:52:33 +00:00
echo "Opening tunnel on ${TUNNEL_SUBDOMAIN}.tunnelto.dev"
tunnelto --subdomain $TUNNEL_SUBDOMAIN --port ${SERVER_PORT}
2024-01-15 09:52:33 +00:00
@local-tunnel-hostname:
2024-03-04 22:29:40 +00:00
echo ${TUNNEL_DOMAIN}
# echo "${TUNNEL_SUBDOMAIN}.tunnelto.dev"
# just tunnel-pyjamas
@tunnel-pyjamas:
command -v wg-quick &> /dev/null || exit "You need to install Wireguard to run the tunnel/proxy. E.g. with: brew install wireguard-tools"
([ -f tunnel.conf ] || curl https://tunnel.pyjam.as/{{PUBLIC_PORT}} > tunnel.conf) && (wg-quick up ./tunnel.conf || cat tunnel.conf) | pcregrep -o1 'https:\/\/([^/]+)'
@tunnel-pyjamas-down:
wg-quick down ./tunnel.conf
2024-03-04 14:28:24 +00:00
with-docker-total:
just with-docker-switch WITHOUT_DOCKER_TOTAL WITH_DOCKER_TOTAL
2024-03-04 15:34:56 +00:00
without-docker-total:
2024-03-04 14:28:24 +00:00
just with-docker-switch WITH_DOCKER_TOTAL WITHOUT_DOCKER_TOTAL
with-docker-switch old_dir new_dir:
mkdir -p data/{{ old_dir }}
mkdir -p data/{{ new_dir }}
mv _build data/{{ old_dir }}
mv assets/node_modules data/{{ old_dir }}
2024-03-04 15:34:56 +00:00
mv data/{{ new_dir }}/_build ./
mv data/{{ new_dir }}/node_modules assets/
2024-03-04 14:28:24 +00:00