-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
70 lines (58 loc) · 1.84 KB
/
build.gradle
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
plugins {
id 'java'
id 'org.springframework.boot' version '3.3.2'
id 'io.spring.dependency-management' version '1.1.6'
id 'com.palantir.docker' version '0.36.0'
}
group = 'com.example'
version = '1.5'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}
tasks.named('test') {
useJUnitPlatform()
}
def platform = project.hasProperty('platform') ? project.property('platform') : "frontend"
docker {
if (platform == "frontend") {
name "ddarahakit2024/frontend:"+version
files "frontend/dist"
buildArgs(['DIST_DIR': "/"])
dockerfile file('Dockerfile.frontend')
} else {
name "ddarahakit2024/backend:"+version
files tasks.bootJar.outputs.files
buildArgs(['JAR_FILE': tasks.bootJar.outputs.files.singleFile.name])
dockerfile file('Dockerfile')
}
}
task buildDocker(type: Exec) {
workingDir project.rootDir
commandLine 'gradlew.bat', 'docker','-Pplatform=backend'
}
task dockerComposeUp(type: Exec, dependsOn: buildDocker) {
environment 'DOCKER_IMAGE_TAG', version
commandLine 'docker-compose', 'up', '--build', '-d'
}
task buildFrontend(type: Exec) {
workingDir 'frontend'
commandLine 'C:\\Program Files\\nodejs\\npm.cmd', 'run', 'build'
}
task buildDockerFrontend(type: Exec, dependsOn: buildFrontend) {
workingDir project.rootDir
commandLine 'cmd', '/c', 'gradlew.bat', 'docker'
}
task dockerComposeUpFrontend(type: Exec, dependsOn: buildDockerFrontend) {
environment 'DOCKER_IMAGE_TAG', version
commandLine 'docker-compose', 'up', '--build', '-d'
}