forked from ixoworld/qiforge
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
67 lines (50 loc) · 2.09 KB
/
Dockerfile
File metadata and controls
67 lines (50 loc) · 2.09 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
56
57
58
59
60
61
62
63
64
65
66
67
ARG NODE_VERSION=22.11.0
# Debian-based image (glibc) instead of Alpine (musl)
FROM --platform=linux/amd64 node:${NODE_VERSION}-bookworm-slim AS debian-base
RUN apt-get update \
&& apt-get install -y --no-install-recommends python3 make g++ git ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Setup pnpm and turbo on the debian base
FROM --platform=linux/amd64 debian-base as base
ENV CI=true
RUN npm install pnpm@10.0.0 turbo --global
RUN pnpm config set store-dir ~/.pnpm-store
# Prune projects
FROM --platform=linux/amd64 base AS pruner
ARG PROJECT
WORKDIR /app
COPY . .
RUN turbo prune --scope=${PROJECT} --docker
# Build the project
FROM --platform=linux/amd64 base AS builder
ARG PROJECT
WORKDIR /app
# Copy lockfile and package.json's of isolated subworkspace
COPY --from=pruner /app/out/pnpm-lock.yaml ./pnpm-lock.yaml
COPY --from=pruner /app/out/pnpm-workspace.yaml ./pnpm-workspace.yaml
COPY --from=pruner /app/out/json/ .
# First install the dependencies (as they change less often)
RUN --mount=type=cache,id=pnpm,target=~/.pnpm-store pnpm install --frozen-lockfile
# Copy source code of isolated subworkspace
COPY --from=pruner /app/out/full/ .
RUN turbo build --filter=${PROJECT}
# Remove dev dependencies and hoist production dependencies to top level for proper module resolution
RUN --mount=type=cache,id=pnpm,target=~/.pnpm-store pnpm install --frozen-lockfile --prod --shamefully-hoist
# Remove source files only from workspace packages, not from node_modules
RUN rm -rf ./packages/*/src ./apps/*/src
# Final image
FROM --platform=linux/amd64 debian-base AS runner
ARG PROJECT
ENV PROJECT=${PROJECT}
# Clean up build dependencies in the final image
RUN apt-get purge -y make g++ git \
&& apt-get autoremove -y && apt-get clean
WORKDIR /app
COPY --from=builder /app .
# Create matrix storage directory
RUN mkdir -p apps/${PROJECT}/matrix-storage
ENV NODE_ENV=production
EXPOSE 3000
CMD sh -c "node --experimental-require-module apps/${PROJECT}/dist/main"
# docker build -t api:latest --build-arg PROJECT=api .
# docker build -t ghcr.io/ixofoundation/ixo-ai-oracles:v0.0.2 --build-arg PROJECT=guru .