-
Notifications
You must be signed in to change notification settings - Fork 6
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
de7226e
commit 654064d
Showing
8 changed files
with
265 additions
and
13 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 babashka/babashka:latest@sha256:9e0381fc4c78ee6ff12fd8836352cf343afba289aceb77e36129d92f30a92cc7 | ||
|
||
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,44 @@ | ||
{ | ||
description = "imagemagick"; | ||
|
||
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 | ||
''; | ||
}; | ||
|
||
run-entrypoint = pkgs.writeShellScriptBin "entrypoint" '' | ||
export PATH=${pkgs.lib.makeBinPath [pkgs.ghostscript pkgs.imagemagick pkgs.man]} | ||
export SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt | ||
/usr/local/bin/bb ${scripts} "$@" | ||
''; | ||
|
||
default = pkgs.buildEnv { | ||
name = "imagemagick"; | ||
paths = [ run-entrypoint ]; | ||
}; | ||
}; | ||
}); | ||
} | ||
|
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,42 @@ | ||
(ns init | ||
(:require | ||
[babashka.process] | ||
[cheshire.core])) | ||
|
||
(defn output [args] | ||
(try | ||
(-> | ||
(apply babashka.process/process | ||
{:out :string} | ||
args) | ||
(deref) | ||
(babashka.process/check)) | ||
(catch Throwable _ nil))) | ||
|
||
(defn man [t] | ||
(output ["man" t])) | ||
(defn help [t] | ||
(output [t "--help"])) | ||
(defn h [t] | ||
(output [t "-h"])) | ||
|
||
(try | ||
(let [[json-string & extra-args] *command-line-args* | ||
{:keys [args]} (cheshire.core/parse-string json-string true)] | ||
(println | ||
(-> (if (= "man" (first extra-args)) | ||
(let [t (second args)] (or (man t) (help t) (h t))) | ||
(-> (babashka.process/process | ||
{:out :string} | ||
(format "%s" args)) | ||
(deref) | ||
(babashka.process/check))) | ||
(deref) | ||
(babashka.process/check) | ||
:out))) | ||
(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,35 @@ | ||
# Background | ||
|
||
The `curl` function has one parameter. | ||
|
||
* `args`: the args to send to the image | ||
|
||
## 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/imagemagick:latest '{"args": "man convert"}' | ||
``` | ||
|
||
## Build | ||
|
||
```sh | ||
docker build -t vonwig/imagemagick:latest . | ||
``` | ||
|
||
```sh | ||
# docker:command=build | ||
|
||
docker buildx build \ | ||
--builder hydrobuild \ | ||
--platform linux/amd64,linux/arm64 \ | ||
--tag vonwig/imagemagick:latest \ | ||
--file Dockerfile \ | ||
--push . | ||
docker pull vonwig/imagemagick: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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
tools: | ||
- name: imagemagick | ||
--- | ||
|
||
# prompt user | ||
|
||
Use Imagemagick to convert the family.pdf file into a bunch of jpg images. |
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