-
Notifications
You must be signed in to change notification settings - Fork 8
/
image.go
56 lines (45 loc) · 1.27 KB
/
image.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
// Copyright 2022 Namespace Labs Inc; All rights reserved.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
package main
import (
"embed"
"encoding/json"
"io/fs"
"github.com/moby/buildkit/client/llb"
specs "github.com/opencontainers/image-spec/specs-go/v1"
"namespacelabs.dev/foundation/internal/dependencies/pins"
"namespacelabs.dev/foundation/internal/llbutil"
)
var (
//go:embed versions.json fn-postgres-entrypoint.sh
lib embed.FS
postgresImage string
entrypoint []byte
)
type versionsJSON struct {
Images map[string]string `json:"images"`
Postgres string `json:"postgres"`
}
var (
versions versionsJSON
)
func init() {
versionData, err := fs.ReadFile(lib, "versions.json")
if err != nil {
panic(err)
}
if err := json.Unmarshal(versionData, &versions); err != nil {
panic(err)
}
postgresImage = pins.Image(versions.Postgres)
entrypoint, err = fs.ReadFile(lib, "fn-postgres-entrypoint.sh")
if err != nil {
panic(err)
}
}
func makePostgresImageState(platform specs.Platform) llb.State {
return llbutil.Image(postgresImage, platform).
File(llb.Mkfile("fn-postgres-entrypoint.sh", 0777, entrypoint)).
File(llb.Rm("/usr/local/bin/docker-entrypoint.sh"))
}