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..a5b11a8 100644 --- a/template/Makefile +++ b/template/Makefile @@ -72,7 +72,8 @@ backend/requirements/production.txt: compile backend/requirements/tests.txt: compile setup: - @echo " $(YELLOW)⛭$(END) Checking if the setup is correct and all prerequisites are installed..." + 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 \ if ! which $$exec > /dev/null 2>&1; then \ 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.