From 0648dcb96c80169bd2651deb2824f38757025396 Mon Sep 17 00:00:00 2001 From: Garrett Woodford Date: Sat, 23 Mar 2024 00:14:31 -0500 Subject: [PATCH] Added .env file support more directly --- .gitignore | 6 ++++++ api/.gitignore | 1 - api/server.js | 15 ++++++++++++++- docker-compose.yaml | 10 ++++++++++ envSample | 11 +++++++++++ 5 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 .gitignore delete mode 100644 api/.gitignore create mode 100644 envSample diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bd660a7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +.env +**/node_modules/ +package-lock.json +*.swp +.prettyrc +.vscode \ No newline at end of file diff --git a/api/.gitignore b/api/.gitignore deleted file mode 100644 index 2eea525..0000000 --- a/api/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.env \ No newline at end of file diff --git a/api/server.js b/api/server.js index 5c8234d..63c9005 100644 --- a/api/server.js +++ b/api/server.js @@ -17,4 +17,17 @@ app.use("/api/data", dataRoutes); app.use("/api/inventory", inventoryRoutes); const PORT = process.env.PORT || 3000; -app.listen(PORT, () => console.log(`Server running on port ${PORT}`)); +app.listen(PORT, () => { + console.log(`Environment: \n\n + ${JSON.stringify(process.env)}`); + console.log(`Server running on port ${PORT}`); //These will both get updated to smartLogging later + console.log(`System Settings: \n + port = ${process.env.PORT} \n + debug = ${process.env.DEBUG} \n + dotenv_key = ${process.env.DOTENV_KEY} \n + ebay_client_id = ${process.env.EBAY_CLIENT_ID} \n + ebay_client_secret = ${process.env.EBAY_CLIENT_SECRET} \n + ebay_dev_id = ${process.env.EBAY_DEV_ID} \n + ebay_redirect_uri = ${process.env.EBAY_REDIRECT_URI} \n + `); +}); diff --git a/docker-compose.yaml b/docker-compose.yaml index 67c4c6f..2c15f90 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -4,5 +4,15 @@ services: build: ./api ports: - "3000:3000" + env_file: + - .env + # environment: + # PORT: 8005 + # DEBUG: "false" + # DOTENV_KEY: "DotKeyDC" + # EBAY_CLIENT_ID: "EbayClientIDDC" + # EBAY_CLIENT_SECRET: "EbayClientSecretDC" + # EBAY_DEV_ID: "EbayDevIDDC" + # EBAY_REDIRECT_URI: "EbayRedirectURIDC" volumes: - ./api:/usr/src/app # Mount the local ./api directory to /usr/src/app in the container diff --git a/envSample b/envSample new file mode 100644 index 0000000..ea482f6 --- /dev/null +++ b/envSample @@ -0,0 +1,11 @@ +PORT=8003 +DEBUG=true +DOTENV_KEY=DotKey +EBAY_CLIENT_ID=EbayClientID +EBAY_CLIENT_SECRET=EbayClientSecret +EBAY_DEV_ID=EbayDevID +EBAY_REDIRECT_URI=EbayRedirectURI + + +#I'm not 100% on this, but I think the --env-file flag for docker containers should handle this. We just +#need to figure out how that gets consumed. \ No newline at end of file