Skip to content

Commit dc1c7f9

Browse files
committed
added database deploy to sandbox
1 parent 703aaaf commit dc1c7f9

File tree

7 files changed

+80
-8
lines changed

7 files changed

+80
-8
lines changed

docker-compose.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,18 @@ services:
3838
user: root # to access host's docker socket
3939
environment:
4040
- "SPRING_PROFILES_ACTIVE=${PROFILE}"
41+
- "MYSQL_USER=/run/secrets/db_username"
42+
- "MYSQL_PASSWORD_FILE=/run/secrets/db_password"
43+
secrets:
44+
- db_username
45+
- db_password
46+
- db_url
4147
ports:
4248
- "5400:5400"
4349
volumes:
4450
- "/var/run/docker.sock:/var/run/docker.sock"
45-
- /home/saveu/executionLogs:/home/cnb/executionLogs/
4651
- /home/saveu/configs/sandbox:/home/cnb/config
52+
- save-fs-storage:/home/cnb/files
4753
- save-tmp-resources:/tmp
4854
extra_hosts:
4955
- "host.docker.internal:host-gateway"

gradle/libs.versions.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ spring-boot-starter-test = { module = "org.springframework.boot:spring-boot-star
8484
spring-boot-starter-data-jpa = { module = "org.springframework.boot:spring-boot-starter-data-jpa" }
8585
spring-boot-starter-quartz = { module = "org.springframework.boot:spring-boot-starter-quartz" }
8686
spring-boot-starter-security = { module = "org.springframework.boot:spring-boot-starter-security" }
87+
spring-boot = { module = "org.springframework.boot:spring-boot" }
8788
spring-boot-configuration-processor = { module = "org.springframework.boot:spring-boot-configuration-processor", version.ref = "spring-boot" }
8889
spring-security-core = { module = "org.springframework.security:spring-security-core" }
8990
spring-security-oauth2-client = { module = "org.springframework.security:spring-security-oauth2-client" }
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
org.springframework.boot.env.EnvironmentPostProcessor=com.saveourtool.save.backend.postprocessor.DockerSecretsDatabaseProcessor
1+
org.springframework.boot.env.EnvironmentPostProcessor=com.saveourtool.save.spring.postprocessor.DockerSecretsDatabaseProcessor

save-cloud-charts/save-cloud/templates/sandbox-deployment.yaml

Lines changed: 68 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,79 @@ spec:
4747
fieldPath: spec.nodeName
4848
volumeMounts:
4949
- {{ include "spring-boot.config-volume-mount" . | indent 14 | trim }}
50-
- name: execution-logs-storage
51-
mountPath: /home/cnb/executionLogs/
50+
- name: fs-storage
51+
mountPath: /home/cnb/files
52+
- name: database-secret
53+
mountPath: {{ .Values.sandbox.dbPasswordFile }}
5254
{{- include "spring-boot.management" .Values.sandbox | nindent 10 }}
5355
resources:
5456
limits:
5557
memory: 800M
5658
requests:
5759
memory: 600M
60+
initContainers:
61+
- name: git-cloner
62+
image: alpine/git
63+
args:
64+
- clone
65+
- --single-branch
66+
- --branch
67+
- {{ .Values.mysql.migrations.branch | default "master" }}
68+
- --
69+
- https://github.com/saveourtool/save-cloud.git
70+
- /data
71+
volumeMounts:
72+
- mountPath: /data
73+
name: migrations-data
74+
- name: liquibase-runner
75+
image: liquibase/liquibase:4.15
76+
securityContext:
77+
runAsUser: 1001
78+
runAsGroup: 1001
79+
args:
80+
- --url=$(DB_URL)
81+
- --changeLogFile=save-sandbox/db/db.changelog-master.xml
82+
- --username=$(DB_USERNAME)
83+
- --password=$(DB_PASSWORD)
84+
- --log-level=info
85+
- --contexts={{ .Values.profile }}
86+
- update
87+
resources:
88+
requests:
89+
memory: 100M
90+
limits:
91+
memory: 300M
92+
env:
93+
# See https://hub.docker.com/r/liquibase/liquibase, section 'Notice for MySQL Users'
94+
- name: INSTALL_MYSQL
95+
value: 'true'
96+
- name: DB_URL
97+
valueFrom:
98+
secretKeyRef:
99+
name: db-secrets
100+
key: spring.datasource.url
101+
- name: DB_USERNAME
102+
valueFrom:
103+
secretKeyRef:
104+
name: db-secrets
105+
key: spring.datasource.username
106+
- name: DB_PASSWORD
107+
valueFrom:
108+
secretKeyRef:
109+
name: db-secrets
110+
key: spring.datasource.password
111+
volumeMounts:
112+
- mountPath: /liquibase/changelog
113+
name: migrations-data
114+
- mountPath: {{ .Values.sandbox.dbPasswordFile }}
115+
name: database-secret
58116
volumes:
59117
- {{ include "spring-boot.config-volume" (dict "service" .Values.sandbox) | indent 10 | trim }}
60-
- name: execution-logs-storage
61-
# FixMe: Do we still need logs storage? All logs should be stored in Loki.
62-
emptyDir: {}
118+
- name: fs-storage
119+
persistentVolumeClaim:
120+
claimName: save-fs-storage
121+
- name: database-secret
122+
secret:
123+
secretName: db-secrets
124+
- name: migrations-data
125+
emptyDir: { }

save-cloud-common/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ kotlin {
4545
implementation(project.dependencies.platform(libs.spring.boot.dependencies))
4646
implementation(libs.spring.security.core)
4747
implementation(libs.spring.web)
48+
implementation(libs.spring.boot)
4849
implementation(libs.jackson.module.kotlin)
4950
implementation(libs.hibernate.jpa21.api)
5051
api(libs.slf4j.api)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.saveourtool.save.backend.postprocessor
1+
package com.saveourtool.save.spring.postprocessor
22

33
import org.springframework.boot.SpringApplication
44
import org.springframework.boot.env.EnvironmentPostProcessor
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
org.springframework.boot.env.EnvironmentPostProcessor=com.saveourtool.save.spring.postprocessor.DockerSecretsDatabaseProcessor

0 commit comments

Comments
 (0)