Skip to content

Commit 4f76bad

Browse files
committed
[refactor] Update Dockerfile and server configuration; add nginx setup and implement Express server
1 parent 4999296 commit 4f76bad

File tree

4 files changed

+36
-1
lines changed

4 files changed

+36
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ dist-ssr
2121
*.sln
2222
*.sw?
2323
.env
24+
*.ps1

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ WORKDIR /app
88
COPY . .
99

1010
RUN pnpm install --frozen-lockfile
11+
RUN pnpm install -D express
1112

1213
EXPOSE 80
1314

14-
CMD [ "cd /app && pnpm run build && pnpm start --port 80" ]
15+
CMD [ "cd /app && pnpm run build && node server.js" ]

nginx.conf

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
server {
2+
listen 80 default_server;
3+
4+
root /app;
5+
6+
# Logging
7+
access_log /dev/stdout;
8+
error_log /dev/stderr;
9+
10+
location / {
11+
try_files $uri $uri/ /index.html;
12+
}
13+
14+
# Files
15+
location ~ \.(?!html) {
16+
try_files $uri =404;
17+
}
18+
}

server.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import express, { static } from "express";
2+
import { join } from "path";
3+
4+
const app = express();
5+
const port = 80;
6+
7+
app.use(static(join(__dirname, "dist")));
8+
9+
app.get("*", (req, res) => {
10+
res.sendFile(join(__dirname, "dist", "index.html"));
11+
});
12+
13+
app.listen(port, () => {
14+
console.log(`Server is running on port ${port}`);
15+
});

0 commit comments

Comments
 (0)