Skip to content

Commit 90371f2

Browse files
committed
fix(website): complete ssr and docker build
1 parent ee3972c commit 90371f2

13 files changed

+99
-88
lines changed

.dockerignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
node_modules
22
dist
3-
.angular
3+
website/dist
4+
website/node_modules
5+
website/.angular
46
.dockerignore
57
Dockerfile

.yarnrc.yml

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ nodeLinker: node-modules
22

33
yarnPath: .yarn/releases/yarn-4.0.2.cjs
44

5+
supportedArchitectures:
6+
os: [linux, darwin]
7+
cpu: [x64, arm64]
8+
59
packageExtensions:
610
711
dependencies:

website/.dockerignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules
2+
dist
3+
.angular
4+
.dockerignore
5+
Dockerfile

website/Dockerfile

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ ADD .yarnrc.yml yarn.lock /app/
99
ADD .yarn /app/.yarn
1010
ADD website/package.json /app/website/package.json
1111
RUN yarn workspaces focus website
12-
ADD website/ /app
13-
RUN npm run build
12+
ADD website /app/website
13+
RUN cd website && npm run build
1414

1515
FROM node:20.8.0-alpine3.18
1616
ENV TZ="Europe/Berlin"
1717

1818
EXPOSE 8080
19-
ENV PORT 8080
19+
ENV PORT=8080
2020

2121
RUN mkdir /app/
2222
WORKDIR /app
@@ -25,7 +25,7 @@ ADD package.json /app/package.json
2525
ADD .yarnrc.yml yarn.lock /app/
2626
ADD .yarn /app/.yarn
2727
ADD website/package.json /app/website/package.json
28-
RUN yarn workspaces focus website --production
28+
RUN yarn workspaces focus website --production --all
2929

3030
COPY --from=0 /app/dist /app/dist
3131
COPY --from=0 /app/src /app/src

website/angular.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"server": "src/main.server.ts",
5353
"outputMode": "server",
5454
"ssr": {
55-
"entry": "src/server/server.ts"
55+
"entry": "src/server/app.ts"
5656
},
5757
"browser": "src/main.ts",
5858
"preserveSymlinks": true,

website/docker_start.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ node dist/src/server/app.js search:index
44
node dist/src/server/app.js import:questions
55
node dist/src/server/app.js import:examples
66

7-
app_environment=prod app_framework_port=$PORT node dist/src/server/app.js server:start
7+
app_environment=prod app_framework_port=$PORT node dist/app/server/server.mjs server:start

website/package.json

+21-21
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"ng:build:dev": "NODE_OPTIONS=--preserve-symlinks ng build --watch --configuration development",
77
"ng:test": "NODE_OPTIONS=--preserve-symlinks ng test",
88
"app": "NODE_OPTIONS=--preserve-symlinks TS_NODE_PROJECT=tsconfig.server.json node -r ts-node/register -r tsconfig-paths/register src/server/app.ts",
9-
"build": "NODE_OPTIONS=--preserve-symlinks ng build --configuration production",
9+
"build": "BUILD=angular NODE_OPTIONS=--preserve-symlinks ng build --configuration production",
1010
"test": "jest"
1111
},
1212
"installConfig": {
@@ -15,29 +15,29 @@
1515
"private": true,
1616
"dependencies": {
1717
"@angular/ssr": "^19.1.6",
18-
"@deepkit/angular-ssr": "^1.0.1-alpha.143",
19-
"@deepkit/app": "^1.0.1-alpha.143",
20-
"@deepkit/broker": "^1.0.1-alpha.143",
21-
"@deepkit/bson": "^1.0.1-alpha.143",
22-
"@deepkit/core": "^1.0.1-alpha.143",
23-
"@deepkit/core-rxjs": "^1.0.1-alpha.143",
24-
"@deepkit/desktop-ui": "^1.0.1-alpha.143",
25-
"@deepkit/event": "^1.0.1-alpha.143",
26-
"@deepkit/filesystem": "^1.0.1-alpha.143",
18+
"@deepkit/angular-ssr": "^1.0.1",
19+
"@deepkit/app": "^1.0.1",
20+
"@deepkit/broker": "^1.0.1",
21+
"@deepkit/bson": "^1.0.1",
22+
"@deepkit/core": "^1.0.1",
23+
"@deepkit/core-rxjs": "^1.0.1",
24+
"@deepkit/desktop-ui": "^1.0.1",
25+
"@deepkit/event": "^1.0.1",
26+
"@deepkit/filesystem": "^1.0.1",
2727
"@deepkit/framework": "^1.0.1-alpha.144",
28-
"@deepkit/http": "^1.0.1-alpha.143",
29-
"@deepkit/injector": "^1.0.1-alpha.143",
30-
"@deepkit/logger": "^1.0.1-alpha.143",
28+
"@deepkit/http": "^1.0.1",
29+
"@deepkit/injector": "^1.0.1",
30+
"@deepkit/logger": "^1.0.1",
3131
"@deepkit/mongo": "^1.0.1-alpha.144",
32-
"@deepkit/orm": "^1.0.1-alpha.143",
32+
"@deepkit/orm": "^1.0.1",
3333
"@deepkit/postgres": "^1.0.1-alpha.144",
34-
"@deepkit/rpc": "^1.0.1-alpha.143",
35-
"@deepkit/rpc-tcp": "^1.0.1-alpha.143",
34+
"@deepkit/rpc": "^1.0.1",
35+
"@deepkit/rpc-tcp": "^1.0.1",
3636
"@deepkit/sql": "^1.0.1-alpha.144",
37-
"@deepkit/stopwatch": "^1.0.1-alpha.143",
38-
"@deepkit/template": "^1.0.1-alpha.143",
39-
"@deepkit/type": "^1.0.1-alpha.143",
40-
"@deepkit/workflow": "^1.0.1-alpha.143",
37+
"@deepkit/stopwatch": "^1.0.1",
38+
"@deepkit/template": "^1.0.1",
39+
"@deepkit/type": "^1.0.1",
40+
"@deepkit/workflow": "^1.0.1",
4141
"angular-plotly.js": "^5.2.2",
4242
"discord.js": "^14.13.0",
4343
"gray-matter": "^4.0.3",
@@ -72,7 +72,7 @@
7272
"@angular/platform-browser-dynamic": "^19.1.5",
7373
"@angular/platform-server": "^19.1.5",
7474
"@angular/router": "^19.1.5",
75-
"@deepkit/type-compiler": "^1.0.1-alpha.102",
75+
"@deepkit/type-compiler": "^1.0.1",
7676
"@types/jest": "^29.5.5",
7777
"@types/prismjs": "^1.26.0",
7878
"concurrently": "^8.2.1",

website/src/app/components/title.ts

+2-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, Injectable, Input, NgZone, OnChanges, OnDestroy, OnInit } from '@angular/core';
1+
import { Component, Injectable, Input, OnChanges, OnDestroy, OnInit } from '@angular/core';
22
import { Meta, Title } from '@angular/platform-browser';
33
import { arrayRemoveItem } from '@deepkit/core';
44

@@ -7,13 +7,8 @@ type Type = { type: string, value?: any };
77
@Injectable()
88
export class AppMetaStack {
99
stack: Type[] = [];
10-
stable = false;
1110

12-
constructor(private title: Title, private meta: Meta, private ngZone: NgZone) {
13-
ngZone.onStable.subscribe(() => {
14-
this.stable = true;
15-
this.update();
16-
});
11+
constructor(private title: Title, private meta: Meta) {
1712
}
1813

1914
register(appTitle: Type) {
@@ -27,8 +22,6 @@ export class AppMetaStack {
2722
}
2823

2924
update() {
30-
if (!this.stable) return;
31-
3225
const titles = this.stack.filter(v => v.type === 'title');
3326
const descriptions = this.stack.filter(v => v.type === 'description');
3427

website/src/app/pages/libraries/libraries.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { AppTitle } from '@app/app/components/title';
2424
text-align: left;
2525
display: block;
2626
27-
color: white;
27+
color: white !important;
2828
2929
&:hover {
3030
text-decoration: none;

website/src/server/app.ts

+17-3
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ import { MarkdownParser } from '@app/common/markdown';
2323
import { migrate } from '@app/server/commands/migrate';
2424
import { importExamples, importQuestions } from '@app/server/commands/import';
2525
import { BenchmarkController, BenchmarkHttpController } from '@app/server/controller/benchmark.controller';
26-
import { AngularModule } from '@deepkit/angular-ssr';
27-
26+
import { AngularModule, RequestHandler } from '@deepkit/angular-ssr';
27+
import { isMainModule } from '@angular/ssr/node';
2828

2929
(global as any).window = undefined;
3030
(global as any).document = undefined;
@@ -72,7 +72,9 @@ export const app = new App({
7272
startOnBootstrap: false,
7373
},
7474
}),
75-
new AngularModule()
75+
new AngularModule({
76+
moduleUrl: import.meta.url
77+
})
7678
],
7779
});
7880

@@ -96,3 +98,15 @@ app.listen(onServerMainBootstrap, registerBot);
9698
app.listen(onServerMainBootstrap, (event, parser: MarkdownParser) => parser.load());
9799

98100
app.loadConfigFromEnv({ namingStrategy: 'same', prefix: 'app_', envFilePath: ['local.env'] });
101+
102+
const isBuild = process.env.BUILD === 'angular'; //detecting prerender
103+
const isMain = isMainModule(import.meta.url);
104+
105+
if (isMain) {
106+
void app.run();
107+
}
108+
109+
export const reqHandler =
110+
isBuild || isMain
111+
? () => undefined
112+
: app.get(RequestHandler).create();

website/src/server/server.ts

-7
This file was deleted.

website/tsconfig.app.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"files": [
99
"src/main.ts",
1010
"src/main.server.ts",
11-
"src/server/server.ts"
11+
"src/server/app.ts"
1212
],
1313
"include": [
1414
"src/**/*.d.ts"

0 commit comments

Comments
 (0)