I have been trying to find an example of pkgs.dockerTools.pullImage, pkgs.dockerTools.buildImage, and pkgs.dockerTools.buildLayeredImage that does the equivalent of this very simple dockerfile:
FROM caddy:2.11-builder AS builder
RUN xcaddy build \
--with github.com/caddy-dns/namesilo \
--with github.com/liujed/caddy-dns01proxy
FROM caddy:2.11
COPY --from=builder /usr/bin/caddy /usr/bin/caddy
So far, I’ve found the following threads and posts on the topic:
- pkgs.dockerTools Examples
- Cheap Docker Images with Nix (older post, relevant bit is in the “Building off a base image” part for me)
- Building and Running Docker Images
- Pull Docker Image for Later Use
My goal is to work with this config for home-manager (that link is to the commit in my repo that is from, so if more context is needed you can view the rest of the source there):
{ config, lib, osConfig, ... }:
let
# The "users" group.
gid = "100";
uid = toString osConfig.system-settings.users.${config.home.username}.uid;
in
{
config.services.podman.containers.caddy-reverese-proxy = lib.mkIf (
osConfig.system-settings.server-environment.enable &&
osConfig.system-settings.server-environment.containers.enable &&
config.home.service-user.containers.caddy.enable
) {
image = "docker.io/library/caddy:2.11";
addCapabilities = [
"NET_ADMIN"
];
autoStart = true;
autoUpdate = "registry";
description = "Caddy Reverse Proxy";
extraPodmanArgs = [
"--name=caddy-reverse-proxy"
"--user=${uid}:${gid}"
"--userns=keep-id"
];
network = "hosted-applications";
networkAlias = [
"caddy"
"caddy-reverse-proxy"
];
ports = [
"80:80"
"443:443"
"443:443/udp"
];
volumes = [
"/srv/configuration/caddy/config:/config:Z"
"/srv/configuration/caddy/data:/data:Z"
"/srv/configuration/caddy/etc:/etc/caddy:Z"
"/srv/configuration/caddy/logs:/logs:Z"
"/srv/www:/srv:z"
];
};
}
The end goal is to replace “image” in the above config with the equivalent of the Dockerfile I posted earlier. Any help would be greatly appreciated.