-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
28 lines (27 loc) · 957 Bytes
/
Copy pathDockerfile
File metadata and controls
28 lines (27 loc) · 957 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Generated by Drydock — static site (built with bun, served by bun) from ./web.
FROM oven/bun:1.3-alpine AS build
WORKDIR /app/web
COPY web/package.json web/bun.lock ./
RUN bun install --frozen-lockfile
WORKDIR /app
COPY . .
WORKDIR /app/web
RUN bun run build
FROM oven/bun:1.3-alpine
WORKDIR /app
ENV NODE_ENV=production
COPY --from=build /app/web/dist ./public
RUN printf '%s\n' \
'const root = new URL("./public/", import.meta.url).pathname;' \
'const port = Number(process.env.PORT ?? 3000);' \
'Bun.serve({ port, async fetch(req) {' \
' const url = new URL(req.url);' \
' let p = decodeURIComponent(url.pathname);' \
' if (p.endsWith("/")) p += "index.html";' \
' let file = Bun.file(root + p.replace(/^\//, ""));' \
' if (!(await file.exists())) file = Bun.file(root + "index.html");' \
' return new Response(file);' \
'} });' \
'console.log("static server on " + port);' > serve.ts
EXPOSE 3000
CMD ["bun", "serve.ts"]