Refactor database environment variable usage across workflows and application code
All checks were successful
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Successful in 3m53s
All checks were successful
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Successful in 3m53s
- Updated Gitea workflows to standardize on `DB_NAME` instead of `DB_DATABASE` for database name references. - Modified deployment, backup, reset, and restore workflows to ensure consistent environment variable usage. - Removed dotenv dependency and preload script, transitioning to environment variable management directly in scripts. - Adjusted application code to utilize `DB_NAME` for database connections and logging. - Enhanced README to reflect changes in environment variable configuration and usage. - Cleaned up package.json scripts to remove unnecessary preload references.
This commit is contained in:
41
README.md
41
README.md
@@ -27,12 +27,18 @@ We are working on an app to help people save money, by finding good deals that a
|
||||
|
||||
---
|
||||
|
||||
## Required Environment Variables & Setup
|
||||
## Required Secrets & Configuration
|
||||
|
||||
This project requires several secret keys to function. Create a `.env` file in the root of the project and see the `env.example` file for a complete template.
|
||||
This project is configured to run in a CI/CD environment and does not use `.env` files. All configuration and secrets must be provided as environment variables. For deployments using the included Gitea workflows, these must be configured as **repository secrets** in your Gitea instance.
|
||||
|
||||
- **For the AI Service**: `GEMINI_API_KEY`. This is your public-facing Google Gemini API key.
|
||||
- **For the Database**: You will need to provide connection details for your PostgreSQL database, such as `DB_USER`, `DB_HOST`, `DB_DATABASE`, `DB_PASSWORD`, and `DB_PORT`.
|
||||
- **`DB_HOST`, `DB_PORT`, `DB_USER`, `DB_PASSWORD`**: Credentials for your PostgreSQL server.
|
||||
- **`DB_DATABASE_PROD`**: The name of your production database.
|
||||
- **`REDIS_PASSWORD_PROD`**: The password for your production Redis instance.
|
||||
- **`REDIS_PASSWORD_TEST`**: The password for your test Redis instance.
|
||||
- **`JWT_SECRET`**: A long, random, and secret string for signing authentication tokens.
|
||||
- **`VITE_GOOGLE_GENAI_API_KEY`**: Your Google Gemini API key.
|
||||
- **`GOOGLE_MAPS_API_KEY`**: Your Google Maps Geocoding API key.
|
||||
- **`WORKER_CONCURRENCY`**: The number of concurrent jobs the flyer processing worker should handle (e.g., `5`).
|
||||
|
||||
## Setup and Installation
|
||||
|
||||
@@ -55,7 +61,7 @@ This project requires several secret keys to function. Create a `.env` file in t
|
||||
2. **Run the Application**:
|
||||
|
||||
```bash
|
||||
npm run dev
|
||||
npm run start:prod
|
||||
```
|
||||
|
||||
### Step 3: Seed Development Users (Optional)
|
||||
@@ -106,12 +112,6 @@ Under Authorized redirect URIs, click ADD URI and enter the URL where Google wil
|
||||
|
||||
Click Create. You will be given a Client ID and a Client Secret.
|
||||
|
||||
Add these credentials to your .env file at the project root:
|
||||
|
||||
plaintext
|
||||
GOOGLE_CLIENT_ID="your-client-id-from-google"
|
||||
GOOGLE_CLIENT_SECRET="your-client-secret-from-google"
|
||||
|
||||
2. Get GitHub OAuth Credentials
|
||||
You'll need to obtain a Client ID and Client Secret from GitHub:
|
||||
|
||||
@@ -130,12 +130,6 @@ Click Register application.
|
||||
|
||||
You will be given a Client ID and a Client Secret.
|
||||
|
||||
Add these credentials to your .env file at the project root:
|
||||
|
||||
plaintext
|
||||
GITHUB_CLIENT_ID="your-github-client-id"
|
||||
GITHUB_CLIENT_SECRET="your-github-client-secret"
|
||||
|
||||
## connect to postgres on projectium.com
|
||||
|
||||
psql -h localhost -U flyer_crawler_user -d "flyer-crawler-prod" -W
|
||||
@@ -204,16 +198,15 @@ bash
|
||||
psql -U flyer_crawler_user -d "flyer-crawler-prod" -f sql/master_schema_rollup.sql
|
||||
This single command creates all tables, extensions (pg_trgm, postgis), functions, and triggers, and seeds essential data like categories and master items.
|
||||
|
||||
Step 4: Seed the Admin Account
|
||||
Your application has a separate script to create the initial admin user.
|
||||
|
||||
Ensure your .env file on the server is configured with the correct production database credentials (DB_USER, DB_PASSWORD, DB_DATABASE="flyer-crawler-prod", etc.).
|
||||
|
||||
Run the admin seeding script using tsx.
|
||||
Step 4: Seed the Admin Account (If Needed)
|
||||
Your application has a separate script to create the initial admin user. To run it, you must first set the required environment variables in your shell session.
|
||||
|
||||
bash
|
||||
# Set variables for the current session
|
||||
export DB_USER=flyer_crawler_user DB_PASSWORD=your_password DB_NAME="flyer-crawler-prod" ...
|
||||
# Run the seeding script
|
||||
npx tsx src/db/seed_admin_account.ts
|
||||
Your production database is now ready! Your application can connect to it using the flyer_crawler_user role and the credentials in your .env file.
|
||||
Your production database is now ready!
|
||||
|
||||
Part 2: Test Database Setup (for CI/CD)
|
||||
Your Gitea workflow (deploy.yml) already automates the creation and teardown of the test database during the pipeline run. The steps below are for understanding what the workflow does and for manual setup if you ever need to run tests outside the CI pipeline.
|
||||
|
||||
Reference in New Issue
Block a user