Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closes Issue #1932: Added environment variables to prod's Docker file #2027

Merged
merged 1 commit into from
Mar 30, 2021

Conversation

chrispinkney
Copy link
Contributor

Issue This PR Addresses

Closes Issue #1932

Type of Change

  • Bugfix: Change which fixes an issue
  • New Feature: Change which adds functionality
  • Documentation Update: Change which improves documentation
  • UI: Change which improves UI

Description

This PR adds the required environment variables for the Users MS to prod's Docker file. I added some test values and console.log'd them after running docker-compose --env-file config/env.production up --build and they all displayed just fine. Users should be set up and ready to go once we finally create a Firebase project for Telescope (don't quote me on this.)

I also hardcoded an environment variable (process.env.FIRESTORE_EMULATOR_HOST = 'localhost:8088')in firestore.js which allows developers to test locally when using npm run services:start firebase and cd src/api/users && npm run dev together. This environment variable is only injected when running in dev mode.
To be completely honestly, it's hacky but I couldn't get get the dev version of the users ms to work when running via Docker, only when running using npm run dev. I'd love to spend some time with someone to try and figure this out (as well as properly test prod), as it's worrisome that prod may not actually work, but it is at least set up with this PR.

pic

Checklist

  • Quality: This PR builds and passes our npm test and works locally
  • Tests: This PR includes thorough tests or an explanation of why it does not
  • Screenshots: This PR includes screenshots or GIFs of the changes made or an explanation of why it does not (if applicable)
  • Documentation: This PR includes updated/added documentation to user exposed functionality or configuration variables are added/changed or an explanation of why it does not(if applicable)

@@ -33,7 +33,7 @@ if (
type: FIREBASE_TYPE,
project_id: FIREBASE_PROJECT_ID,
private_key_id: FIREBASE_PRIVATE_KEY_ID,
private_key: FIREBASE_PRIVATE_KEY,
private_key: FIREBASE_PRIVATE_KEY.replace(/\\n/g, '\n'), // escape the newline characters so docker can properly parse the key
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are there newline characters in it at all? It should be a single line of text.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is a single line of text but it does have newline characters in it. I was getting private key errors without this fix (that someone suggested on stackoverflow)

Copy link
Contributor

Choose a reason for hiding this comment

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

In other files where we do this, we've been reading a file (cc @manekenpix, who has done this a bunch and probably has advice).

src/api/users/src/services/firestore.js Show resolved Hide resolved
src/api/users/src/services/firestore.js Outdated Show resolved Hide resolved
@chrispinkney
Copy link
Contributor Author

Big thanks to @manekenpix who graciously spent some time to help me figure out how to get this mess working.

config/env.development Show resolved Hide resolved
docker/development.yml Outdated Show resolved Hide resolved
docker/docker-compose.yml Outdated Show resolved Hide resolved
docker/production.yml Outdated Show resolved Hide resolved
docker/production.yml Show resolved Hide resolved
src/api/users/src/services/firestore.js Outdated Show resolved Hide resolved
src/api/users/src/services/firestore.js Outdated Show resolved Hide resolved
src/api/users/src/services/firestore.js Show resolved Hide resolved
src/api/users/src/services/firestore.js Outdated Show resolved Hide resolved
src/api/users/src/services/firestore.js Outdated Show resolved Hide resolved
* Dev and Docker mode now working both locally and in prod environments
* Overriding FIRESTORE_EMULATOR_HOST in jest.config.e2e.js to pass tests
* Removed dotenv (no longer needed)
* Using cross-env
* Utilizing require instead of fs for firestore keys
* Refactored firestore.js
* Removed unused variables
* Added comments, cleaned up key require in firestore.js, rebased
@chrispinkney chrispinkney merged commit 619541b into Seneca-CDOT:master Mar 30, 2021
@chrispinkney chrispinkney deleted the issue-1932 branch April 22, 2021 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants