From 36c9809b1e37856aec364f16e3baed324dc76d55 Mon Sep 17 00:00:00 2001 From: = <=> Date: Tue, 16 Sep 2025 11:28:19 -0400 Subject: [PATCH] update docker container to serve with a base ref of /pharos --- Dockerfile | 13 ++++++++++--- docker-compose.yml | 14 ++++++++++++++ package.json | 1 + src/app/tools/search-component/search.component.ts | 2 +- 4 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile index 57a82aa0f..9a8b8df67 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,14 @@ FROM node:20 as buildContainer +ARG BASE_HREF=/ WORKDIR /app COPY . /app RUN npm install -g npm@latest RUN npm install --legacy-peer-deps # max-old-space is needed to avoid any compilation issues because of missing memory -ENV NODE_OPTIONS --max-old-space-size=4096 -RUN npm run build:ssr +ENV NODE_OPTIONS --max-old-space-size=8192 +# Pass the BASE_HREF to the build command +RUN npm run build:ssr --base-href=${BASE_HREF} FROM node:20-alpine @@ -23,4 +25,9 @@ COPY --from=buildContainer /app/dist /app/dist EXPOSE 4000 ENV NODE_ENV=production -CMD ["pm2-runtime", "dist/server/main.js"] +# Make BASE_HREF available at runtime as well +ARG BASE_HREF=/ +ENV BASE_HREF=${BASE_HREF} + +# Use env var instead of hardcoding +CMD ["sh", "-c", "pm2-runtime dist/server/main.js --base-href=${BASE_HREF}"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..c9a2eb693 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,14 @@ +services: + app: + build: + context: . + dockerfile: Dockerfile + args: + BASE_HREF: /pharos/ + container_name: pharos-ui + ports: + - "8041:4000" + environment: + NODE_ENV: production + NODE_OPTIONS: --max-old-space-size=16384 + restart: unless-stopped diff --git a/package.json b/package.json index e96911922..b7dc8be2a 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "compodoc": "npx compodoc -p tsconfig.app.json -s -w --theme material", "build:ssr": "npm --no-git-tag-version version patch && npm run prerender", "build:ssr:dev": "ng build && ng run pharos:server:development", + "serve": "ng serve", "serve:ssr": "node dist/server/main.js", "perfmon": "node dist/server/main.js perf", "rerun:ssr": "npm run build:ssr && say pharos is ready && npm run serve:ssr", diff --git a/src/app/tools/search-component/search.component.ts b/src/app/tools/search-component/search.component.ts index 9d42f14aa..069eb9ea9 100644 --- a/src/app/tools/search-component/search.component.ts +++ b/src/app/tools/search-component/search.component.ts @@ -26,7 +26,7 @@ import {MatTooltip} from '@angular/material/tooltip'; @Component({ standalone: true, imports: [CommonModule, FormsModule, MatInputModule, ReactiveFormsModule, MatAutocomplete, MatButtonModule, - MatIconModule, MatAutocompleteTrigger, MatOption, SearchComponent, HighlightPipe, MatTooltip], + MatIconModule, MatAutocompleteTrigger, MatOption, HighlightPipe, MatTooltip], selector: 'pharos-search-component', templateUrl: './search.component.html', styleUrls: ['./search.component.scss'],