mirror of
https://github.com/fastapi/full-stack-fastapi-template.git
synced 2026-11-03 12:29:42 +00:00
♻️ Simplify Copier environment configuration (#2416)
## AI Disclaimer Using Codex with gpt-5.6-sol. Reviewed manually.
This commit is contained in:
committed by
GitHub
parent
0625bcc8b0
commit
2c7e51505e
@@ -9,9 +9,20 @@ answers_path = Path(__file__).parent / ".copier-answers.yml"
|
|||||||
answers = json.loads(answers_path.read_text())
|
answers = json.loads(answers_path.read_text())
|
||||||
env_path = root_path / ".env"
|
env_path = root_path / ".env"
|
||||||
env_content = env_path.read_text()
|
env_content = env_path.read_text()
|
||||||
|
# Keep deployment provider settings from replacing local development defaults.
|
||||||
|
env_answer_keys = {
|
||||||
|
"emails_from_email",
|
||||||
|
"first_superuser",
|
||||||
|
"first_superuser_password",
|
||||||
|
"postgres_password",
|
||||||
|
"project_name",
|
||||||
|
"secret_key",
|
||||||
|
}
|
||||||
lines = []
|
lines = []
|
||||||
for line in env_content.splitlines():
|
for line in env_content.splitlines():
|
||||||
for key, value in answers.items():
|
for key, value in answers.items():
|
||||||
|
if key not in env_answer_keys:
|
||||||
|
continue
|
||||||
upper_key = key.upper()
|
upper_key = key.upper()
|
||||||
if line.startswith(f"{upper_key}="):
|
if line.startswith(f"{upper_key}="):
|
||||||
if " " in value:
|
if " " in value:
|
||||||
|
|||||||
@@ -199,12 +199,8 @@ The input variables, with their default values (some auto generated) are:
|
|||||||
- `secret_key`: (default: `"changethis"`) The secret key for the project, used for security, stored in .env, you can generate one with the method above.
|
- `secret_key`: (default: `"changethis"`) The secret key for the project, used for security, stored in .env, you can generate one with the method above.
|
||||||
- `first_superuser`: (default: `"admin@example.com"`) The email of the first superuser (in .env).
|
- `first_superuser`: (default: `"admin@example.com"`) The email of the first superuser (in .env).
|
||||||
- `first_superuser_password`: (default: `"changethis"`) The password of the first superuser (in .env).
|
- `first_superuser_password`: (default: `"changethis"`) The password of the first superuser (in .env).
|
||||||
- `smtp_host`: (default: "") The SMTP server host to send emails, you can set it later in .env.
|
|
||||||
- `smtp_user`: (default: "") The SMTP server user to send emails, you can set it later in .env.
|
|
||||||
- `smtp_password`: (default: "") The SMTP server password to send emails, you can set it later in .env.
|
|
||||||
- `emails_from_email`: (default: `"info@example.com"`) The email account to send emails from, you can set it later in .env.
|
- `emails_from_email`: (default: `"info@example.com"`) The email account to send emails from, you can set it later in .env.
|
||||||
- `postgres_password`: (default: `"changethis"`) The password for the PostgreSQL database, stored in .env, you can generate one with the method above.
|
- `postgres_password`: (default: `"changethis"`) The password for the PostgreSQL database, stored in .env, you can generate one with the method above.
|
||||||
- `sentry_dsn`: (default: "") The DSN for Sentry, if you are using it, you can set it later in .env.
|
|
||||||
|
|
||||||
## Backend Development
|
## Backend Development
|
||||||
|
|
||||||
|
|||||||
-20
@@ -21,21 +21,6 @@ first_superuser_password:
|
|||||||
help: The password of the first superuser (in .env)
|
help: The password of the first superuser (in .env)
|
||||||
default: changethis
|
default: changethis
|
||||||
|
|
||||||
smtp_host:
|
|
||||||
type: str
|
|
||||||
help: The SMTP server host to send emails, you can set it later in .env
|
|
||||||
default: ""
|
|
||||||
|
|
||||||
smtp_user:
|
|
||||||
type: str
|
|
||||||
help: The SMTP server user to send emails, you can set it later in .env
|
|
||||||
default: ""
|
|
||||||
|
|
||||||
smtp_password:
|
|
||||||
type: str
|
|
||||||
help: The SMTP server password to send emails, you can set it later in .env
|
|
||||||
default: ""
|
|
||||||
|
|
||||||
emails_from_email:
|
emails_from_email:
|
||||||
type: str
|
type: str
|
||||||
help: The email account to send emails from, you can set it later in .env
|
help: The email account to send emails from, you can set it later in .env
|
||||||
@@ -49,11 +34,6 @@ postgres_password:
|
|||||||
python -c "import secrets; print(secrets.token_urlsafe(32))"'
|
python -c "import secrets; print(secrets.token_urlsafe(32))"'
|
||||||
default: changethis
|
default: changethis
|
||||||
|
|
||||||
sentry_dsn:
|
|
||||||
type: str
|
|
||||||
help: The DSN for Sentry, if you are using it, you can set it later in .env
|
|
||||||
default: ""
|
|
||||||
|
|
||||||
_exclude:
|
_exclude:
|
||||||
# Global
|
# Global
|
||||||
- .vscode
|
- .vscode
|
||||||
|
|||||||
+10
-4
@@ -200,16 +200,22 @@ To configure them, go to your repository's **Settings** > **Environments** and c
|
|||||||
|
|
||||||
For each GitHub Environment (`staging` and `production`), configure the required secrets as [environment secrets](https://docs.github.com/en/actions/how-tos/write-workflows/choose-what-workflows-do/use-secrets#creating-secrets-for-an-environment). Environment secrets are preferred over [repository secrets](https://docs.github.com/en/actions/how-tos/write-workflows/choose-what-workflows-do/use-secrets#creating-secrets-for-a-repository) because they are scoped to the specific environment, reducing exposure and aligning with any protection rules you configure.
|
For each GitHub Environment (`staging` and `production`), configure the required secrets as [environment secrets](https://docs.github.com/en/actions/how-tos/write-workflows/choose-what-workflows-do/use-secrets#creating-secrets-for-an-environment). Environment secrets are preferred over [repository secrets](https://docs.github.com/en/actions/how-tos/write-workflows/choose-what-workflows-do/use-secrets#creating-secrets-for-a-repository) because they are scoped to the specific environment, reducing exposure and aligning with any protection rules you configure.
|
||||||
|
|
||||||
The current Github Actions workflows expect these secrets:
|
The deployment workflows require these secrets:
|
||||||
|
|
||||||
* `DOMAIN`
|
* `DOMAIN`
|
||||||
* `EMAILS_FROM_EMAIL`
|
|
||||||
* `FIRST_SUPERUSER`
|
* `FIRST_SUPERUSER`
|
||||||
* `FIRST_SUPERUSER_PASSWORD`
|
* `FIRST_SUPERUSER_PASSWORD`
|
||||||
* `POSTGRES_PASSWORD`
|
* `POSTGRES_PASSWORD`
|
||||||
* `SECRET_KEY`
|
* `SECRET_KEY`
|
||||||
* `LATEST_CHANGES`
|
|
||||||
* `SMOKESHOW_AUTH_KEY`
|
To enable emails, configure these additional secrets with the values from your email provider:
|
||||||
|
|
||||||
|
* `SMTP_HOST`
|
||||||
|
* `SMTP_USER`
|
||||||
|
* `SMTP_PASSWORD`
|
||||||
|
* `EMAILS_FROM_EMAIL`
|
||||||
|
|
||||||
|
To enable Sentry, configure the `SENTRY_DSN` secret.
|
||||||
|
|
||||||
## GitHub Action Deployment Workflows
|
## GitHub Action Deployment Workflows
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user