This repository has been archived by the owner on Sep 26, 2022. It is now read-only.
/
base.go
63 lines (56 loc) · 1.77 KB
/
base.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package stack
import (
"fmt"
"os"
"path/filepath"
)
const arch = "x86_64"
func NewBaseStack(buildTag, runTag, stackDir string, publish bool) (Definition, error) {
sources, err := os.ReadFile(filepath.Join(stackDir, "arch", arch, "sources.list"))
if err != nil {
return Definition{}, fmt.Errorf("failed to read sources list file: %w", err)
}
buildPackages, err := os.ReadFile(filepath.Join(stackDir, "packages", "base", "build"))
if err != nil {
return Definition{}, fmt.Errorf("failed to read build packages list file: %w", err)
}
runPackages, err := os.ReadFile(filepath.Join(stackDir, "packages", "base", "run"))
if err != nil {
return Definition{}, fmt.Errorf("failed to read run packages list file: %w", err)
}
useBuildKit := false
return Definition{
BuildBase: Image{
UseBuildKit: useBuildKit,
Publish: publish,
Tag: buildTag,
Dockerfile: fmt.Sprintf("%s/bionic/dockerfile/build", stackDir),
Args: []string{
fmt.Sprintf("sources=%s", sources),
fmt.Sprintf("packages=%s", buildPackages),
},
},
BuildCNB: Image{
Publish: publish,
Tag: fmt.Sprintf("%s-cnb", buildTag),
Dockerfile: fmt.Sprintf("%s/bionic/cnb/build", stackDir),
Description: "ubuntu:bionic + openssl + CA certs + compilers + shell utilities",
},
RunBase: Image{
UseBuildKit: useBuildKit,
Publish: publish,
Tag: runTag,
Dockerfile: fmt.Sprintf("%s/bionic/dockerfile/run", stackDir),
Args: []string{
fmt.Sprintf("sources=%s", sources),
fmt.Sprintf("packages=%s", runPackages),
},
},
RunCNB: Image{
Publish: publish,
Tag: fmt.Sprintf("%s-cnb", runTag),
Dockerfile: fmt.Sprintf("%s/bionic/cnb/run", stackDir),
Description: "ubuntu:bionic + openssl + CA certs",
},
}, nil
}