-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.app
47 lines (34 loc) · 1.16 KB
/
Dockerfile.app
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
# BASE Stage
FROM oven/bun:1 AS base
# setup all global artifacts. why Node? A: https://github.com/oven-sh/bun/issues/4848
RUN apt update \
&& apt install -y curl
ARG NODE_VERSION=20
RUN curl -L https://raw.githubusercontent.com/tj/n/master/bin/n -o n \
&& bash n $NODE_VERSION \
&& rm n \
&& npm install -g n
# INSTALL Stage
# install dependencies into temp folder. this will cache them and speed up future builds
FROM base AS install
WORKDIR /temp/prod/
COPY package.json bun.lockb ./
RUN bun install --frozen-lockfile --production
# PRERELEASE Stage
# copy node_modules from temp folder. then copy all (non-ignored) project files into the image
FROM install AS prerelease
WORKDIR /usr/src/app
COPY --from=install /temp/prod/node_modules node_modules
COPY . .
RUN npx prisma generate
# RELEASE Stage
FROM base AS release
COPY --from=prerelease /usr/src/app/node_modules ./node_modules
COPY --from=prerelease /usr/src/app/index.ts .
COPY --from=prerelease /usr/src/app/lib ./lib
COPY --from=prerelease /usr/src/app/routes ./routes
COPY --from=prerelease /usr/src/app/package.json .
# run the app
USER bun
EXPOSE 3003/tcp
CMD ["bun", "run", "index.ts"]