This repository was archived by the owner on Mar 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathAcornfile
100 lines (89 loc) · 2.03 KB
/
Acornfile
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
name: "Postgres Acorn"
description: "Acorn providing Postgres"
readme: "./README.md"
info: localData.info
icon: "./icon.png"
args: {
// Name of the default database
dbName: "postgres"
// Name of the default user
dbUser: "postgres"
}
services: db: {
default: true
container: "postgres"
secrets: ["admin"]
ports: "5432"
data: dbName: args.dbName
}
containers: {
postgres: {
name: "Postgres"
description: "Container running a Postgres server"
image: "postgres:15.5-alpine3.18"
env: {
PGDATA: "/var/lib/postgresql/data/db"
POSTGRES_DB: args.dbName
POSTGRES_USER: "secret://admin/username"
POSTGRES_PASSWORD: "secret://admin/password"
}
dirs: {
"/var/lib/postgresql/data": "volume://db-data"
}
probes: [
{
type: "liveness"
initialDelaySeconds: 10
exec: command: localData.livenessProbeCommand
},
{
type: "readiness"
initialDelaySeconds: 5
exec: command: localData.readinessProbeCommand
},
]
}
}
volumes: {
"db-data": {}
}
secrets: {
admin: {
name: "credentials of the admin user"
type: "basic"
params: {
passwordLength: 10
passwordCharacters: "A-Za-z0-9"
}
data: {
username: std.ifelse(args.dbUser != "", args.dbUser, "")
password: ""
}
}
}
localData: readinessProbeCommand: [
"bash",
"-c",
"PGPASSWORD=\"${POSTGRES_PASSWORD}\" psql -U \"${POSTGRES_USER}\" -d \"${POSTGRES_DB}\" -c 'SELECT 1'",
]
localData: livenessProbeCommand: [
"bash",
"-c",
"PGPASSWORD=\"${POSTGRES_PASSWORD}\" pg_isready -U \"${POSTGRES_USER}\" -d \"${POSTGRES_DB}\"",
]
localData: info: """
## Usage
services: db: {
image: "ghcr.io/acorn-io/postgres:v#.#-#"
}
containers: app: {
image: "app-image"
env: {
DB_HOST: "@{@{service.}db.address}"
DB_PORT: "@{@{service.}db.port.5432}"
DB_NAME: "@{@{service.}db.data.dbName}"
DB_ADMIN_USER: "@{@{service.}db.secrets.admin.username}"
DB_ADMIN_PASS: "@{@{service.}db.secrets.admin.password}"
}
}
"""