Skip to content

Commit 3a7a362

Browse files
committed
Added support for custom path for .env file
Signed-off-by: Lasse Gaardsholt <[email protected]>
1 parent 0d1802b commit 3a7a362

File tree

2 files changed

+27
-9
lines changed

2 files changed

+27
-9
lines changed

README.md

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Here are the key metrics visualized in these charts:
2323

2424
2. **Total Suggestions** This chart illustrates the total number of code suggestions made by GitHub Copilot. It offers a view of the tool's activity and its engagement with users over time.
2525

26-
3. **Total Acceptances:** This visualization focuses on the total number of suggestions accepted by users.
26+
3. **Total Acceptances:** This visualization focuses on the total number of suggestions accepted by users.
2727

2828
<p align="center">
2929
<img width="800" alt="image" src="https://github.com/martedesco/copilot-metrics-viewer/assets/3329307/b84220ae-fbdc-4503-b50b-4689362bf364">
@@ -70,7 +70,7 @@ The language breakdown analysis tab also displays a table showing the Accepted P
7070

7171
4. **Total Active Copilot Chat Users:** a bar chart that illustrates the total number of users who have actively interacted with Copilot over the past 28 days.
7272

73-
## Seat Analysis
73+
## Seat Analysis
7474
<p align="center">
7575
<img width="800" alt="image" src="https://github.com/github-copilot-resources/copilot-metrics-viewer/assets/54096296/51747194-df30-4bfb-8849-54a0510fffcb">
7676
</p>
@@ -88,7 +88,7 @@ The language breakdown analysis tab also displays a table showing the Accepted P
8888

8989
In the `.env` file, you can configure several environment variables that control the behavior of the application.
9090

91-
#### VUE_APP_SCOPE
91+
#### VUE_APP_SCOPE
9292

9393
The `VUE_APP_SCOPE` environment variable in the `.env` file determines the scope of the API calls made by the application. It can be set to either 'enterprise' or 'organization'.
9494

@@ -161,6 +161,8 @@ Proxy can authenticate user using GitHub App. In order to do that, following env
161161
* `GITHUB_CLIENT_SECRET` - client secret of the GitHub App
162162
* `SESSION_SECRET` - random string for securing session state
163163

164+
If you want use a custom path for your `.env` file you can set the environment variable `DOTENV_CONFIG_PATH`.
165+
164166
https://github.com/user-attachments/assets/e5596067-da9c-409d-9b9f-0a688cc1f2c4
165167

166168
It's also possible to run with **PAT Token**, see examples below for required variables.
@@ -180,6 +182,15 @@ To run:
180182
docker run -it --rm -p 8080:3000 --env-file ./.env copilot-metrics-viewer-with-proxy
181183
```
182184

185+
Or with custom path for your `.env` file:
186+
187+
```bash
188+
docker run -it --rm -p 8080:3000 \
189+
-e DOTENV_CONFIG_PATH=/custom/.env \
190+
-v /path/to/your/.env:/custom/.env \
191+
copilot-metrics-viewer-with-proxy
192+
```
193+
183194
Proxy can also run with token hardcoded on the backend (which hides it from frontend calls), here's a sample:
184195

185196
```bash
@@ -204,16 +215,16 @@ docker run -it --rm -p 3000:3000 \
204215
copilot-metrics-viewer-with-proxy
205216
```
206217

207-
## License
218+
## License
208219

209220
This project is licensed under the terms of the MIT open source license. Please refer to [MIT](./LICENSE.txt) for the full terms.
210221

211-
## Maintainers
222+
## Maintainers
212223

213224
[@martedesco](https://github.com/martedesco) & [@karpikpl](https://github.com/karpikpl)
214225

215226
## Support
216227

217-
This project is independently developed and maintained, and is not an official GitHub product. It thrives through the dedicated efforts of ([@martedesco](https://github.com/martedesco)), ([@karpikpl](https://github.com/karpikpl)) our wonderful contributors. A heartfelt thanks to all our contributors! ✨
228+
This project is independently developed and maintained, and is not an official GitHub product. It thrives through the dedicated efforts of ([@martedesco](https://github.com/martedesco)), ([@karpikpl](https://github.com/karpikpl)) our wonderful contributors. A heartfelt thanks to all our contributors! ✨
218229

219230
I aim to provide support through [GitHub Issues](https://github.com/github-copilot-resources/copilot-metrics-viewer/issues). While I strive to stay responsive, I can't guarantee immediate responses. For critical issues, please include "CRITICAL" in the title for quicker attention. 🙏🏼

api/server.mjs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,15 @@ import { createProxyMiddleware } from 'http-proxy-middleware';
88

99
// Construct __dirname equivalent in ES module scope
1010
const __dirname = path.dirname(fileURLToPath(import.meta.url));
11-
dotenv.config({ path: path.join(__dirname, '.env') });
12-
//dotenv.config();
11+
12+
const DOTENV_CONFIG_PATH = process.env.DOTENV_CONFIG_PATH;
13+
14+
if (DOTENV_CONFIG_PATH) {
15+
console.log("DOTENV_CONFIG_PATH is set to: ", DOTENV_CONFIG_PATH)
16+
dotenv.config({ path: DOTENV_CONFIG_PATH });
17+
} else {
18+
dotenv.config({ path: path.join(__dirname, '.env') });
19+
}
1320

1421
const app = express();
1522

@@ -127,4 +134,4 @@ process.on('SIGINT', () => {
127134
});
128135

129136
const PORT = process.env.PORT || 3000;
130-
app.listen(PORT, () => console.log(`Server running on port ${PORT}`));
137+
app.listen(PORT, () => console.log(`Server running on port ${PORT}`));

0 commit comments

Comments
 (0)