-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
73c82bc
commit b779d1f
Showing
6 changed files
with
70 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,18 @@ services: | |
- SENTRY_DSN= | ||
- MONITORENV_URL=http://geoserver-monitorenv-stubs:8080 | ||
- MONITORFISH_API_PROTECTED_API_KEY=APIKEY | ||
- FRONTEND_GEOSERVER_LOCAL_URL=//localhost:8081 | ||
- FRONTEND_GEOSERVER_REMOTE_URL=//localhost:8081 | ||
- FRONTEND_IS_DEV_ENV=true | ||
- FRONTEND_MAPBOX_KEY=pk.eyJ1IjoibW9uaXRvcmZpc2giLCJhIjoiY2tsdHJ6dHhhMGZ0eDJ2bjhtZmJlOHJmZiJ9.bdi1cO-cUcZKXdkEkqAoZQ | ||
- FRONTEND_MONITORENV_URL=//localhost:8081 | ||
- FRONTEND_OIDC_AUTHORITY=https://authentification.recette.din.developpement-durable.gouv.fr/authSAML/oidc/monitorfish | ||
- FRONTEND_OIDC_CLIENT_ID=monitorfish | ||
- FRONTEND_OIDC_ENABLED=false | ||
- FRONTEND_OIDC_REDIRECT_URI=https://monitorfish.din.developpement-durable.gouv.fr | ||
- FRONTEND_SENTRY_DSN=https://[email protected]/8 | ||
- FRONTEND_SHOM_KEY=rg8ele7cft4ujkwjspsmtwas | ||
- VITE_SMALL_CHAT_SNIPPET= | ||
ports: | ||
- 8880:8880 | ||
- 8000:8000 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// @ts-ignore | ||
self.env = undefined |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* Make sure to add the env variable to the Env enum located in `domain/types/env.ts` | ||
*/ | ||
// @ts-ignore | ||
self.env = { | ||
VITE_GEOSERVER_LOCAL_URL: "$VITE_GEOSERVER_LOCAL_URL", | ||
VITE_GEOSERVER_REMOTE_URL: "$VITE_GEOSERVER_REMOTE_URL", | ||
VITE_MAPBOX_KEY: "$VITE_MAPBOX_KEY", | ||
VITE_MONITORENV_URL: "$VITE_MONITORENV_URL", | ||
VITE_OIDC_AUTHORITY: "$VITE_OIDC_AUTHORITY", | ||
VITE_OIDC_CLIENT_ID: "$VITE_OIDC_CLIENT_ID", | ||
VITE_OIDC_ENABLED: "$VITE_OIDC_ENABLED", | ||
VITE_OIDC_REDIRECT_URI: "$VITE_OIDC_REDIRECT_URI", | ||
VITE_SENTRY_DSN: "$VITE_SENTRY_DSN", | ||
VITE_SHOM_KEY: "$VITE_SHOM_KEY", | ||
VITE_SMALL_CHAT_SNIPPET: "$VITE_SMALL_CHAT_SNIPPET" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { Env } from './env' | ||
|
||
export type Self = Window & | ||
typeof globalThis & { | ||
env: Record<Env, string> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* eslint-disable no-restricted-globals */ | ||
import type { Env } from '../domain/types/env' | ||
import type { Self } from '../domain/types/self' | ||
|
||
/** | ||
* Get the environment variable: | ||
* - injected by the `env.sh` script at runtime in `window` | ||
* - or from `import.meta.env` | ||
*/ | ||
export function env(name: Env) { | ||
if ((self as Self).env) { | ||
const injectedValue = (self as Self).env[name] | ||
|
||
if (injectedValue) { | ||
if (injectedValue === 'true' || injectedValue === 'false') { | ||
return Boolean(injectedValue) | ||
} | ||
|
||
return injectedValue | ||
} | ||
} | ||
|
||
const valueFromProcess = import.meta.env[name] | ||
if (valueFromProcess === 'true' || valueFromProcess === 'false') { | ||
return Boolean(valueFromProcess) | ||
} | ||
|
||
return valueFromProcess | ||
} | ||
|
||
/* eslint-enable no-restricted-globals */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters