diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e9d0b6fe5..cc1a5b6f0 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -63,3 +63,15 @@ 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: Set XDG_RUNTIME_DIR + run: mkdir ~/.xdg-runtime && echo "XDG_RUNTIME_DIR=$HOME/.xdg-runtime" >> $GITHUB_ENV + - name: Push Image + run: nix run ".#publish-container-release" + env: + GH_USERNAME: ${{ github.actor }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/docs/start/install/container.md b/docs/start/install/container.md new file mode 100644 index 000000000..5f200fc32 --- /dev/null +++ b/docs/start/install/container.md @@ -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 +``` diff --git a/nix/modules/flake-parts/container.nix b/nix/modules/flake-parts/container.nix new file mode 100644 index 000000000..7431929de --- /dev/null +++ b/nix/modules/flake-parts/container.nix @@ -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 + ''; + }; + }; +}