-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
53 lines (42 loc) · 1.42 KB
/
Copy pathDockerfile
File metadata and controls
53 lines (42 loc) · 1.42 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
43
44
45
46
47
48
49
50
51
52
53
# use the official Bun image
# see all versions at https://hub.docker.com/r/oven/bun/tags
FROM oven/bun:1.3.14-slim AS base
# set working directory
WORKDIR /app
# Install openssl
RUN apt-get update -y && apt-get install -y openssl
# install dependencies into temp directory
# this will cache them and speed up future builds
FROM base AS install
RUN mkdir -p /temp
COPY package.json bun.lock /temp/
RUN cd /temp && \
bun --bun install --ignore-scripts --shamefully-hoist --frozen-lockfile
# copy node_modules from temp directory
# then copy all (non-ignored) project files into the image
FROM base AS prerelease
COPY --from=install /temp/node_modules node_modules
COPY . .
# zenstack:generate, prisma:deploy, build and compress
ENV NODE_ENV=production
RUN bun build \
--compile \
# If your are using telemetry, you can enable the following minification options and disable the general --minify flag
# --minify-whitespace \
# --minify-syntax \
# If you uncommented the lines above, you should comment the --minify flag line below
--minify \
--outfile server \
src/index.ts
# create final image with distroless for smaller size and improved security
FROM base AS release
# set working directory
WORKDIR /app
# copy the built server from the prerelease stage
COPY --from=prerelease /app /app
# set environment variables
ENV NODE_ENV=production
# expose the listening port
EXPOSE 3000:3000
# run the server
ENTRYPOINT ["./server"]