diff --git a/Dockerfile b/Dockerfile index 80f71b60f..472017e5e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,5 @@ FROM node:20 as buildContainer +ARG BASE_HREF=/ WORKDIR /app COPY . /app RUN npm install -g npm@latest @@ -6,7 +7,8 @@ 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=8192 -RUN npm run build:ssr + +RUN npm run build:ssr --base-href=${BASE_HREF} FROM node:20.15.1-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'],