-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathDockerfile
More file actions
55 lines (39 loc) · 1.24 KB
/
Dockerfile
File metadata and controls
55 lines (39 loc) · 1.24 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
54
55
FROM oven/bun:1.3 AS base
WORKDIR /var/www/api
# -----------------------------
# deps stage - cache dependencies
# -----------------------------
FROM base AS deps
COPY package.json bun.lock* ./
COPY prisma ./prisma
RUN bun install --frozen-lockfile
RUN bunx prisma generate
# -----------------------------
# build stage - compile TypeScript to JavaScript
# -----------------------------
FROM deps AS build
COPY . .
RUN bun build src/server.ts --target=bun --production --outdir dist
# -----------------------------
# development stage
# -----------------------------
FROM deps AS development
COPY . .
EXPOSE 3000
CMD ["bun", "src/server.ts"]
# -----------------------------
# production stage
# -----------------------------
FROM oven/bun:1-slim AS production
WORKDIR /var/www/api
RUN groupadd -g 1001 nodejs && useradd -u 1001 -g nodejs -m bunjs
COPY --from=build --chown=bunjs:nodejs /var/www/api/dist ./dist
COPY --from=deps --chown=bunjs:nodejs /var/www/api/src/generated ./dist/generated
RUN chown -R bunjs:nodejs /var/www/api
USER bunjs
ENV NODE_ENV=production
ENV PORT=3000
EXPOSE 3000
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget -qO- http://localhost:3000/health || exit 1
CMD ["bun", "./dist/server.js"]