-
Notifications
You must be signed in to change notification settings - Fork 4
/
xnat-web.pkr.hcl
91 lines (83 loc) · 2.96 KB
/
xnat-web.pkr.hcl
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
# xnat-build/xnat-web.pkr.hcl
# variables: xnat-build/xnat-web-variables.pkr.hcl
# pre-req.: make
#
build {
provisioner "shell" {
inline = [
"mkdir -p ${var.xnat_root}/{archive,build,cache,fileStore,ftp,inbox,pipeline,prearchive}",
"mkdir -p ${var.xnat_home}/{config/auth,logs,plugins,themes,work}",
"chown -R ${var.run_as_uid}:${var.run_as_uid} ${var.xnat_root} ${var.xnat_home}",
]
inline_shebang = "/bin/bash -e"
}
provisioner "file" {
destination = "${var.xnat_plugins}/"
sources = var.xnat_plugins_list
}
provisioner "file" {
destination = "/tmp/"
sources = [
"xnat-web-${var.xnat_version}.war",
"packer_files"
]
only = ["docker.xnat-web"]
}
provisioner "file" {
destination = "${var.xnat_home}/config/"
sources = [
"xnat-conf.properties"
]
}
provisioner "file" {
destination = "/"
sources = [
"docker-entrypoint.sh",
"docker-entrypoint.d"
]
only = [ "docker.xnat-web" ]
}
provisioner "shell" {
inline = [
"apt-get update",
"rm -rf $${CATALINA_HOME}/webapps/*",
"unzip -o -d $${CATALINA_HOME}/webapps/ROOT /tmp/xnat-web-*.war",
"sed -i 's/ch.qos.logback.core.rolling.RollingFileAppender/ch.qos.logback.core.ConsoleAppender/' $${CATALINA_HOME}/webapps/ROOT/WEB-INF/classes/logback.xml",
"cp /tmp/packer_files/setenv.sh $${CATALINA_HOME}/bin/setenv.sh && chmod 0555 $${CATALINA_HOME}/bin/setenv.sh",
"find ${var.xnat_home}/config ${var.xnat_plugins} -type d -exec chmod 0755 {} \\; && find ${var.xnat_plugins} -type f -exec chmod 0644 {} \\;",
# Set local account as owner of XNAT config, plugins and Tomcat directories
"chown -R ${var.run_as_uid}:${var.run_as_uid} ${var.xnat_home}/config ${var.xnat_plugins} $${CATALINA_HOME}",
"[ -f /docker-entrypoint.sh ] && chmod 0755 /docker-entrypoint.sh",
"[ -d /docker-entrypoint.d ] && find /docker-entrypoint.d -type d -exec chmod 0755 {} \\; && find /docker-entrypoint.d -type f -exec chmod 0644 {} \\; && chown -R ${var.run_as_uid}:${var.run_as_uid} /docker-entrypoint.d",
"rm -rf /tmp/*",
"rm -rf /var/lib/apt/lists/*"
]
}
post-processors {
# Do not remove ci tag - required for CICD pipeline
# used for development; microk8s registry
post-processor "docker-tag" {
repository = "${var.repository}/${source.name}"
tags = ["${var.xnat_version}","ci"]
only = ["docker.xnat-web"]
}
post-processor "docker-push" {
only = ["docker.xnat-web"]
}
}
sources = [
"source.docker.xnat-web"
]
}
source "docker" "xnat-web" {
changes = [
"CMD [\"bin/catalina.sh\",\"run\"]",
"ENTRYPOINT [\"/docker-entrypoint.sh\"]",
"ENV XNAT_HOME=${var.xnat_home}",
"LABEL maintainer=\"Dean Taylor <[email protected]>\"",
"LABEL org.opencontainers.image.source https://github.com/australian-imaging-service/xnat-build",
"USER ${var.run_as_uid}"
]
commit = true
image = var.docker_image
}