SouthFox's Garden

Search IconA magnifying glass icon. 搜索
种植日期: 2025-09-09 上次照料: 2025-09-10

2025-09-09

Guix 打包成 docker 镜像

Guix 里的东西打包成 docker 镜像:

Invoking guix pack

guix pack node python python-beautifulsoup4 python-lxml tar gzip git-minimal nss-certs hugo-bin --substitute-urls=https://mirror.sjtu.edu.cn/guix/ -C zstd -f docker -S /usr/bin=bin --image-tag=git.southfox.me/actions/docker-agent

其中 -S 参数是链接 profile 到根目录下的软连接,可设空 -S /profile= 则可以将 progil 链接到镜像 /profile 下。

Guix 设置 glibc-locales

(define %minimal-glibc-locales
  (make-glibc-utf8-locales
   glibc
   #:locales (list "en_US")
   #:name "glibc-utf8-locales"))

(define-public minimal-glibc-locales
  (package
   (name "minimal-glibc-locales")
   (version "master")
   (source (plain-file "hello" "Hello World!"))
   (build-system copy-build-system)
   (arguments (list
               #:install-plan #~'(("hello" "share/"))
               #:phases
               #~(modify-phases
                  %standard-phases
                  (add-after 'unpack 'move-locales
                             (lambda _
                               (mkdir-p (string-append #$output "/share"))
                               (invoke
                                "cp" "-r"
                                (string-append #$(this-package-input "glibc-utf8-locales")
                                               "/lib")
                                (string-append #$output "/")))))))
   (inputs (list %minimal-glibc-locales))
   (synopsis "x")
   (description "x")
   (home-page "x")
   (license expat)))

glibc-locales 下占用了快 1G 的空间,对于 docker 镜像打包可以裁剪下,或许有更好方法?

docker 镜像中设置 locales

之行程序需要设置 GUIX_LOCPATHLANG=en_US.UTF-8 环境变量才能使相关 guix 程序正确应用本地化设置。

GUIX_LOCPATH=/profile/lib/locale LANG=en_US.UTF-8 haunt build

评论