From 6aad01eb0e42e3afac68e8e812b247f1753573fc Mon Sep 17 00:00:00 2001 From: Madison Swain-Bowden Date: Fri, 10 Sep 2021 14:46:29 -0700 Subject: [PATCH] Add is_prod logic to justfile (#71) * Add is_prod logic to justfile * Update documentation --- README.md | 12 +++++++++--- justfile | 14 ++++++-------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 5a4782b..813d806 100644 --- a/README.md +++ b/README.md @@ -11,21 +11,27 @@ To deploy, copy `.env.example` to `.env` and populate with the appropriate value ## Setup +We use `just` as our command runner for this repo. +The same `just` commands described below can be used to deploy production. +The `docker-compose-prod.yml` file defines the minimum services for running in production. +In order to use this file, set the `IS_PROD` environment variable to `true`. +This will run all commands using the prod docker file. + A phone must be registered prior to running the container. This can be done with the following command: ```bash -docker-compose run --rm cli ./register-number.sh +just register ``` After following the registration prompts with your device, the container can be run with: ```bash -docker-compose up -d +just up ``` If a safety number in a group changes, the signal-cli will have issues sending messages. The following verification utility will re-verify these numbers. ```bash -docker-compose run --rm cli signal-scanner-bot-verify +just verify ``` ## Technicalities diff --git a/justfile b/justfile index 3c1fbda..9dbe7fa 100644 --- a/justfile +++ b/justfile @@ -1,5 +1,7 @@ set dotenv-load := false -DC := "docker-compose" +IS_PROD := env_var_or_default("IS_PROD", "") +COMPOSE_FILE := if IS_PROD == "true" {"-f docker-compose-prod.yml "} else {""} +DC := "docker-compose " + COMPOSE_FILE RUN := "run --rm cli" # Build the containers @@ -14,17 +16,13 @@ up service="": down: {{ DC }} down -# Production deployment -deploy: - {{ DC }} -f docker-compose-prod.yml up -d - # Verify all numbers verify: - {{ DC }} -f docker-compose-prod.yml {{ RUN }} signal-scanner-bot-verify + {{ DC }} {{ RUN }} signal-scanner-bot-verify # Register a new number -register file="docker-compose.yml": - {{ DC }} -f {{ file }} {{ RUN }} ./register-number.sh +register: + {{ DC }} {{ RUN }} ./register-number.sh # Static checks static: