Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions template/.envrc.example
Original file line number Diff line number Diff line change
@@ -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 %}
1 change: 1 addition & 0 deletions template/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,4 @@ env

# ignore .direnv
.direnv/
.envrc
3 changes: 2 additions & 1 deletion template/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
9 changes: 3 additions & 6 deletions template/docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,17 @@ 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we automate this by adding it to tasks.py?


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
export LOG_LEVEL=debug
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:
Expand All @@ -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
Expand Down Expand 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.
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.