-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
33 lines (27 loc) · 994 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
FROM oven/bun:latest AS base
WORKDIR /usr/src/app
# install dependencies into a temporary directory.
# this will will cache them and speed up future builds.
FROM base AS install
RUN mkdir -p /tmp/dev
COPY package.json bun.lockb .env* /tmp/dev
RUN cd /tmp/dev && bun install --frozen-lockfile --ignore-scripts
# copy production dependencies into temporary directory.
# "production" =: exclude devDependencies
RUN mkdir -p /tmp/prod
COPY package.json bun.lockb .env* /tmp/prod
RUN cd /tmp/prod && bun install --frozen-lockfile --ignore-scripts --production
# copy node_modules from temporary directory.
# then copy all (non-ignored) project files into the image
FROM base AS prerelease
COPY --from=install /tmp/dev/node_modules node_modules
COPY . .
# test and build
ARG NODE_ENV=production
RUN bun compile
# copy production dependencies and source code into final image.
FROM base AS release
COPY --from=prerelease /usr/src/app .
# run the app
EXPOSE 4000/tcp
CMD ["bun", "start+tracing"]