Skip to content

Commit c4519f0

Browse files
Add container image
This change enables running emanote in a container.
1 parent 13125a0 commit c4519f0

File tree

3 files changed

+63
-0
lines changed

3 files changed

+63
-0
lines changed

.github/workflows/ci.yaml

+13
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,16 @@ jobs:
6363
- name: Deploy to GitHub Pages
6464
id: deployment
6565
uses: actions/deploy-pages@v4
66+
container:
67+
if: github.ref == 'refs/heads/master'
68+
runs-on: x86_64-linux
69+
steps:
70+
- uses: actions/checkout@v3
71+
- uses: DeterminateSystems/nix-installer-action@main
72+
- uses: DeterminateSystems/magic-nix-cache-action@main
73+
74+
- name: Push Image
75+
run: nix run ".#publish-container-release"
76+
env:
77+
GH_USERNAME: ${{ github.actor }}
78+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

docs/start/install/container.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Using Container
2+
3+
Emanote provides a standalone container.
4+
5+
Start the live server by mounting your notebook (here `./docs`) to `/site`:
6+
```sh
7+
podman run -it -p 8080:8080 -v ./docs:/site:z ghcr.io/srid/emanote run -p 8080
8+
```
9+
10+
Build the static pages:
11+
```sh
12+
podman run -it -v ./docs:/site:z -v ./output:/output:z ghcr.io/srid/emanote gen /output
13+
```

nix/modules/flake-parts/container.nix

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{ root, ... }: {
2+
perSystem = { pkgs, config, ... }:
3+
let
4+
emanote = config.packages.emanote;
5+
container-name = "ghcr.io/srid/emanote";
6+
container = pkgs.dockerTools.streamLayeredImage {
7+
name = container-name;
8+
tag = "latest";
9+
created = "now";
10+
config.Entrypoint = [ "${emanote}/bin/emanote" ];
11+
config.WorkingDir = "/site";
12+
config.Labels = {
13+
"org.opencontainers.image.source" = "https://github.com/srid/emanote";
14+
};
15+
};
16+
in {
17+
# Load the container locally with: `nix build .#container && ./result | podman load`
18+
packages.container = container;
19+
20+
# Run this script in the CI to publish a new image
21+
apps.publish-container-release =
22+
pkgs.writeShellScriptBin "emanote-release" ''
23+
set -e
24+
export PATH=$PATH:${pkgs.gzip}/bin:${pkgs.skopeo}/bin
25+
IMAGE="docker://${container-name}"
26+
27+
echo "Logging to registry..."
28+
echo $GH_TOKEN | skopeo login --username $GH_USERNAME --password-stdin ghcr.io
29+
30+
echo "Building and publishing the image..."
31+
${container} | gzip --fast | skopeo copy docker-archive:/dev/stdin $IMAGE:${emanote.version}
32+
33+
echo "Tagging latest"
34+
skopeo copy $IMAGE:${emanote.version} $IMAGE:latest
35+
'';
36+
};
37+
}

0 commit comments

Comments
 (0)