Skip to content

Commit

Permalink
Update dependencies v2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Romanow committed Aug 27, 2024
1 parent c171615 commit 5a4c17f
Show file tree
Hide file tree
Showing 13 changed files with 58 additions and 20 deletions.
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
exclude: ^report/.*\.(key|pdf)
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ COPY --from=builder application/spring-boot-loader/ ./
COPY --from=builder application/dependencies/ ./
COPY --from=builder application/snapshot-dependencies/ ./
COPY --from=builder application/application/ ./
ENTRYPOINT ["java", "org.springframework.boot.loader.JarLauncher"]
ENTRYPOINT ["java", "org.springframework.boot.loader.launch.JarLauncher"]
38 changes: 34 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,38 @@ $ helm repo update
$ helm install postgres romanow/postgres --values postgres/values.yaml

# install service
$ helm install migration-application romanow/java-service --values=migration-application/values.yaml

# rollback
$ helm install rollback-to-v3 romanow/common-job --values=rollback-job/values.yaml --set rollbackTag=v3.0
$ helm upgrade \
migration-application \
romanow/java-service \
--values=k8s/migration-application/values.yaml \
--set image.tag="$IMAGE_VERSION" \
--set ingress.name=k8s \
--set ingress.domain=romanow-alex.ru \
--description "$IMAGE_VERSION" \
--install \
--wait

# rollback migration
$ helm install \
--generate-name \
romanow/common-job \
--values=k8s/rollback-job/values.yaml \
--set rollbackTag="$VERSION" \
--wait

# rollback revision
$ helm rollback migration-application "$REVISION" --wait
```

## Public report

[Деплой и откат приложения и миграций БД](report/README.md)

## TODO

1. Больше фокус на + и - миграций.
2. Мы можем себе это позволить, потому что данных не много (> 10Gb), если данных много, то тут другие подходы.
3. Деплоймент с даунтаймом, мы можем себе позволить релизное окно.
4. Из-за того, что мы не удаляем данные (и не восстанавливаем из архива), у нас данные растут и мы можем проверять
performance.
5. Генерация схемы через ORM – выстрел в ногу: долго, дорого, неконтролируемо.
12 changes: 6 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
plugins {
id "idea"
id "org.jetbrains.kotlin.kapt" version "1.7.10"
id "org.jetbrains.kotlin.jvm" version "1.7.10"
id "org.jetbrains.kotlin.plugin.jpa" version "1.7.10"
id "org.jetbrains.kotlin.plugin.spring" version "1.7.10"
id "org.springframework.boot" version "3.1.5"
id "org.jetbrains.kotlin.kapt" version "1.9.25"
id "org.jetbrains.kotlin.jvm" version "1.9.25"
id "org.jetbrains.kotlin.plugin.jpa" version "1.9.25"
id "org.jetbrains.kotlin.plugin.spring" version "1.9.25"
id "org.springframework.boot" version "3.2.8"
id "com.gorylenko.gradle-git-properties" version "2.4.1"
id "io.spring.dependency-management" version "1.1.0"
}

ext {
jetbrainsAnnotationsVersion = "24.0.1"
postgresContainerVersion = "1.18.0"
postgresContainerVersion = "1.20.0"
}

idea {
Expand Down
5 changes: 2 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: "3"
services:
postgres:
image: "postgres:15"
Expand All @@ -10,7 +9,7 @@ services:
ports:
- "5432:5432"
healthcheck:
test: [ "CMD-SHELL", "pg_isready" ]
test: [ "CMD-SHELL", "pg_isready -U $$POSTGRES_USER" ]
interval: 10s
timeout: 5s
retries: 5
Expand All @@ -20,7 +19,7 @@ services:

migration-application:
build: .
image: romanowalex/migration-application:v2.0
image: romanowalex/migration-application:v6.0
container_name: migration-application
environment:
SPRING_PROFILES_ACTIVE: docker
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
version=2.0
version=6.0
group=ru.romanow.migration
org.gradle.daemon=true
2 changes: 1 addition & 1 deletion liquibase-container/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM liquibase/liquibase:4.20

COPY src/main/resources/db/liquibase /liquibase/changelog
COPY src/main/resources/db/liquibase /BOOT-INF/classes/db/liquibase
COPY liquibase-container/drivers/postgresql-driver.jar /liquibase/lib
COPY liquibase-container/config/liquibase.docker.properties /liquibase
4 changes: 2 additions & 2 deletions liquibase-container/config/liquibase.docker.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
searchPath=/liquibase/changelog
changeLogFile=changelog.xml
searchPath=/
changeLogFile=BOOT-INF/classes/db/liquibase/changelog.xml
10 changes: 10 additions & 0 deletions report/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Деплой и откат приложения и миграций БД

## План

1. Постановка задачи: деплой `feature`-веток с миграциями БД и последующий откат до `develop`.
2. Прямые и обратные SQL операции.
3. Пример реализации: создаем кластер k8s, деплоим туда несколько версий приложения (_v1.0_, _v2.0_, ... _v5.0_), после
этого откатываем приложение и миграции до _v3.0_ и снова накатываем версию _v6.0_.
4. Ограничения решения.
5. Как настроить liquibase для применения отката миграций.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
logicalFilePath="v1.0_CreateUserTable.xml"
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
logicalFilePath="v2.0_ChangeIdToIdentity.xml"
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
Expand Down

0 comments on commit 5a4c17f

Please sign in to comment.