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
27 changes: 23 additions & 4 deletions container.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,20 @@ type ContainerGoProps struct {
// Toolchain configuration for building Go Lambda function
Toolchain *Toolchain

// Path to Dockerfile relative to the module,
// if not specified, the default Dockerfile will be generated.
//
// The file must contain:
// ADD bootstrap /bin/bootstrap
// CMD ["/bin/bootstrap"]
Dockerfile string

// Static files included into container, the path is relative to module
// Only added to container if Dockerfile is not specified, otherwise it's caller responsibility to add them into container within Dockerfile
StaticAssets []string

// Linux Alpine Packages (apk) to be installed within the container
// Only added to container if Dockerfile is not specified, otherwise it's caller responsibility to add them into container within Dockerfile
Packages []string
}

Expand Down Expand Up @@ -115,7 +125,15 @@ func NewContainerGo(scope constructs.Construct, id *string, spec *ContainerGoPro
panic(fmt.Errorf("unable to build %s/%s", spec.SourceCodeModule, spec.SourceCodeLambda))
}

docker := fmt.Sprintf(`
if spec.Dockerfile != "" {
source := filepath.Join(rootSourceCode(spec.SourceCodeModule), spec.Dockerfile)
target := filepath.Join(path, "Dockerfile")
log.Printf("==> copy %s\n", spec.Dockerfile)
if err := copy(source, target); err != nil {
panic(err)
}
} else {
docker := fmt.Sprintf(`
FROM %s
%s
%s
Expand All @@ -124,9 +142,10 @@ ADD bootstrap /bin/bootstrap
CMD ["/bin/bootstrap"]
`, dockerBaseImage(spec), dockerPackages(spec), dockerAssets(path, spec))

err := os.WriteFile(filepath.Join(path, "Dockerfile"), []byte(docker), 0664)
if err != nil {
panic(err)
err := os.WriteFile(filepath.Join(path, "Dockerfile"), []byte(docker), 0664)
if err != nil {
panic(err)
}
}

props.Code = awslambda.DockerImageCode_FromImageAsset(
Expand Down
16 changes: 6 additions & 10 deletions doc/scud-logo-v2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading