Skip to content

Commit

Permalink
feat(config): support env var config via dotenv
Browse files Browse the repository at this point in the history
Allow Form to be configured using a .env file, read by dotenv and
populated into `process.env`.

- `npm install dotenv`
- pick up the `.env` config using dotenv just before we invoke
  the application
- remove `.env` entry from `.dockerignore`
  • Loading branch information
LoneRifle committed Jun 23, 2021
1 parent 6f63ca5 commit 9fc8c9e
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 9 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
**/.elasticbeanstalk
**/node_modules
**/public/lib
**/.env
.eslintrc.json
.prettierrc.json
.travis.yml
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,6 @@ FormSG requires some environment variables in order to function.
More information about the required environment variables can be seen in
[DEPLOYMENT_SETUP.md](/docs/DEPLOYMENT_SETUP.md).

The docker-compose file declares some blank environment variables that are secret and cannot be committed into
the repository. See below instructions to get them injected into the container.

We provide a [`.template-env`](./.template-env) file with the secrets blanked out. You can copy and
paste the variables described into a self-created `.env` file, replacing the
required values with your own.
Expand Down
3 changes: 1 addition & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
"build-frontend": "webpack --config webpack.prod.js",
"build-frontend-dev": "webpack --config webpack.dev.js",
"build-frontend-dev:watch": "webpack --config webpack.dev.js --watch",
"start": "node dist/backend/app/server.js",
"start": "node -r dotenv/config dist/backend/app/server.js",
"dev": "docker-compose up --build",
"docker-dev": "npm run build-frontend-dev:watch & ts-node-dev --respawn --transpile-only --inspect=0.0.0.0 --exit-child -- src/app/server.ts",
"docker-dev": "npm run build-frontend-dev:watch & ts-node-dev --respawn --transpile-only --inspect=0.0.0.0 --exit-child -r dotenv/config -- src/app/server.ts",
"test": "npm run test-backend && npm run test-frontend",
"download-binary": "node tests/end-to-end/helpers/get-mongo-binary.js",
"test-e2e": "npm run test-e2e-build && npm run test-e2e-ci",
Expand Down Expand Up @@ -99,6 +99,7 @@
"csv-string": "^4.0.1",
"date-fns": "^2.22.1",
"dedent-js": "~1.0.1",
"dotenv": "^10.0.0",
"ejs": "^3.1.6",
"express": "^4.16.4",
"express-device": "~0.4.2",
Expand Down Expand Up @@ -253,4 +254,4 @@
"webpack-merge": "^4.1.3",
"worker-loader": "^2.0.0"
}
}
}

0 comments on commit 9fc8c9e

Please sign in to comment.