|
| 1 | +# syntax=docker/dockerfile:1 |
| 2 | + |
| 3 | +# We use Nix to build DiffDetective. |
| 4 | +FROM nixos/nix:2.22.0 AS builder |
| 5 | + |
| 6 | +# Create and navigate to a working directory |
| 7 | +WORKDIR /home/user |
| 8 | + |
| 9 | +# Copy all of the source code into the working directory. Impurities like |
| 10 | +# additional files and previous build results will be filtered by Nix. Note that |
| 11 | +# All files which are considered *tracked* by Git will be used for the build, |
| 12 | +# even if they are modified. |
| 13 | +COPY . . |
| 14 | + |
| 15 | +# Build the DiffDetective demo. This also all dependencies (e.g., DiffDetective |
| 16 | +# itselves) using the default nix binary cache. |
| 17 | +RUN nix-build |
| 18 | + |
| 19 | +# Copy DiffDetective with all runtime dependencies (ignoring build-time |
| 20 | +# dependencies) to a separate folder. Such a subset of the Nix store is called a |
| 21 | +# closure and enables us to create a minimal Docker container. |
| 22 | +RUN mkdir closure |
| 23 | +RUN nix-store -qR result | xargs cp -Rt closure |
| 24 | + |
| 25 | +# Start building the final container. |
| 26 | +FROM scratch |
| 27 | + |
| 28 | +# Create another working directory for runtime files (e.g., cloned repositories). |
| 29 | +WORKDIR /home/user |
| 30 | + |
| 31 | +# Copy DiffDetective (it's runtime closure) to the final container. |
| 32 | +COPY --from=builder /home/user/closure /nix/store |
| 33 | + |
| 34 | +# Copy the Symlink to the DiffDetective derivation, mostly for convenience. |
| 35 | +COPY --from=builder /home/user/result /DiffDetective |
| 36 | + |
| 37 | +# Copy the necessary data. Beware that this directory might have impure files. |
| 38 | +COPY data /home/user/data |
| 39 | + |
| 40 | +ENV DISPLAY=:0 HOME=/home/user |
| 41 | +CMD ["/DiffDetective/bin/DiffDetective-Demo"] |
0 commit comments