Skip to content

Commit

Permalink
Merge pull request #52 from intuitem/fix/dynamic-env
Browse files Browse the repository at this point in the history
use dynamic env variable for PUBLIC_BACKEND_API_URL
  • Loading branch information
eric-intuitem authored Feb 15, 2024
2 parents 9dd0640 + b0050ba commit 8bb72b1
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 11 deletions.
4 changes: 1 addition & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ services:
container_name: frontend
environment:
- ORIGIN=http://localhost:3000
build:
context: ./frontend
args:
- PUBLIC_BACKEND_API_URL=http://backend:8000/api
build: ./frontend
depends_on:
- backend
ports:
Expand Down
3 changes: 1 addition & 2 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
FROM node:21-alpine AS builder
WORKDIR /app

ARG PUBLIC_BACKEND_API_URL
ENV PUBLIC_BACKEND_API_URL=$PUBLIC_BACKEND_API_URL
ENV PUBLIC_BACKEND_API_URL=foo

COPY package*.json .
COPY . .
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/lib/utils/constants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PUBLIC_BACKEND_API_URL } from '$env/static/public';
import { env } from '$env/dynamic/public';

export const BASE_API_URL = `${PUBLIC_BACKEND_API_URL}`;
export const BASE_API_URL = `${env.PUBLIC_BACKEND_API_URL}`;

export const RISK_COLOR_PALETTE: string[] = ['#BBF7D0', '#BEF264', '#FEF08A', '#FBBF24', '#F87171'];
export const COMPLIANCE_COLOR_MAP = {
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/routes/(app)/scoring-assistant/+page.server.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { PUBLIC_BACKEND_API_URL } from '$env/static/public';
import { BASE_API_URL } from '$lib/utils/constants';
import type { RiskMatrix, RiskMatrixJsonDefinition } from '$lib/utils/types';
import type { PageServerLoad } from './$types';
import { error } from '@sveltejs/kit';

export const load: PageServerLoad = async ({ fetch }) => {
const req = await fetch(`${PUBLIC_BACKEND_API_URL}/risk-matrices/`);
const req = await fetch(`${BASE_API_URL}/risk-matrices/`);
const req_data = await req.json();

const risk_matrices: RiskMatrixJsonDefinition[] = req_data.results.map(
Expand Down
3 changes: 1 addition & 2 deletions frontend/tests/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
FROM mcr.microsoft.com/playwright:v1.40.1
WORKDIR /app

ARG PUBLIC_BACKEND_API_URL
ENV PUBLIC_BACKEND_API_URL=$PUBLIC_BACKEND_API_URL
ENV PUBLIC_BACKEND_API_URL=foo

COPY ../package*.json .
RUN npm ci
Expand Down

0 comments on commit 8bb72b1

Please sign in to comment.