Add Forgejo action to build Docker image
This commit is contained in:
parent
649566c8ab
commit
fe9488d31c
3 changed files with 101 additions and 31 deletions
86
flake.nix
86
flake.nix
|
@ -4,9 +4,14 @@
|
|||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
|
||||
flutils.url = "github:numtide/flake-utils";
|
||||
|
||||
nginx = {
|
||||
url = "github:nginx/nginx";
|
||||
flake = false;
|
||||
};
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, flutils }: flutils.lib.eachDefaultSystem (system:
|
||||
outputs = { self, nixpkgs, flutils, nginx }: flutils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
|
||||
|
@ -21,28 +26,73 @@
|
|||
dontUnpack = true;
|
||||
installPhase = "install -Dm755 ${./patch-feed-date.py} $out/bin/patch-feed-date";
|
||||
};
|
||||
|
||||
nginxPort = "80";
|
||||
nginxConf = pkgs.writeText "nginx.conf" ''
|
||||
user nobody nobody;
|
||||
daemon off;
|
||||
error_log /dev/stdout info;
|
||||
pid /dev/null;
|
||||
events {}
|
||||
http {
|
||||
access_log /dev/stdout;
|
||||
include ${nginx.outPath}/conf/mime.types;
|
||||
|
||||
server {
|
||||
listen ${nginxPort};
|
||||
index index.html;
|
||||
location / {
|
||||
root ${self.packages.${system}.static-website};
|
||||
}
|
||||
}
|
||||
}
|
||||
'';
|
||||
in
|
||||
{
|
||||
packages.static-website = pkgs.stdenv.mkDerivation {
|
||||
name = "blog-pim";
|
||||
src = ./src;
|
||||
sourceRoot = "src";
|
||||
packages = {
|
||||
static-website = pkgs.stdenv.mkDerivation {
|
||||
name = "blog-pim";
|
||||
src = ./src;
|
||||
sourceRoot = "src";
|
||||
|
||||
buildInputs = [
|
||||
gems
|
||||
gems.wrappedRuby
|
||||
patch-feed-date
|
||||
];
|
||||
buildInputs = [
|
||||
gems
|
||||
gems.wrappedRuby
|
||||
patch-feed-date
|
||||
];
|
||||
|
||||
buildPhase = ''
|
||||
bundle exec jekyll build
|
||||
'';
|
||||
buildPhase = ''
|
||||
bundle exec jekyll build
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out
|
||||
cp -r _site/* $out/
|
||||
patch-feed-date --file _site/feed.xml > $out/feed.xml
|
||||
'';
|
||||
installPhase = ''
|
||||
mkdir -p $out
|
||||
cp -r _site/* $out/
|
||||
patch-feed-date --file _site/feed.xml > $out/feed.xml
|
||||
'';
|
||||
};
|
||||
|
||||
container-image = pkgs.dockerTools.buildLayeredImage {
|
||||
name = "blog-pim";
|
||||
tag = "latest";
|
||||
|
||||
contents = [
|
||||
pkgs.fakeNss
|
||||
pkgs.nginx
|
||||
];
|
||||
|
||||
extraCommands = ''
|
||||
mkdir -p tmp/nginx_client_body
|
||||
mkdir -p var/log/nginx
|
||||
'';
|
||||
|
||||
config = {
|
||||
Cmd = [ "nginx" "-c" nginxConf ];
|
||||
ExposedPorts = {
|
||||
"${nginxPort}/tcp" = { };
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue