Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add container image #561

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,13 @@ jobs:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
container:
# if: github.ref == 'refs/heads/master'
runs-on: x86_64-linux
steps:
- uses: actions/checkout@v4
- name: Push Image
run: nix run ".#publish-container-release"
env:
GH_USERNAME: ${{ github.actor }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
17 changes: 17 additions & 0 deletions docs/start/install/container.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
slug: container
---

# Using Container

Emanote provides a standalone container.

Start the live server by mounting your notebook (here `./docs`) to `/site`:
```sh
podman run -it --rm -p 8080:8080 -v ./docs:/site:z ghcr.io/srid/emanote run -p 8080
```

Build the static pages:
```sh
podman run -it --rm -v ./docs:/site:z -v ./output:/output:z ghcr.io/srid/emanote gen /output
```
39 changes: 39 additions & 0 deletions nix/modules/flake-parts/container.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{ root, ... }: {
perSystem = { pkgs, config, lib, ... }:
let
emanote = config.packages.emanote;
container-name = "ghcr.io/srid/emanote";
container = pkgs.dockerTools.streamLayeredImage {
name = container-name;
tag = "latest";
created = "now";
config.Entrypoint = [ "${emanote}/bin/emanote" ];
config.WorkingDir = "/site";
config.Labels = {
"org.opencontainers.image.source" = "https://github.com/srid/emanote";
};
};
in
{
# Load the container locally with: `nix build .#container && ./result | podman load`
packages = { container = container; };

# Run this script in the CI to publish a new image
apps = {
publish-container-release.program = pkgs.writeShellScriptBin "emanote-release" ''
set -e
export PATH=$PATH:${pkgs.gzip}/bin:${pkgs.skopeo}/bin
IMAGE="docker://${container-name}"

echo "Logging to registry..."
echo $GH_TOKEN | skopeo login --username $GH_USERNAME --password-stdin ghcr.io

echo "Building and publishing the image..."
${container} | gzip --fast | skopeo copy docker-archive:/dev/stdin $IMAGE:${emanote.version}

echo "Tagging latest"
skopeo copy $IMAGE:${emanote.version} $IMAGE:latest
'';
};
};
}
Loading