Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
54 lines (48 loc) · 2.38 KB
/
Copy pathDockerfile
File metadata and controls
54 lines (48 loc) · 2.38 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
# syntax=docker/dockerfile:1
# The image ghcr.io/teslacloud/fpkg: the fpkg binary, statically linked against
# musl, on Alpine. .github/workflows/image.yml builds and publishes it.
#
# The build needs the nl repository as the build context "nl" and the nl fork
# of LuaJIT prepared in vendor/luajit-src:
#
# scripts/prepare-nl.sh
# docker buildx build --build-context nl=../nl -t fpkg .
FROM rust:1.100-alpine3.24 AS build
RUN apk add --no-cache gcc make musl-dev
# The layout the manifests expect: fpkg and nl side by side. Of nl, the build
# reads the workspace manifest, the crates and the files they embed (the VM
# comes from vendor/).
COPY --from=nl Cargo.toml /src/nl/Cargo.toml
COPY --from=nl crates /src/nl/crates
COPY --from=nl decl /src/nl/decl
COPY --from=nl runtime /src/nl/runtime
WORKDIR /src/fpkg
COPY . .
# On arm64, LuaJIT flushes the instruction cache with __clear_cache, which is in
# libgcc; a static musl link does not pull that in by itself.
ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_RUSTFLAGS="-C link-arg=-lgcc"
RUN --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/src/fpkg/target \
CARGO_PROFILE_RELEASE_STRIP=symbols cargo build --release --locked -p fpkg && \
cp target/release/fpkg /usr/local/bin/fpkg
# The binary evaluates specs and runs tasks (SQLite, files) on this architecture and libc.
RUN fpkg --version && fpkg --project tests/fixtures/flux-ce check --quiet && \
[ "$(fpkg --project tests/fixtures/tasks db:count)" = "$(printf 'environment 1\nvisits 1')" ] && \
[ "$(fpkg --project tests/fixtures/tasks files)" = "$(printf 'read data file, return 1\nfound out.lua')" ]
# The binary alone, for the release archives:
# docker buildx build --build-context nl=../nl --target binary --output <dir> .
FROM scratch AS binary
COPY --from=build /usr/local/bin/fpkg /fpkg
FROM alpine:3.24
LABEL org.opencontainers.image.title="fpkg" \
org.opencontainers.image.description="fpkg, the package manager for Flux packages" \
org.opencontainers.image.source="https://github.com/TeslaCloud/fpkg" \
org.opencontainers.image.licenses="MIT"
COPY --from=build /usr/local/bin/fpkg /usr/local/bin/fpkg
# The package cache, writable by whichever user runs the image.
RUN mkdir -m 1777 /var/cache/fpkg
ENV FPKG_CACHE_DIR=/var/cache/fpkg
# Mount the project (or the server folder) here.
WORKDIR /work
ENTRYPOINT ["fpkg"]
CMD ["--help"]