From 25b0b9e58581e9d7487a48d5d8c5cf013b75f8c8 Mon Sep 17 00:00:00 2001 From: Daniel Lindsley Date: Mon, 1 Dec 2025 11:24:58 -0600 Subject: [PATCH 1/4] chore: Moved to `.envrc.example` file. --- template/.envrc.example | 27 +++++++++++++++++++++++++++ template/.gitignore | 1 + template/Makefile | 1 + template/docs/development.md | 9 +++------ 4 files changed, 32 insertions(+), 6 deletions(-) create mode 100644 template/.envrc.example diff --git a/template/.envrc.example b/template/.envrc.example new file mode 100644 index 0000000..b6cd349 --- /dev/null +++ b/template/.envrc.example @@ -0,0 +1,27 @@ +#!/use/bin/env bash + +# Source personal .envrc.local if it exists +if [ -f .envrc.local ]; then + echo "Loading personal environment from .envrc.local" + source .envrc.local +fi + +if command -v nix-shell >/dev/null 2>&1; then + use flake +fi + +# read the secrets from 1Password +# strip whitespace from the value +export AWS_S3_ACCESS_KEY_ID="op://{{ copier__project_name }}/AWS_S3_ACCESS_KEY_ID/token" +export AWS_S3_SECRET_ACCESS_KEY="op://{{ copier__project_name }}/AWS_S3_SECRET_ACCESS_KEY/token" +export AWS_SES_ACCESS_KEY_ID="op://{{ copier__project_name }}/AWS_SES_ACCESS_KEY_ID/token" +export AWS_SES_SECRET_ACCESS_KEY="op://{{ copier__project_name }}/AWS_SES_SECRET_ACCESS_KEY/token" +export POSTGRES_PASSWORD="op://{{ copier__project_name }}/POSTGRES_DB/password" +export POSTGRES_USER="op://{{ copier__project_name }}/POSTGRES_DB/username" +# use sandbox host for secrets generation +export POSTGRES_HOST=postgres +export DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}/{{ copier__project_slug }} +export DJANGO_SECRET_KEY="op://{{ copier__project_name }}/DJANGO_SECRET_KEY/token" +{%- if copier__mail_service == 'Mailgun' %} +# Mailgun api key +export MAILGUN_API_KEY="op://{{ copier__project_name }}/MAILGUN_API_KEY/token"{%- endif %} diff --git a/template/.gitignore b/template/.gitignore index 8188493..c8d82e0 100644 --- a/template/.gitignore +++ b/template/.gitignore @@ -68,3 +68,4 @@ env # ignore .direnv .direnv/ +.envrc diff --git a/template/Makefile b/template/Makefile index 3ac5677..5aac5ad 100644 --- a/template/Makefile +++ b/template/Makefile @@ -72,6 +72,7 @@ backend/requirements/production.txt: compile backend/requirements/tests.txt: compile setup: + cp -n .envrc.example .envrc @echo " $(YELLOW)⛭$(END) Checking if the setup is correct and all prerequisites are installed..." @MISSING=""; \ for exec in $(PREREQUISITE_COMMANDS); do \ diff --git a/template/docs/development.md b/template/docs/development.md index 85d93e9..4ccba96 100644 --- a/template/docs/development.md +++ b/template/docs/development.md @@ -17,11 +17,10 @@ Consult the links below if you prefer to use Minikube or Docker Desktop instead: $ git clone {{ copier__repo_url }} $ cd {{ copier__project_slug }} + $ cp -n .envrc.example .envrc 2. Prepare the environment variables. Edit the `.envrc` file to work for your environment. - **For personal environment configurations**: Create a `.envrc.local` file for your personal development settings that won't be committed to version control: - ```bash # Example .envrc.local file export DEBUG=true @@ -29,8 +28,6 @@ Consult the links below if you prefer to use Minikube or Docker Desktop instead: export LOCAL_DEV_SETTING=custom_value ``` - The `.envrc.local` file will be automatically loaded when you enter the directory (after `.envrc`), allowing you to override or add environment variables without modifying the shared `.envrc` file. - ## Run the kubernetes cluster and the {{ copier__project_slug }} app to develop the code First load the environment variables, then run: @@ -56,7 +53,7 @@ To remove the cluster entirely: $ kind delete cluster --name {{ copier__project_slug }} To switch between different Scaf project contexts: - + $ tilt down # inside the codebase of the previous project $ make setup # inside the codebase of the project you want to work on $ tilt up @@ -95,4 +92,4 @@ Resource limits have been predefined for both Django and NextJS services to ensu - Limits: `cpu: 250m`, `memory: 300Mi` {% endif %} -Ensure these values are appropriate for your environment. If needed, adjust them based on real workload observations in a staging or production environment to balance performance and resource consumption. \ No newline at end of file +Ensure these values are appropriate for your environment. If needed, adjust them based on real workload observations in a staging or production environment to balance performance and resource consumption. From 1bf3df7349a2893b1edc7208f368ad80e609e52b Mon Sep 17 00:00:00 2001 From: Daniel Lindsley Date: Mon, 1 Dec 2025 11:30:50 -0600 Subject: [PATCH 2/4] Added missing EOL Makefile bits. --- template/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/template/Makefile b/template/Makefile index 5aac5ad..3c00d1a 100644 --- a/template/Makefile +++ b/template/Makefile @@ -72,7 +72,7 @@ backend/requirements/production.txt: compile backend/requirements/tests.txt: compile setup: - cp -n .envrc.example .envrc + cp -n .envrc.example .envrc; \ @echo " $(YELLOW)⛭$(END) Checking if the setup is correct and all prerequisites are installed..." @MISSING=""; \ for exec in $(PREREQUISITE_COMMANDS); do \ From 62d75f3b00cda32700aab4478fe3983ae40e03dc Mon Sep 17 00:00:00 2001 From: Daniel Lindsley Date: Mon, 1 Dec 2025 11:33:00 -0600 Subject: [PATCH 3/4] Another? --- template/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/template/Makefile b/template/Makefile index 3c00d1a..75b90df 100644 --- a/template/Makefile +++ b/template/Makefile @@ -73,7 +73,7 @@ backend/requirements/tests.txt: compile setup: cp -n .envrc.example .envrc; \ - @echo " $(YELLOW)⛭$(END) Checking if the setup is correct and all prerequisites are installed..." + @echo " $(YELLOW)⛭$(END) Checking if the setup is correct and all prerequisites are installed..."; \ @MISSING=""; \ for exec in $(PREREQUISITE_COMMANDS); do \ if ! which $$exec > /dev/null 2>&1; then \ From ce3b59fe2d2bb0dc20802f37a6913c97bea149a2 Mon Sep 17 00:00:00 2001 From: Daniel Lindsley Date: Mon, 1 Dec 2025 14:10:02 -0600 Subject: [PATCH 4/4] OMG tabs. --- template/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/template/Makefile b/template/Makefile index 75b90df..a5b11a8 100644 --- a/template/Makefile +++ b/template/Makefile @@ -72,7 +72,7 @@ backend/requirements/production.txt: compile backend/requirements/tests.txt: compile setup: - cp -n .envrc.example .envrc; \ + cp -n .envrc.example .envrc; \ @echo " $(YELLOW)⛭$(END) Checking if the setup is correct and all prerequisites are installed..."; \ @MISSING=""; \ for exec in $(PREREQUISITE_COMMANDS); do \