forked from Xyphyn/photon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
40 lines (36 loc) · 931 Bytes
/
Dockerfile
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
29
30
31
32
33
34
35
36
37
38
39
40
# Base stage for both Bun and Node.js
FROM alpine:3.14 AS base
WORKDIR /app
COPY package.json .
# Bun stage
FROM oven/bun:1 AS bun-builder
USER bun
WORKDIR /app
COPY --from=base /app/package.json .
COPY . .
RUN bun install
RUN ADAPTER=bun bun run build
# Node.js stage
FROM node:20-alpine AS node-builder
WORKDIR /app
COPY --from=base /app/package.json .
COPY . .
RUN npm install --no-lockfile
RUN ADAPTER=node npm run build
# Final Bun image
FROM oven/bun:1-alpine AS bun
WORKDIR /app
COPY --from=bun-builder /app/build /app/build
COPY --from=bun-builder /app/node_modules /app/node_modules
EXPOSE 3000
USER bun
CMD ["bun", "build/index.js"]
# Final Node.js image
FROM node:20-alpine AS node
USER node
WORKDIR /app
COPY --from=node-builder /app/build /app/build
COPY --from=node-builder /app/node_modules /app/node_modules
COPY --from=node-builder /app/package.json /app/package.json
EXPOSE 3000
CMD ["node", "build/index.js"]