|
1 |
| -# syntax = docker/dockerfile:1.4 |
2 |
| -FROM nixos/nix:latest@sha256:3f6c77ee4d2c82e472e64e6cd7087241dc391421a0b42c22e6849c586d5398d9 AS builder |
3 |
| - |
4 |
| -WORKDIR /tmp/build |
5 |
| -RUN mkdir /tmp/nix-store-closure |
6 |
| - |
7 |
| -# ignore SC2046 because the output of nix-store -qR will never have spaces - this is safe here |
8 |
| -# hadolint ignore=SC2046 |
9 |
| -RUN --mount=type=cache,target=/nix,from=nixos/nix:latest@sha256:3f6c77ee4d2c82e472e64e6cd7087241dc391421a0b42c22e6849c586d5398d9,source=/nix \ |
10 |
| - --mount=type=cache,target=/root/.cache \ |
11 |
| - --mount=type=bind,target=/tmp/build \ |
12 |
| - <<EOF |
13 |
| - nix \ |
14 |
| - --extra-experimental-features "nix-command flakes" \ |
15 |
| - --option filter-syscalls false \ |
16 |
| - --show-trace \ |
17 |
| - --log-format raw \ |
18 |
| - build . --out-link /tmp/output/result |
19 |
| - cp -R $(nix-store -qR /tmp/output/result) /tmp/nix-store-closure |
20 |
| -EOF |
21 |
| - |
22 |
| -FROM scratch |
23 |
| - |
| 1 | +# The first stage, node dependencies stage - "deps" |
| 2 | +FROM node:22-slim@sha256:377674fd5bb6fc2a5a1ec4e0462c4bfd4cee1c51f705bbf4bda0ec2c9a73af72 AS deps |
24 | 3 | WORKDIR /app
|
| 4 | +COPY package*.json ./ |
| 5 | +RUN --mount=type=cache,target=/root/.npm npm ci --omit=dev |
25 | 6 |
|
26 |
| -COPY --from=builder /tmp/nix-store-closure /nix/store |
27 |
| -COPY --from=builder /tmp/output/ /app/ |
| 7 | +# The second stage - "build" |
| 8 | +FROM deps AS build |
| 9 | +RUN --mount=type=cache,target=/root/.npm npm ci |
28 | 10 |
|
29 |
| -ENTRYPOINT ["/app/result/bin/entrypoint"] |
| 11 | +# The third stage, selecting a base image recommended by Scout |
| 12 | +FROM node:22-slim@sha256:377674fd5bb6fc2a5a1ec4e0462c4bfd4cee1c51f705bbf4bda0ec2c9a73af72 |
| 13 | +WORKDIR /app |
| 14 | +COPY --from=deps /app/node_modules ./node_modules |
| 15 | +COPY ./main.js ./main.js |
| 16 | +ENTRYPOINT ["node", "/app/main.js"] |
0 commit comments