Skip to content

Commit

Permalink
adapt env variables for docker compose
Browse files Browse the repository at this point in the history
fix

change back

fix back
  • Loading branch information
Pascal-Delange committed Mar 8, 2024
1 parent 55dd731 commit 984717f
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ docker-compose.yml
**/venv
**/env
**/dist
**/build
**/build
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ RUN --mount=type=secret,id=SENTRY_AUTH_TOKEN \
SENTRY_AUTH_TOKEN=$(cat /run/secrets/SENTRY_AUTH_TOKEN) && \
export SENTRY_AUTH_TOKEN=$SENTRY_AUTH_TOKEN && \
pnpm run -r build-with-sourcemaps --release $SENTRY_RELEASE
# Comment above and uncomment below to build the image locally (not in CI)
# RUN pnpm --filter=app-builder run build
ENV NODE_ENV=production
RUN pnpm deploy --filter=app-builder --prod /prod/app-builder

FROM base AS app-builder
Expand Down
3 changes: 2 additions & 1 deletion packages/app-builder/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ NODE_ENV=development
SESSION_SECRET=SESSION_SECRET
SESSION_MAX_AGE=43200

MARBLE_API_DOMAIN=http://localhost:8080
MARBLE_API_DOMAIN_CLIENT=http://localhost:8080
MARBLE_API_DOMAIN_SERVER=http://localhost:8080
MARBLE_APP_DOMAIN=http://localhost:3000

# coment out to use the real firebase
Expand Down
3 changes: 2 additions & 1 deletion packages/app-builder/src/entry.client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ Sentry.init({
// Set `tracePropagationTargets` to control for which URLs distributed tracing should be enabled
tracePropagationTargets: [
getClientEnv('MARBLE_APP_DOMAIN'),
getClientEnv('MARBLE_API_DOMAIN'),
getClientEnv('MARBLE_API_DOMAIN_CLIENT'),
getClientEnv('MARBLE_API_DOMAIN_SERVER'),
],

// Capture Replay for 10% of all sessions,
Expand Down
2 changes: 1 addition & 1 deletion packages/app-builder/src/services/auth/auth.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ export function useSendPasswordResetEmail({
export function useBackendInfo({
authenticationClientRepository,
}: AuthenticationClientService) {
const backendUrl = getClientEnv('MARBLE_API_DOMAIN');
const backendUrl = getClientEnv('MARBLE_API_DOMAIN_CLIENT');

const getAccessToken = async () => {
try {
Expand Down
4 changes: 2 additions & 2 deletions packages/app-builder/src/services/auth/auth.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export function makeAuthenticationServerService(
{
authorization: `Bearer ${idToken}`,
},
{ baseUrl: getServerEnv('MARBLE_API_DOMAIN') },
{ baseUrl: getServerEnv('MARBLE_API_DOMAIN_CLIENT') },
);

const apiClient = getMarbleAPIClient(marbleToken.access_token);
Expand Down Expand Up @@ -174,7 +174,7 @@ export function makeAuthenticationServerService(
{
authorization: `Bearer ${idToken}`,
},
{ baseUrl: getServerEnv('MARBLE_API_DOMAIN') },
{ baseUrl: getServerEnv('MARBLE_API_DOMAIN_CLIENT') },
);

const apiClient = getMarbleAPIClient(marbleToken.access_token);
Expand Down
2 changes: 1 addition & 1 deletion packages/app-builder/src/services/init.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function makeClientServices(repositories: ClientRepositories) {
function initClientServices() {
const firebaseClient = initializeFirebaseClient({
firebaseOptions: getClientEnv('FIREBASE_OPTIONS'),
authEmulatorHost: getClientEnv('AUTH_EMULATOR_HOST'),
authEmulatorHost: getClientEnv('FIREBASE_AUTH_EMULATOR_HOST'),
});
const clientRepositories = makeClientRepositories(firebaseClient);
return makeClientServices(clientRepositories);
Expand Down
2 changes: 1 addition & 1 deletion packages/app-builder/src/services/init.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function makeServerServices(repositories: ServerRepositories) {
function initServerServices() {
checkServerEnv();
const getMarbleAPIClient = initializeGetMarbleAPIClient({
baseUrl: getServerEnv('MARBLE_API_DOMAIN'),
baseUrl: getServerEnv('MARBLE_API_DOMAIN_SERVER'),
});
const serverRepositories = makeServerRepositories({
getMarbleAPIClient,
Expand Down
12 changes: 9 additions & 3 deletions packages/app-builder/src/utils/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ const ServerPublicEnvVarNameSchema = z.object({
ENV: z.string(),
NODE_ENV: z.string(),
SESSION_MAX_AGE: z.string(),
MARBLE_API_DOMAIN: z.string(),
MARBLE_API_DOMAIN_CLIENT: z.string(),
MARBLE_API_DOMAIN_SERVER: z.string(),
MARBLE_APP_DOMAIN: z.string(),

FIREBASE_API_KEY: z.string(),
Expand Down Expand Up @@ -106,7 +107,11 @@ export function getServerEnv<K extends keyof ServerEnvVarName>(
export function getClientEnvVars() {
return {
ENV: getServerEnv('ENV'),
AUTH_EMULATOR_HOST: getServerEnv('FIREBASE_AUTH_EMULATOR_HOST'),
FIREBASE_AUTH_EMULATOR_HOST: getServerEnv(
'FIREBASE_AUTH_EMULATOR_HOST',
)?.startsWith('http://')
? getServerEnv('FIREBASE_AUTH_EMULATOR_HOST')
: 'http://' + getServerEnv('FIREBASE_AUTH_EMULATOR_HOST'),
FIREBASE_OPTIONS: {
apiKey: getServerEnv('FIREBASE_API_KEY'),
authDomain: getServerEnv('FIREBASE_AUTH_DOMAIN'),
Expand All @@ -115,7 +120,8 @@ export function getClientEnvVars() {
messagingSenderId: getServerEnv('FIREBASE_MESSAGING_SENDER_ID'),
appId: getServerEnv('FIREBASE_APP_ID'),
},
MARBLE_API_DOMAIN: getServerEnv('MARBLE_API_DOMAIN'),
MARBLE_API_DOMAIN_SERVER: getServerEnv('MARBLE_API_DOMAIN_SERVER'),
MARBLE_API_DOMAIN_CLIENT: getServerEnv('MARBLE_API_DOMAIN_CLIENT'),
MARBLE_APP_DOMAIN: getServerEnv('MARBLE_APP_DOMAIN'),
SENTRY_DSN: getServerEnv('SENTRY_DSN'),
SENTRY_ENVIRONMENT: getServerEnv('SENTRY_ENVIRONMENT'),
Expand Down

0 comments on commit 984717f

Please sign in to comment.