Skip to content

Commit

Permalink
Standardize the env variables in env.ts and docker compose config
Browse files Browse the repository at this point in the history
  • Loading branch information
tnagorra committed Nov 8, 2024
1 parent b1322f1 commit da10172
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
8 changes: 3 additions & 5 deletions docker-compose-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,12 @@ services:
target: builder
environment:
NODE_OPTIONS: "--max_old_space_size=1024"
APP_GOOGLE_ANALYTICS_ID: ${FRONTEND_APP_GOOGLE_ANALYTICS_ID?error}
APP_TITLE: ${FRONTEND_APP_TITLE:-IFRC Alert Hub}
APP_MAPBOX_ACCESS_TOKEN: ${FRONTEND_APP_MAPBOX_ACCESS_TOKEN?error}
APP_GRAPHQL_API_ENDPOINT: ${FRONTEND_APP_GRAPHQL_API_ENDPOINT?error}
APP_GRAPHQL_ENDPOINT: ${FRONTEND_APP_GRAPHQL_ENDPOINT?error}
APP_ENVIRONMENT: ${FRONTEND_APP_ENVIRONMENT:-prod}
APP_GRAPHQL_API_ENDPOINT: ${FRONTEND_APP_GRAPHQL_API_ENDPOINT?error}
APP_MAPBOX_ACCESS_TOKEN: ${FRONTEND_APP_MAPBOX_ACCESS_TOKEN?error}
APP_GRAPHQL_CODEGEN_ENDPOINT: ${FRONTEND_APP_GRAPHQL_CODEGEN_ENDPOINT?error}
env_file:
- .env
command: |
sh -c 'pnpm generate && pnpm build && rm -rf /client-build/* ; cp -r build/* /client-build/'
volumes:
Expand Down
12 changes: 10 additions & 2 deletions env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import { defineConfig, Schema } from '@julr/vite-plugin-validate-env';

// TODO: Integrate .env for CI and remove optional() call on required fields
export default defineConfig({
APP_TITLE: Schema.string.optional(),
// Used in vite
APP_GOOGLE_ANALYTICS_ID: Schema.string.optional(),

// Used in application
APP_TITLE: Schema.string.optional(), // NOTE: not used right now
APP_ENVIRONMENT: (key, value) => {
// NOTE: APP_ENVIRONMENT_PLACEHOLDER is meant to be used with image builds
// The value will be later replaced with the actual value
Expand All @@ -18,7 +22,11 @@ export default defineConfig({
},
APP_GRAPHQL_API_ENDPOINT: Schema.string({ format: 'url', protocol: true, tld: false }),
APP_MAPBOX_ACCESS_TOKEN: Schema.string(),
APP_GOOGLE_ANALYTICS_ID: Schema.string.optional(),

// Used in codegen
APP_GRAPHQL_CODEGEN_ENDPOINT: Schema.string(), // NOTE: this is both url and file path

// Used in application, automatically injected by vite
APP_COMMIT_HASH: Schema.string.optional(),
APP_VERSION: Schema.string.optional(),
})
4 changes: 2 additions & 2 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ const {
APP_VERSION,
} = import.meta.env;

export const appTitle = APP_TITLE;
export const environment = APP_ENVIRONMENT;
export const appTitle = APP_TITLE; // not used
export const environment = APP_ENVIRONMENT; // not used
export const api = APP_GRAPHQL_API_ENDPOINT;
export const mapboxToken = APP_MAPBOX_ACCESS_TOKEN;
export const appCommitHash = APP_COMMIT_HASH;
Expand Down

0 comments on commit da10172

Please sign in to comment.