[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Building Docker images for AWS Lambda
From: |
Ray Miller |
Subject: |
Building Docker images for AWS Lambda |
Date: |
Sat, 26 Apr 2025 16:28:54 +0100 |
User-agent: |
Mozilla Thunderbird |
Hi,
I've been experimenting with a custom AWS Lambda runtime for Guile. AWS
Lambda allows you to use a container image as your deployment package,
and I figured it should be possible to create a Docker image with Guile,
my runtime and handler, and all their dependencies using `guix pack`.
Well, it nearly works...only it turns out AWS Lambda is a bit fussy
about the layers and the function creation fails with this error:
"MissingParentDirectory: Parent directory does not exist for file:
gnu/store/zic27jikg36d6wjj4cz8hyriyfl3ygiz-info-dir/"
It seems the gnu/ and gnu/store parent directories need to appear in the
tarball before any packages.
I made a couple of small changes to guix (see below) to create a
container that works with AWS Lambda, and now I'm wondering (a) if
there's a better way and (b) how to get an acceptable change
incorporated into guix proper. Please advise (also, please let me know
if this would better have been directed at the guix-devel mailing list -
I'm fairly now to this). Many thanks.
diff --git a/guix/docker.scm b/guix/docker.scm
index 60ce13cbde..9911bb84bb 100644
--- a/guix/docker.scm
+++ b/guix/docker.scm
@@ -365,10 +365,10 @@ (define* (build-docker-image image paths prefix
(apply invoke "tar" "-cf" "../layer.tar"
`(,@transformation-options
,@(tar-base-options)
- ,@(if max-layers '() paths)
,@(scandir "."
(lambda (file)
- (not (member file '("." ".."))))))))
+ (not (member file '("." "..")))))
+ ,@(if max-layers '() paths))))
(delete-file-recursively "extra")))
;; It is possible for "/" to show up in the archive, especially
when
diff --git a/guix/scripts/pack.scm b/guix/scripts/pack.scm
index 7ab2c0d447..ca2a6ba4d8 100644
--- a/guix/scripts/pack.scm
+++ b/guix/scripts/pack.scm
@@ -580,9 +580,11 @@ (define* (docker-image name profile
(,source -> ,target))))))
(define directives
- ;; Create a /tmp directory, as some programs expect it, and
- ;; create SYMLINKS.
+ ;; Create /tmp, /gnu, and /gnu/store directories, as some
+ ;; programs expect them, and create SYMLINKS.
`((directory "/tmp" ,(getuid) ,(getgid) #o1777)
+ (directory "/gnu" ,(getuid) ,(getgid) #o1777)
+ (directory "/gnu/store" ,(getuid) ,(getgid) #o1777)
,@(append-map symlink->directives '#$symlinks)))
(define (form-entry-point prefix entry-point
entry-point-argument)
OpenPGP_0x043F786C4CD681B8.asc
Description: OpenPGP public key
OpenPGP_signature.asc
Description: OpenPGP digital signature
- Building Docker images for AWS Lambda,
Ray Miller <=