Skip to content

Commit 0e30e07

Browse files
committed
add dockerfile
1 parent b195963 commit 0e30e07

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

.dockerignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
node_modules
2+
Dockerfile*
3+
docker-compose*
4+
.dockerignore
5+
.git
6+
.gitignore
7+
README.md
8+
LICENSE
9+
.vscode
10+
Makefile
11+
helm-charts
12+
.env
13+
.editorconfig
14+
.idea
15+
coverage*

Dockerfile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# https://hub.docker.com/r/oven/bun/tags
2+
FROM oven/bun:1 AS base
3+
WORKDIR /usr/src/app
4+
5+
# install dependencies into temp directory
6+
# this will cache them and speed up future builds
7+
FROM base AS install
8+
RUN mkdir -p /temp/dev
9+
COPY package.json bun.lock /temp/dev/
10+
RUN cd /temp/dev && bun install --frozen-lockfile
11+
12+
# install with --production (exclude devDependencies)
13+
RUN mkdir -p /temp/prod
14+
COPY package.json bun.lock /temp/prod/
15+
RUN cd /temp/prod && bun install --frozen-lockfile --production
16+
17+
# copy node_modules from temp directory
18+
# then copy all (non-ignored) project files into the image
19+
FROM base AS prerelease
20+
COPY --from=install /temp/dev/node_modules node_modules
21+
COPY . .
22+
23+
# copy production dependencies and source code into final image
24+
FROM base AS release
25+
COPY --from=install /temp/prod/node_modules node_modules
26+
COPY --from=prerelease /usr/src/app/src ./src
27+
COPY --from=prerelease /usr/src/app/tsconfig.json .
28+
COPY --from=prerelease /usr/src/app/package.json .
29+
30+
USER bun
31+
EXPOSE 8181/tcp
32+
ENTRYPOINT [ "bun", "start" ]

0 commit comments

Comments
 (0)