-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
105 lines (87 loc) · 2.52 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.bmuschko:gradle-docker-plugin:3.0.12'
}
}
apply plugin: 'com.bmuschko.docker-remote-api'
import com.bmuschko.gradle.docker.tasks.image.Dockerfile
import com.bmuschko.gradle.docker.tasks.image.DockerBuildImage
task createTargetDir {
new File('target').mkdirs()
new File('target/css').mkdirs()
new File('target/dist').mkdirs()
}
task buildHetzer(type: Exec) {
executable = 'stack'
args = ['build']
}
task installHetzer(dependsOn: [buildHetzer, createTargetDir], type: Exec) {
executable = 'stack'
args = ['install', '--local-bin-path', 'target']
}
task copyConfig(dependsOn: createTargetDir, type: Copy) {
from 'config'
into 'target'
include 'hetzer_conf.json'
}
task copyCss(dependsOn: createTargetDir, type: Copy) {
from 'frontend'
into 'target/css'
include '*.css'
}
task copyIndex(dependsOn: createTargetDir, type: Copy) {
from 'frontend'
into 'target'
include 'index.html'
}
task npmInstall(type: Exec) {
workingDir 'frontend'
executable = 'npm'
args = ['install']
}
task webpack(type: Exec) {
workingDir 'frontend'
executable = 'webpack'
}
task copyReact(dependsOn: npmInstall, type: Copy) {
from 'frontend/node_modules/react/dist/react.js'
into 'target/dist'
}
task copyReactDom(dependsOn: npmInstall, type: Copy) {
from 'frontend/node_modules/react-dom/dist/react-dom.js'
into 'target/dist'
}
task copyBootstrapCss(dependsOn: [npmInstall, createTargetDir], type: Copy) {
from 'frontend/node_modules/bootstrap/dist/css'
into 'target/css'
include '*.css'
}
task copyBundle(dependsOn: [createTargetDir, webpack], type: Copy) {
from 'frontend/dist'
into 'target/dist'
}
task clean(type: Delete) {
delete 'target'
}
task install
install.dependsOn copyCss,copyIndex,copyConfig,installHetzer,copyBootstrapCss, copyBundle, copyReact, copyReactDom
task createDockerFile(dependsOn: install, type: Dockerfile) {
destFile = project.file('target/Dockerfile')
from 'debian:stretch'
runCommand('apt-get update')
runCommand('apt-get install -y libgmp-dev')
workingDir('/hetzer')
copyFile('hetzer_conf.json', './hetzer_conf.json')
copyFile('css', './css')
copyFile('dist', './dist')
copyFile('index.html', './')
copyFile('hetzer', './')
entryPoint('./hetzer')
}
task buildImage(dependsOn: createDockerFile, type: DockerBuildImage) {
inputDir = createDockerFile.destFile.parentFile
tag = 'hetzer'
}