Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Контекст сборки — весь репозиторий, но Dockerfile берёт из него только
# .git, файлы сборки Gradle и src/, а Dockerfile.migrator — liquibase/.
# Всё остальное исключаем, чтобы не гонять десятки мегабайт в билдер.
#
# ВНИМАНИЕ: .git исключать нельзя — Dockerfile копирует его внутрь,
# плагин com.palantir.git-version определяет по нему версию сборки.

# Результаты сборки
/build/
.gradle/
*.war
*.ear
*.class

# Документация и картинки
/docs/
/markdown_en/
/markdown_ru/
screenshot.png
*.md

# Инфраструктура, не участвующая в сборке образа
/k8s/
docker-compose.yml
.env

# IDE
.idea/
*.iml
63 changes: 63 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Build

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:

# Новый пуш в ту же ветку отменяет предыдущий незавершённый прогон
concurrency:
group: build-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
build:
name: Gradle build
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
with:
# com.palantir.git-version определяет version по тегам,
# при shallow clone теги недоступны и версия получается неверной
fetch-depth: 0

- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '21'

- name: Set up Gradle
uses: gradle/actions/setup-gradle@v4

- name: Print version
run: ./gradlew --no-daemon printVersion

- name: Build (compile + test + war)
run: ./gradlew --no-daemon --stacktrace build

- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results
path: |
build/reports/tests/test
build/test-results/test
if-no-files-found: ignore
retention-days: 14

- name: Upload WAR
uses: actions/upload-artifact@v4
with:
name: TrackStudio-war
path: build/libs/TrackStudio.war
if-no-files-found: error
retention-days: 14
36 changes: 31 additions & 5 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,40 @@ on:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:

jobs:
concurrency:
group: docker-${{ github.ref }}
cancel-in-progress: true

build:
permissions:
contents: read

jobs:
build:
name: Docker build
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Build the Docker image
run: docker build . --file Dockerfile --tag trackstudio/app:$(date +%s)
- name: Checkout
uses: actions/checkout@v4
with:
# Dockerfile копирует .git внутрь сборки, а com.palantir.git-version
# определяет version по тегам. При shallow clone тегов нет и в образ
# попадает версия-заглушка вместо реальной.
fetch-depth: 0

- name: Set up Buildx
uses: docker/setup-buildx-action@v3

- name: Build the Docker image
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: false
load: false
tags: trackstudio/app:${{ github.sha }}
# Кеш слоёв между прогонами: без него Gradle качает зависимости заново
cache-from: type=gha
cache-to: type=gha,mode=max
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ target
.bat
.sh

# Gradle
/build/
.gradle/

# Mobile Tools for Java (J2ME)
.mtj.tmp/

Expand Down
Loading