Skip to content

Commit

Permalink
Make sure dev env works without replica set
Browse files Browse the repository at this point in the history
  • Loading branch information
cesarvarela committed Dec 19, 2024
1 parent a76fe7f commit 7434a7e
Show file tree
Hide file tree
Showing 3 changed files with 144 additions and 40 deletions.
61 changes: 61 additions & 0 deletions site/gatsby-site/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Mongo database

API_MONGODB_CONNECTION_STRING=mongodb://127.0.0.1:4110 # MongoDB connection string
MONGODB_CONNECTION_STRING=mongodb://127.0.0.1:4110 # MongoDB connection string
MONGODB_REPLICA_SET= # Name of the MongoDB replica set for high availability
MONGODB_TRANSLATIONS_CONNECTION_STRING=mongodb://127.0.0.1:4110 # MongoDB connection string for the translations database
MONGODB_MIGRATIONS_CONNECTION_STRING=mongodb://127.0.0.1:4110

# Rollbar

ROLLBAR_POST_SERVER_ITEM_ACCESS_TOKEN=dummy # Token for sending error reports to Rollbar from the server
GATSBY_ROLLBAR_TOKEN=dummy # Token for Rollbar error tracking in the Gatsby frontend


# Algolia

GATSBY_ALGOLIA_APP_ID=JD5JCVZEVS # Application ID for Algolia search integration in the Gatsby app
GATSBY_ALGOLIA_SEARCH_KEY=c5e99d93261645721a1765fe4414389c # Public search key for Algolia, used in the Gatsby frontend
ALGOLIA_ADMIN_KEY= # Admin key for managing the Algolia index


# Translations

GATSBY_AVAILABLE_LANGUAGES=en,es # List of languages available for the Gatsby app (e.g., en, es, fr)
GOOGLE_TRANSLATE_API_KEY= # API key for accessing Google Translate services


# Cloudflare R2 storage

CLOUDFLARE_R2_ACCOUNT_ID= # Account ID for Cloudflare R2 storage service
CLOUDFLARE_R2_ACCESS_KEY_ID= # Access key ID for Cloudflare R2 storage
CLOUDFLARE_R2_SECRET_ACCESS_KEY= # Secret access key for Cloudflare R2 storage
CLOUDFLARE_R2_BUCKET_NAME= # Name of the Cloudflare R2 bucket for storage
GATSBY_CLOUDFLARE_R2_PUBLIC_BUCKET_URL= # Public URL for accessing the Cloudflare R2 bucket from the Gatsby app


# Email notifications

MAILERSEND_API_KEY=dummy # API key for MailerSend email service or dummy value if you don't plan to send emails
NOTIFICATIONS_SENDER_NAME=AIID Notifications # Name of the sender for email notifications
NOTIFICATIONS_SENDER=[email protected] # Email address of the sender for email notifications

# Prismic

PRISMIC_ACCESS_TOKEN=MC5aSjFfa0JFQUFDQUFiOURr.77-977-977-977-977-977-9NgI8PU7vv70rKu-_ve-_ve-_ve-_ve-_ve-_vUlN77-9Q2fvv71O77-977-9Y--_ve-_vQ # Access token for Prismic API
GATSBY_PRISMIC_REPO_NAME=aiidstaging # Name of the Prismic repository


# Auth

NEXTAUTH_URL=http://localhost:8000
NEXTAUTH_SECRET=678x1irXYWeiOqTwCv1awvkAUbO9eHa5xzQEYhxhMms=


# Other

GOOGLE_MAPS_API_KEY= # API key for accessing Google Maps services
SITE_URL=http://localhost:8000 # URL
SKIP_PAGE_CREATOR=createBackupsPage # List of page creator functions to skip during build


109 changes: 76 additions & 33 deletions site/gatsby-site/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
<p align="center">
<a href="https://incidentdatabase.ai#gh-light-mode-only">
<img src="./static/logos/Blue_AIID.svg" height="100">
</a>
<a href="https://incidentdatabase.ai#gh-dark-mode-only">
<img src="./static/logos/White_AIID.svg" height="100">
</a>
</p>

<h1 align="center">
Artificial Intelligence Incident Database
</h1>


## Setting Up a Local Development Environment

Once you have cloned the repository, to set up a local development environment for the AIID project, follow these steps:
Expand All @@ -22,48 +36,77 @@ Once you have cloned the repository, to set up a local development environment f

Create a `.env` file in the root of the `gatsby-site` directory. Add the following environment variables to the file, replacing the placeholders with your actual credentials:

```env
REALM_API_APP_ID= # Application ID for MongoDB Realm API
REALM_API_GROUP_ID= # Group ID for MongoDB Realm API
REALM_API_PRIVATE_KEY= # Private key for accessing the MongoDB Realm API
REALM_API_PUBLIC_KEY= # Public key for accessing the MongoDB Realm API
REALM_GRAPHQL_API_KEY= # API key for accessing the Realm GraphQL API
REALM_APP_ID= # App ID used to access MongoDB Realm services
API_MONGODB_CONNECTION_STRING=mongodb://127.0.0.1:4110 # MongoDB connection string
ROLLBAR_POST_SERVER_ITEM_ACCESS_TOKEN= # Token for sending error reports to Rollbar from the server
GATSBY_REALM_APP_ID= # Application ID used in the Gatsby frontend for MongoDB Realm, same as REALM_APP_ID
GATSBY_ALGOLIA_APP_ID= # Application ID for Algolia search integration in the Gatsby app
GATSBY_ALGOLIA_SEARCH_KEY= # Public search key for Algolia, used in the Gatsby frontend
ALGOLIA_ADMIN_KEY= # Admin key for managing the Algolia index
MONGODB_CONNECTION_STRING=mongodb://127.0.0.1:4110 # MongoDB connection string
MONGODB_REPLICA_SET= # Name of the MongoDB replica set for high availability
MONGODB_TRANSLATIONS_CONNECTION_STRING=mongodb://127.0.0.1:4110 # MongoDB connection string for the translations database
GOOGLE_MAPS_API_KEY= # API key for accessing Google Maps services
GATSBY_AVAILABLE_LANGUAGES= # List of languages available for the Gatsby app (e.g., en, es, fr)
GOOGLE_TRANSLATE_API_KEY= # API key for accessing Google Translate services
GATSBY_ROLLBAR_TOKEN= # Token for Rollbar error tracking in the Gatsby frontend
CLOUDFLARE_R2_ACCOUNT_ID= # Account ID for Cloudflare R2 storage service
CLOUDFLARE_R2_ACCESS_KEY_ID= # Access key ID for Cloudflare R2 storage
CLOUDFLARE_R2_SECRET_ACCESS_KEY= # Secret access key for Cloudflare R2 storage
CLOUDFLARE_R2_BUCKET_NAME= # Name of the Cloudflare R2 bucket for storage
GATSBY_CLOUDFLARE_R2_PUBLIC_BUCKET_URL= # Public URL for accessing the Cloudflare R2 bucket from the Gatsby app
MAILERSEND_API_KEY= # API key for MailerSend email service
NOTIFICATIONS_SENDER_NAME= # Name of the sender for email notifications
NOTIFICATIONS_SENDER= # Email address of the sender for email notifications
SITE_URL=http://localhost:8000
```
```env
# Mongo database
API_MONGODB_CONNECTION_STRING=mongodb://127.0.0.1:4110 # MongoDB connection string
MONGODB_CONNECTION_STRING=mongodb://127.0.0.1:4110 # MongoDB connection string
MONGODB_REPLICA_SET= # Name of the MongoDB replica set for high availability
MONGODB_TRANSLATIONS_CONNECTION_STRING=mongodb://127.0.0.1:4110 # MongoDB connection string for the translations database
MONGODB_MIGRATIONS_CONNECTION_STRING=mongodb://127.0.0.1:4110
# Rollbar
ROLLBAR_POST_SERVER_ITEM_ACCESS_TOKEN=dummy # Token for sending error reports to Rollbar from the server
GATSBY_ROLLBAR_TOKEN=dummy # Token for Rollbar error tracking in the Gatsby frontend
# Algolia
GATSBY_ALGOLIA_APP_ID=JD5JCVZEVS # Application ID for Algolia search integration in the Gatsby app
GATSBY_ALGOLIA_SEARCH_KEY=c5e99d93261645721a1765fe4414389c # Public search key for Algolia, used in the Gatsby frontend
ALGOLIA_ADMIN_KEY= # Admin key for managing the Algolia index
# Translations
GATSBY_AVAILABLE_LANGUAGES=en,es # List of languages available for the Gatsby app (e.g., en, es, fr)
GOOGLE_TRANSLATE_API_KEY= # API key for accessing Google Translate services
Ensure that each variable is set correctly to match your development environment's requirements.
# Cloudflare R2 storage
CLOUDFLARE_R2_ACCOUNT_ID= # Account ID for Cloudflare R2 storage service
CLOUDFLARE_R2_ACCESS_KEY_ID= # Access key ID for Cloudflare R2 storage
CLOUDFLARE_R2_SECRET_ACCESS_KEY= # Secret access key for Cloudflare R2 storage
CLOUDFLARE_R2_BUCKET_NAME= # Name of the Cloudflare R2 bucket for storage
GATSBY_CLOUDFLARE_R2_PUBLIC_BUCKET_URL= # Public URL for accessing the Cloudflare R2 bucket from the Gatsby app
# Email notifications
MAILERSEND_API_KEY=dummy # API key for MailerSend email service or dummy value if you don't plan to send emails
NOTIFICATIONS_SENDER_NAME=AIID Notifications # Name of the sender for email notifications
[email protected] # Email address of the sender for email notifications
# Prismic
PRISMIC_ACCESS_TOKEN=MC5aSjFfa0JFQUFDQUFiOURr.77-977-977-977-977-977-9NgI8PU7vv70rKu-_ve-_ve-_ve-_ve-_ve-_vUlN77-9Q2fvv71O77-977-9Y--_ve-_vQ # Access token for Prismic API
GATSBY_PRISMIC_REPO_NAME=aiidstaging # Name of the Prismic repository
# Auth
NEXTAUTH_URL=http://localhost:8000
NEXTAUTH_SECRET=678x1irXYWeiOqTwCv1awvkAUbO9eHa5xzQEYhxhMms=
# Other
GOOGLE_MAPS_API_KEY= # API key for accessing Google Maps services
SITE_URL=http://localhost:8000 # URL
SKIP_PAGE_CREATOR=createBackupsPage # List of page creator functions to skip during build
```

4. **Start a Memory Mongo Instance**
1. **Start a Memory Mongo Instance**

To start a memory MongoDB instance, run the following command:

```bash
npm run start:memory-mongo
```

5. **Start Gatsby and Netlify Development Server**
2. **Start Gatsby and Netlify Development Server**

Finally, start the Gatsby development server along with Netlify dev using:

Expand Down
14 changes: 7 additions & 7 deletions site/gatsby-site/gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ const plugins = [
'entities',
],
connectionString: config.mongodb.connectionString,
extraParams: {
replicaSet: config.mongodb.replicaSet,
},
...(config.mongodb.replicaSet
? { extraParams: { replicaSet: config.mongodb.replicaSet } }
: {}),
},
},
{
Expand All @@ -106,9 +106,9 @@ const plugins = [
[]
),
connectionString: config.mongodb.connectionString,
extraParams: {
replicaSet: config.mongodb.replicaSet,
},
...(config.mongodb.replicaSet
? { extraParams: { replicaSet: config.mongodb.replicaSet } }
: {}),
},
},
{
Expand Down Expand Up @@ -310,6 +310,6 @@ module.exports = {
}),
trailingSlash: `always`,
flags: {
DEV_SSR: true,
// DEV_SSR: true,
},
};

0 comments on commit 7434a7e

Please sign in to comment.