-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.api
More file actions
49 lines (35 loc) · 1.3 KB
/
Dockerfile.api
File metadata and controls
49 lines (35 loc) · 1.3 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
FROM oven/bun:1-alpine AS base
WORKDIR /app
FROM base AS deps
RUN apk add --no-cache python3 make g++ linux-headers
COPY package.json bun.lock* ./
COPY packages/shared/package.json ./packages/shared/
COPY packages/typescript-config/package.json ./packages/typescript-config/
COPY apps/api/package.json ./apps/api/
RUN bun install --frozen-lockfile
FROM deps AS workspace
COPY packages/shared ./packages/shared
COPY packages/typescript-config ./packages/typescript-config
COPY apps/api ./apps/api
FROM workspace AS build
WORKDIR /app/apps/api
RUN bun run build
FROM oven/bun:1-alpine AS api
ENV NODE_ENV=production
WORKDIR /app
COPY --from=build /app/apps/api/dist ./apps/api/dist
COPY --from=workspace /app/apps/api/package.json ./apps/api/package.json
COPY --from=workspace /app/apps/api/src ./apps/api/src
COPY --from=workspace /app/packages/shared ./packages/shared
COPY --from=workspace /app/packages/typescript-config ./packages/typescript-config
COPY --from=deps /app/node_modules ./node_modules
COPY --from=deps /app/apps/api/node_modules ./apps/api/node_modules
RUN addgroup -g 1001 -S nodejs && \
adduser -S api -u 1001 -G nodejs
USER api
EXPOSE 3001
CMD ["bun", "run", "apps/api/dist/index.js"]
FROM workspace AS migrate
ENV NODE_ENV=production
WORKDIR /app/apps/api
CMD ["bun", "run", "db:migrate"]