-
Notifications
You must be signed in to change notification settings - Fork 262
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2900: feat: deadpool docker implementation r=sprutton1 a=sprutton1 Super naive implementation of running cyclone in containers. Tons of refactoring work could happen here, but this is enough to get things working. Tests pass! Please crush me with feedback, this is still pretty new to me. Co-authored-by: Scott Prutton <[email protected]>
- Loading branch information
Showing
14 changed files
with
616 additions
and
53 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
########################################################################### | ||
# Builder Stage: cyclone | ||
########################################################################### | ||
# hadolint ignore=DL3007 | ||
FROM nixos/nix:latest AS builder-cyclone | ||
ARG BIN=cyclone | ||
|
||
COPY . /workdir | ||
WORKDIR /workdir | ||
|
||
RUN set -eux; \ | ||
nix \ | ||
--extra-experimental-features "nix-command flakes impure-derivations ca-derivations" \ | ||
--option filter-syscalls false \ | ||
build \ | ||
".#$BIN"; | ||
|
||
RUN mkdir -p /tmp/nix-store-closure /tmp/local-bin | ||
# hadolint ignore=SC2046 | ||
RUN cp -R $(nix-store --query --requisites result/) /tmp/nix-store-closure | ||
# hadolint ignore=SC2046 | ||
RUN ln -snf $(nix-store --query result/)/bin/* /tmp/local-bin/ | ||
|
||
########################################################################### | ||
# Builder Stage: lang-js | ||
########################################################################### | ||
# hadolint ignore=DL3007 | ||
FROM nixos/nix:latest AS builder-lang-js | ||
ARG BIN=lang-js | ||
|
||
COPY . /workdir | ||
WORKDIR /workdir | ||
|
||
RUN set -eux; \ | ||
nix \ | ||
--extra-experimental-features "nix-command flakes impure-derivations ca-derivations" \ | ||
--option filter-syscalls false \ | ||
build \ | ||
".#$BIN"; | ||
|
||
RUN mkdir -p /tmp/nix-store-closure /tmp/local-bin | ||
# hadolint ignore=SC2046 | ||
RUN cp -R $(nix-store --query --requisites result/) /tmp/nix-store-closure | ||
# hadolint ignore=SC2046 | ||
RUN ln -snf $(nix-store --query result/)/bin/* /tmp/local-bin/ | ||
|
||
########################################################################### | ||
# Final Stage | ||
########################################################################### | ||
FROM alpine:3 AS final | ||
ARG BIN=cyclone | ||
|
||
# hadolint ignore=DL3018 | ||
RUN set -eux; \ | ||
apk add --no-cache runuser; \ | ||
adduser -D app; \ | ||
for dir in /run /etc /usr/local/etc /home/app/.config; do \ | ||
mkdir -pv "$dir/$BIN"; \ | ||
done; | ||
|
||
WORKDIR /run/$BIN | ||
COPY --from=builder-cyclone /tmp/nix-store-closure /nix/store | ||
COPY --from=builder-cyclone /tmp/local-bin/* /usr/local/bin/ | ||
COPY --from=builder-lang-js /tmp/nix-store-closure /nix/store | ||
COPY --from=builder-lang-js /tmp/local-bin/* /usr/local/bin/ | ||
|
||
ENTRYPOINT [ \ | ||
"/sbin/runuser", "-u", "app", "--", "/usr/local/bin/cyclone" \ | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/sh | ||
# shellcheck disable=SC3043 | ||
set -eu | ||
|
||
main() { | ||
exec /usr/local/bin/.cyclone "$@" | ||
} | ||
|
||
main "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.