blob: e9fcebeaec5a8a3bdeb6478b09e5327bda3c3c01 [file] [log] [blame]
gio0eaf2712024-04-14 13:08:46 +04001import (
2 "encoding/base64"
3 "encoding/json"
4 "strings"
5)
6
7input: {
8 network: #Network @name(Network)
9 subdomain: string @name(Subdomain)
gioefa0ed42024-06-13 12:31:43 +040010 sshPort: int @name(SSH Port) @role(port)
gio0eaf2712024-04-14 13:08:46 +040011 adminKey: string @name(Admin SSH Public Key)
12
13 // TODO(gio): auto generate
14 ssKeys: #SSHKey
15 fluxKeys: #SSHKey
16 dAppKeys: #SSHKey
17}
18
19name: "Dodo App"
20namespace: "dodo-app"
21readme: "Deploy app by pushing to Git repository"
22description: "Deploy app by pushing to Git repository"
23icon: "<svg xmlns='http://www.w3.org/2000/svg' width='50' height='50' viewBox='0 0 48 48'><path fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' d='M2.837 27.257c3.363 2.45 11.566 3.523 12.546 1.4s.424-10.94.424-10.94s-1.763 1.192-2.302.147s.44-2.433 2.319-2.858c-1.96.05-2.221-.571-2.205-.93s.67-1.878 3.527-1.241c-1.6-.751-1.943-2.956 2.352-1.568c-1.421-.735-.36-2.825 1.649-.62c-.261-1.323 1.584-1.46 2.694.907M10.648 34.633a19 19 0 0 0-4.246.719'/><path fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' d='M15.144 43.402c3.625-2.482 7.685-6.32 7.293-13.406s-1.6-6.368-.523-7.577s6.924-.99 10.712 3.353c.032-2.874-2.504-5.508-2.504-5.508a33 33 0 0 1 5.53.163c2.852.49 2.394 2.514 3.58 2.035s.971-3.472-.39-5.377c-1.666-2.33-3.223-2.83-6.358-2.188s-4.474.458-5.54-.587s-2.026-3.538-4.605-2.515c-2.935 1.164-4.398 2.438-3.767 5.04s2.34 4.558 2.972 6.844'/><path fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' d='M22.001 16.552c-.925-.043-1.894.055-1.709 1.328'/><path fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' d='M20.662 16.763c1.72 2.695 3.405 3.643 9.46 3.501'/><path fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' d='M32.14 14.966c-1.223.879-2.18 3.781-2.496 5.307M23.1 14.908c.48 1.209 1.23.728 1.315.283a1.552 1.552 0 0 0-1.543-1.883m-.408 17.472c5.328 2.71 11.631.229 16.269-2.123c-1.176 4.572-5.911 5.585-8.916 6.107'/><path fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' d='M29.099 37.115c4.376-.294 8.024-1.578 7.833-5.296'/><path fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' d='M20.27 38.702c6.771 3.834 12.505.798 13.786-2.615'/><circle cx='24' cy='24' r='21.5' fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round'/></svg>"
24_domain: "\(input.subdomain).\(input.network.domain)"
25
26images: {
27 softserve: {
28 repository: "charmcli"
29 name: "soft-serve"
30 tag: "v0.7.1"
31 pullPolicy: "IfNotPresent"
32 }
33 dodoApp: {
34 repository: "giolekva"
35 name: "pcloud-installer"
36 tag: "latest"
37 pullPolicy: "Always"
38 }
39}
40
41charts: {
42 softserve: {
giof8843412024-05-22 16:38:05 +040043 kind: "GitRepository"
44 address: "https://github.com/giolekva/pcloud.git"
45 branch: "main"
46 path: "charts/soft-serve"
gio0eaf2712024-04-14 13:08:46 +040047 }
48 dodoApp: {
giof8843412024-05-22 16:38:05 +040049 kind: "GitRepository"
50 address: "https://github.com/giolekva/pcloud.git"
51 branch: "main"
52 path: "charts/dodo-app"
gio0eaf2712024-04-14 13:08:46 +040053 }
54}
55
56portForward: [#PortForward & {
57 allocator: input.network.allocatePortAddr
gioefa0ed42024-06-13 12:31:43 +040058 reservator: input.network.reservePortAddr
gio0eaf2712024-04-14 13:08:46 +040059 sourcePort: input.sshPort
gio3e67ce12024-06-13 19:47:19 +040060 serviceName: "soft-serve"
gio0eaf2712024-04-14 13:08:46 +040061 targetPort: 22
62}]
63
64helm: {
65 softserve: {
66 chart: charts.softserve
giof9f0bee2024-06-11 20:10:05 +040067 info: "Installing Git server"
gio0eaf2712024-04-14 13:08:46 +040068 values: {
69 serviceType: "ClusterIP"
70 addressPool: ""
71 reservedIP: ""
72 adminKey: strings.Join([input.adminKey, input.fluxKeys.public, input.dAppKeys.public], "\n")
73 privateKey: input.ssKeys.private
74 publicKey: input.ssKeys.public
75 ingress: {
76 enabled: false
77 }
78 image: {
79 repository: images.softserve.fullName
80 tag: images.softserve.tag
81 pullPolicy: images.softserve.pullPolicy
82 }
83 }
84 }
85 "dodo-app": {
86 chart: charts.dodoApp
giof9f0bee2024-06-11 20:10:05 +040087 info: "Installing supervisor"
gio0eaf2712024-04-14 13:08:46 +040088 values: {
89 image: {
90 repository: images.dodoApp.fullName
91 tag: images.dodoApp.tag
92 pullPolicy: images.dodoApp.pullPolicy
93 }
94 repoAddr: "soft-serve.\(release.namespace).svc.cluster.local:22"
95 sshPrivateKey: base64.Encode(null, input.dAppKeys.private)
96 self: "dodo-app.\(release.namespace).svc.cluster.local"
97 namespace: release.namespace
98 envConfig: base64.Encode(null, json.Marshal(global))
99 }
100 }
101}
102
103resources: {
104 "config-kustomization": {
105 apiVersion: "kustomize.toolkit.fluxcd.io/v1"
106 kind: "Kustomization"
107 metadata: {
108 name: "app"
109 namespace: release.namespace
110 }
111 spec: {
112 interval: "1m"
113 path: "./.dodo"
114 sourceRef: {
115 kind: "GitRepository"
116 name: "app"
117 namespace: release.namespace
118 }
119 prune: true
120 }
121 }
122 "config-secret": {
123 apiVersion: "v1"
124 kind: "Secret"
125 type: "Opaque"
126 metadata: {
127 name: "app"
128 namespace: release.namespace
129 }
130 data: {
131 identity: base64.Encode(null, input.fluxKeys.private)
132 "identity.pub": base64.Encode(null, input.fluxKeys.public)
133 known_hosts: base64.Encode(null, "soft-serve.\(release.namespace).svc.cluster.local \(input.ssKeys.public)")
134 }
135 }
136 "config-source": {
137 apiVersion: "source.toolkit.fluxcd.io/v1"
138 kind: "GitRepository"
139 metadata: {
140 name: "app"
141 namespace: release.namespace
142 }
143 spec: {
144 interval: "1m0s"
145 ref: branch: "dodo"
146 secretRef: name: "app"
147 timeout: "60s"
148 url: "ssh://soft-serve.\(release.namespace).svc.cluster.local:22/app"
149 }
150 }
151}
152
153help: [{
154 title: "How to use"
155 contents: """
156 Clone: git clone ssh://\(_domain):\(input.sshPort)/app
157 """
158}]