-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c4eb943
commit 66184b8
Showing
23 changed files
with
792 additions
and
5 deletions.
There are no files selected for viewing
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,33 @@ | ||
|
||
# syntax = docker/dockerfile:1.4 | ||
FROM nixos/nix:2.21.1@sha256:3f6c77ee4d2c82e472e64e6cd7087241dc391421a0b42c22e6849c586d5398d9 AS builder | ||
|
||
WORKDIR /tmp/build | ||
RUN mkdir /tmp/nix-store-closure | ||
|
||
# ignore SC2046 because the output of nix-store -qR will never have spaces - this is safe here | ||
# hadolint ignore=SC2046 | ||
RUN --mount=type=cache,target=/nix,from=nixos/nix:2.21.1,source=/nix \ | ||
--mount=type=cache,target=/root/.cache \ | ||
--mount=type=bind,target=/tmp/build \ | ||
<<EOF | ||
nix \ | ||
--extra-experimental-features "nix-command flakes" \ | ||
--option filter-syscalls false \ | ||
--extra-trusted-substituters "https://cache.iog.io" \ | ||
--extra-trusted-public-keys "hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=" \ | ||
--show-trace \ | ||
--log-format raw \ | ||
build . --out-link /tmp/output/result | ||
cp -R $(nix-store -qR /tmp/output/result) /tmp/nix-store-closure | ||
EOF | ||
|
||
FROM scratch | ||
|
||
WORKDIR /app | ||
|
||
COPY --from=builder /tmp/nix-store-closure /nix/store | ||
COPY --from=builder /tmp/output/ /app/ | ||
|
||
ENTRYPOINT ["/app/result/bin/entrypoint"] | ||
CMD ["--help"] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
description = "gh cli function"; | ||
|
||
inputs = { | ||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11"; | ||
flake-utils.url = "github:numtide/flake-utils"; | ||
}; | ||
|
||
outputs = { self, nixpkgs, flake-utils, ...}@inputs: | ||
|
||
flake-utils.lib.eachDefaultSystem | ||
(system: | ||
let | ||
pkgs = import nixpkgs { | ||
inherit system; | ||
}; | ||
|
||
in rec | ||
{ | ||
packages = rec { | ||
|
||
# this derivation just contains the init.clj script | ||
scripts = pkgs.stdenv.mkDerivation { | ||
name = "scripts"; | ||
src = ./.; | ||
installPhase = '' | ||
cp init.clj $out | ||
''; | ||
}; | ||
|
||
# the script must have gh in the PATH | ||
default = pkgs.writeShellScriptBin "entrypoint" '' | ||
export PATH=${pkgs.lib.makeBinPath [pkgs.findutils]} | ||
export SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt | ||
${pkgs.babashka}/bin/bb ${scripts} "$@" | ||
''; | ||
}; | ||
}); | ||
} |
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,24 @@ | ||
(ns init | ||
(:require [cheshire.core] | ||
[babashka.process])) | ||
|
||
(defn run [args] | ||
(-> (apply babashka.process/process | ||
{:out :string} | ||
args) | ||
(deref) | ||
(babashka.process/check) | ||
:out)) | ||
|
||
(try | ||
(let [[json-string & args] *command-line-args* | ||
{:keys [glob]} (cheshire.core/parse-string json-string true)] | ||
(println | ||
(run | ||
(concat | ||
args | ||
[glob])))) | ||
(catch Throwable t | ||
(binding [*out* *err*] | ||
(println (str "Error: " (.getMessage t))) | ||
(System/exit 1)))) |
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,36 @@ | ||
# Background | ||
|
||
The `write_file` function has wo parameters. | ||
|
||
* `path`: is a relative path from some project_root | ||
* `content`: is the content that should be written into the file | ||
|
||
## Usage | ||
|
||
This function should be given a rw bind mount for the root of a project. | ||
|
||
```sh | ||
docker run --rm \ | ||
--mount type=bind,source=$PWD,target=/project \ | ||
--entrypoint /app/result/bin/entrypoint \ | ||
--workdir /project \ | ||
vonwig/findutils:latest '{"glob":"*.md"}' find "." "-name" | ||
``` | ||
|
||
## Build | ||
|
||
```sh | ||
docker build -t vonwig/findutils:latest . | ||
``` | ||
|
||
```sh | ||
# docker:command=build | ||
|
||
docker buildx build \ | ||
--builder hydrobuild \ | ||
--platform linux/amd64,linux/arm64 \ | ||
--tag vonwig/findutils:latest \ | ||
--file Dockerfile \ | ||
--push . | ||
docker pull vonwig/findutils:latest | ||
``` |
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,33 @@ | ||
|
||
# syntax = docker/dockerfile:1.4 | ||
FROM nixos/nix:2.21.1@sha256:3f6c77ee4d2c82e472e64e6cd7087241dc391421a0b42c22e6849c586d5398d9 AS builder | ||
|
||
WORKDIR /tmp/build | ||
RUN mkdir /tmp/nix-store-closure | ||
|
||
# ignore SC2046 because the output of nix-store -qR will never have spaces - this is safe here | ||
# hadolint ignore=SC2046 | ||
RUN --mount=type=cache,target=/nix,from=nixos/nix:2.21.1,source=/nix \ | ||
--mount=type=cache,target=/root/.cache \ | ||
--mount=type=bind,target=/tmp/build \ | ||
<<EOF | ||
nix \ | ||
--extra-experimental-features "nix-command flakes" \ | ||
--option filter-syscalls false \ | ||
--extra-trusted-substituters "https://cache.iog.io" \ | ||
--extra-trusted-public-keys "hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=" \ | ||
--show-trace \ | ||
--log-format raw \ | ||
build . --out-link /tmp/output/result | ||
cp -R $(nix-store -qR /tmp/output/result) /tmp/nix-store-closure | ||
EOF | ||
|
||
FROM scratch | ||
|
||
WORKDIR /app | ||
|
||
COPY --from=builder /tmp/nix-store-closure /nix/store | ||
COPY --from=builder /tmp/output/ /app/ | ||
|
||
ENTRYPOINT ["/app/result/bin/entrypoint"] | ||
CMD ["--help"] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
description = "fasttext"; | ||
|
||
inputs = { | ||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11"; | ||
flake-utils.url = "github:numtide/flake-utils"; | ||
}; | ||
|
||
outputs = { self, nixpkgs, flake-utils, ...}@inputs: | ||
|
||
flake-utils.lib.eachDefaultSystem | ||
(system: | ||
let | ||
pkgs = import nixpkgs { | ||
inherit system; | ||
}; | ||
|
||
in rec | ||
{ | ||
packages = rec { | ||
|
||
# this derivation just contains the init.clj script | ||
scripts = pkgs.stdenv.mkDerivation { | ||
name = "scripts"; | ||
src = ./.; | ||
installPhase = '' | ||
cp init.clj $out | ||
''; | ||
}; | ||
|
||
# the script must have gh in the PATH | ||
default = pkgs.writeShellScriptBin "entrypoint" '' | ||
export PATH=${pkgs.lib.makeBinPath [pkgs.fasttext]} | ||
export SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt | ||
${pkgs.babashka}/bin/bb ${scripts} "$@" | ||
''; | ||
}; | ||
}); | ||
} |
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,19 @@ | ||
(ns init | ||
(:require | ||
[babashka.process] | ||
[cheshire.core])) | ||
|
||
(try | ||
(let [[json-string & args] *command-line-args* | ||
{:keys []} (cheshire.core/parse-string json-string true)] | ||
(println | ||
(-> (apply babashka.process/process | ||
{:out :string} | ||
"fasttext" args) | ||
(deref) | ||
(babashka.process/check) | ||
:out))) | ||
(catch Throwable t | ||
(binding [*out* *err*] | ||
(println (str "Error: " (.getMessage t))) | ||
(System/exit 1)))) |
Oops, something went wrong.