-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitpod.Dockerfile
75 lines (62 loc) · 2.11 KB
/
.gitpod.Dockerfile
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
FROM gitpod/workspace-base
SHELL ["/bin/bash", "-c"]
RUN <<EOR
set -eu
jb_dir="${HOME}/.gitpod/jetbrains"
jb_options_dir="${jb_dir}/options"
jdbc_drivers_dir="${jb_dir}/jdbc-drivers"
mkdir -m 0755 -p "${jb_options_dir}" "${jdbc_drivers_dir}"
# Download database driver dependencies
jars=(
"https://repo1.maven.org/maven2/org/postgresql/postgresql/42.7.3/postgresql-42.7.3.jar"
"https://repo1.maven.org/maven2/org/checkerframework/checker-qual/3.42.0/checker-qual-3.42.0.jar"
)
(
cd "${jdbc_drivers_dir}"
for jar in "${jars[@]}"; do {
curl -LO "${jar}"
} done
)
databaseDrivers_xml="$(
printf '%s\n' '<application>
<component name="LocalDatabaseDriverManager" version="201">
<driver id="postgresql">
<artifact />'
for f in "${jdbc_drivers_dir}"/*; do {
printf '%s\n' " <library>
<url>file://${f}</url>
</library>"
} done
printf '%s\n' ' </driver>
</component>
</application>'
)"
printf "%s\n" "${databaseDrivers_xml}" > "${jb_options_dir}/databaseDrivers.xml"
# For postgres, pgpass is a simple solution, you can pick this auth method in the db connection
## You may add more static entries here as necessary
## You can use wildcards (*) for any field except password
## Format = hostname:port:database:username:password
## See https://www.postgresql.org/docs/current/libpq-pgpass.html for more
cat >> "${HOME}/.pgpass" <<'PGPASS'
*:*:*:*:mysecretpassword
PGPASS
# Keepass method should work for all DBs, commment it out if not needed. For postgres, pgpass is simpler
sudo tee -a /etc/bash.bashrc <<'BASH'
if test -v JETBRAINS_GITPOD_BACKEND_KIND && mkdir /tmp/.jdbc.lock 2>/dev/null; then
(
# until test -e /workspace/.gitpod/ready; do
# sleep 1
# done
shopt -s nullglob
until ides=(/workspace/.config/JetBrains/RemoteDevv-*) && test -n "${ides:-}"; do
sleep 1
done
for ide in "${ides[@]}"; do
for f in "${GITPOD_REPO_ROOT}/.idea/keepass"/*; do
ln -sf "${f}" "${ide}"
done
done
) & disown
fi
BASH
EOR