-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
42 lines (29 loc) · 1 KB
/
Dockerfile
File metadata and controls
42 lines (29 loc) · 1 KB
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
41
42
FROM oven/bun:1-alpine as base
WORKDIR /usr/src/app
# Install dependencies into temp directory
FROM base as deps
RUN mkdir -p /temp/dev
COPY package.json bun.lockb /temp/dev/
RUN cd /temp/dev && bun install --frozen-lockfile --ignore-scripts
RUN mkdir -p /temp/prod
COPY package.json bun.lockb /temp/prod/
RUN cd /temp/prod && bun install --frozen-lockfile --production --ignore-scripts
# Build the app
FROM base as build
COPY --from=deps /temp/dev/node_modules node_modules
COPY . .
ENV NODE_ENV=production
RUN bun run prepare && bun run build
################################################################
# Finally, build the production image with minimal footprint
FROM oven/bun:1-distroless AS release
WORKDIR /app
# You only need these for production
COPY --from=deps /temp/prod/node_modules node_modules
COPY --from=build /usr/src/app/build/ build/
COPY --from=build /usr/src/app/package.json .
USER nonroot
EXPOSE 8080/tcp
ENV NODE_ENV=production
ENV PORT=8080
ENTRYPOINT ["bun", "build/server/index.js"]