Skip to content

Commit 483c4fc

Browse files
committed
build: improve Dockerfile structure and build process
1 parent 27c59ff commit 483c4fc

1 file changed

Lines changed: 25 additions & 9 deletions

File tree

Dockerfile

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,33 @@
1-
FROM oven/bun
1+
FROM oven/bun AS build
22

33
WORKDIR /app
44

5-
COPY package.json .
6-
COPY bun.lockb .
5+
# Cache packages installation
6+
COPY package.json package.json
7+
COPY bun.lock bun.lock
78

8-
RUN bun install --production
9+
RUN bun install
910

10-
COPY src src
11-
COPY tsconfig.json .
12-
# COPY public public
11+
COPY ./src ./src
1312

14-
ENV NODE_ENV production
15-
CMD ["bun", "src/index.ts"]
13+
ENV NODE_ENV=production
14+
15+
RUN bun build \
16+
--compile \
17+
--minify-whitespace \
18+
--minify-syntax \
19+
--target bun \
20+
--outfile server \
21+
./src/index.ts
22+
23+
FROM gcr.io/distroless/base
24+
25+
WORKDIR /app
26+
27+
COPY --from=build /app/server server
28+
29+
ENV NODE_ENV=production
30+
31+
CMD ["./server"]
1632

1733
EXPOSE 3500

0 commit comments

Comments
 (0)