Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
42 changes: 42 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,48 @@ jobs:
- uses: actions/checkout@v4
- uses: DeterminateSystems/flake-checker-action@v9

build-container:
runs-on: ubuntu-latest
permissions:
packages: write
env:
image_name: ocf-docs
registry: ghcr.io/${{ github.repository_owner }}
steps:
- uses: actions/checkout@v7

- uses: cachix/install-nix-action@v31

- name: Build and tag image
run: |
IMAGE_TAG=$(sh $(nix build .#image --no-link --print-out-paths) 2>/dev/null | podman load -q | grep -oe "$image_name:.*$" | sed -e "s/$image_name://")
echo "image_tags=$IMAGE_TAG" >> $GITHUB_ENV

- name: Tag latest
if: github.ref == 'refs/heads/main'
run: |
podman tag $image_name:$image_tags $image_name:latest
echo "image_tags=$image_tags latest" >> $GITHUB_ENV

- name: Log in to GHCR
uses: redhat-actions/podman-login@v1
with:
username: ${{ github.actor }}
password: ${{ github.token }}
registry: ${{ env.registry }}

- name: Push to GHCR
id: push-ghcr
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ env.image_name }}
tags: ${{ env.image_tags }}
registry: ${{ env.registry }}

- name: Print image url
run: echo "Image pushed to ${{ steps.push-ghcr.outputs.registry-paths }}"


build_and_deploy:
runs-on: ci-ocf-mkdocs
if: github.ref == 'refs/heads/main'
Expand Down
4 changes: 4 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@ stdenvNoCC.mkDerivation {
];

buildPhase = ''
runHook preBuild
mkdocs build
runHook postBuild
'';

installPhase = ''
runHook preInstall
mv site $out
runHook postInstall
'';
}
8 changes: 4 additions & 4 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

81 changes: 72 additions & 9 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,30 +1,93 @@
{
description = "Mkdocs configuration for the Open Computing Facility";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
nixpkgs.url = "github:nixos/nixpkgs/nixos-26.05";
systems.url = "github:nix-systems/default";
};
outputs = { self, nixpkgs, systems }:
outputs =
{
self,
nixpkgs,
systems,
}:
let
pkgsFor = system: nixpkgs.legacyPackages.${system};
pkgsFor = system: import nixpkgs { inherit system; };
forAllSystems = fn: nixpkgs.lib.genAttrs (import systems) (system: fn (pkgsFor system));
in
{
packages = forAllSystems (pkgs: {
packages = forAllSystems (pkgs: rec {
default = pkgs.callPackage ./. { };
image = pkgs.dockerTools.streamLayeredImage (
let
timestamp = builtins.readFile (
pkgs.runCommand "timestamp" { } ''
date --date='@${toString self.lastModified}' --iso-8601=minutes > $out
''
);

docsPath = default;

nginxPort = "80";
nginxConf = pkgs.writeText "nginx.conf" ''
user nobody nobody;
daemon off;
error_log /dev/stdout info;
pid /dev/null;
events {}
http {
include ${pkgs.nginx}/conf/mime.types;
default_type application/octet-stream;
access_log /dev/stdout;
server {
listen ${nginxPort};
root ${docsPath};
}
}
'';
in
{
name = "ocf-docs";
created = timestamp;
mtime = timestamp;

contents = with pkgs; [
busybox
nginx
dockerTools.fakeNss
];

extraCommands = ''
# nginx requires these dirs to exist, see:
# https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/docker/examples.nix
mkdir -p tmp/nginx_client_body
mkdir -p var/log/nginx
'';

config = {
Cmd = [
"nginx"
"-c"
nginxConf
];
ExposedPorts = {
"${nginxPort}/tcp" = { };
};
};
}
);
});
devShells = forAllSystems (pkgs: {
default = pkgs.mkShell {
inputsFrom = [ self.packages.${pkgs.system}.default ];
shellHook = "mkdocs serve -f mkdocs-dev.yml";
};
deploy = pkgs.mkShell {
packages = with pkgs; [
rsync
openssh
];
packages = with pkgs; [
rsync
openssh
];
};
});
formatter = forAllSystems (pkgs: pkgs.nixpkgs-fmt);
formatter = forAllSystems (pkgs: pkgs.nixfmt-tree);
};
}
Loading