Skip to content

Commit 01f890f

Browse files
committed
Store a defaults.properties that is not to be edited
Store a copy of the defaults.properties file under `/opt/gitblit/etc`. This is included in the settings files chain, instead of the one in `/var/opt/gitblit/etc` which might get edited by a user. The defaults file needs to be the one included first. When updating to a new version, this file will include the latest settings, while the one on the volume might be at an older state. An altered copy of the `defaults.properties` file is placed into `/var/opt/gitblit/etc` for reference. The settings in the system properties files are deleted or commented out. Also move the `system.properties` file to `/opt/gitblit/etc`. The include of the defaults and system properties is moved to the file `gitblit-docker.properties` to move it out of the way where the user would set her custom settings in `gitblit.properties`.
1 parent ddee0a6 commit 01f890f

File tree

2 files changed

+94
-18
lines changed

2 files changed

+94
-18
lines changed

Dockerfile

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,50 @@ RUN set -eux ; \
3535
mv /opt/gitblit/data $gbetc ; \
3636
ln -s $gbetc /opt/gitblit/data ; \
3737
\
38+
# Make sure that the most current default properties file is available
39+
# unedited to Gitblit.
40+
mkdir -p /opt/gitblit/etc/ ; \
41+
mv $gbetc/defaults.properties /opt/gitblit/etc ; \
42+
printf "\
43+
6 c\\\n\
44+
\\\n\
45+
\\\n\
46+
""#\\\n\
47+
""# DO NOT EDIT THIS FILE. IT CAN BE OVERWRITTEN BY UPDATES.\\\n\
48+
""# FOR YOUR OWN CUSTOM SETTINGS USE THE FILE ${gbetc}/gitblit.properties\\\n\
49+
""# THIS FILE IS ONLY FOR REFERENCE.\\\n\
50+
""#\\\n\
51+
\\\n\
52+
\\\n\
53+
\n\
54+
/^# Base folder for repositories/,/^git.repositoriesFolder/d\n\
55+
/^# The location to save the filestore blobs/,/^filestore.storageFolder/d\n\
56+
/^# Specify the location of the Lucene Ticket index/,/^tickets.indexFolder/d\n\
57+
/^# The destination folder for cached federation proposals/,/^federation.proposalsFolder/d\n\
58+
/^# The temporary folder to decompress/,/^server.tempFolder/d\n\
59+
s/^server.httpPort.*/#server.httpPort = 8080/\n\
60+
s/^server.httpsPort.*/#server.httpsPort = 8443/\n\
61+
s/^server.redirectToHttpsPort.*/#server.redirectToHttpsPort = true/\n\
62+
" > /tmp/defaults.sed ; \
63+
sed -f /tmp/defaults.sed /opt/gitblit/etc/defaults.properties > $gbetc/defaults.properties ; \
64+
rm -f /tmp/defaults.sed ; \
65+
# Check that removal worked
66+
grep "^git.repositoriesFolder" $gbetc/defaults.properties && false ; \
67+
grep "^filestore.storageFolder" $gbetc/defaults.properties && false ; \
68+
grep "^tickets.indexFolder" $gbetc/defaults.properties && false ; \
69+
grep "^federation.proposalsFolder" $gbetc/defaults.properties && false ; \
70+
grep "^server.tempFolder" $gbetc/defaults.properties && false ; \
71+
\
3872
# Create a system.properties file that sets the defaults for this docker setup.
3973
# This is not available outside and should not be changed.
40-
echo "git.repositoriesFolder = ${gbsrv}/git" > /opt/gitblit/system.properties ; \
41-
echo "filestore.storageFolder = ${gbsrv}/lfs" >> /opt/gitblit/system.properties ; \
42-
echo "tickets.indexFolder = ${gbsrv}/tickets/lucene" >> /opt/gitblit/system.properties ; \
43-
echo "federation.proposalsFolder = ${gbsrv}/fedproposals" >> /opt/gitblit/system.properties ; \
44-
echo "server.tempFolder = ${GITBLIT_VAR}/temp" >> /opt/gitblit/system.properties ; \
45-
echo "server.httpPort=8080" >> /opt/gitblit/system.properties ; \
46-
echo "server.httpsPort=8443" >> /opt/gitblit/system.properties ; \
47-
echo "server.redirectToHttpsPort=true" >> /opt/gitblit/system.properties ; \
74+
echo "git.repositoriesFolder = ${gbsrv}/git" > /opt/gitblit/etc/system.properties ; \
75+
echo "filestore.storageFolder = ${gbsrv}/lfs" >> /opt/gitblit/etc/system.properties ; \
76+
echo "tickets.indexFolder = ${gbsrv}/tickets/lucene" >> /opt/gitblit/etc/system.properties ; \
77+
echo "federation.proposalsFolder = ${gbsrv}/fedproposals" >> /opt/gitblit/etc/system.properties ; \
78+
echo "server.tempFolder = ${GITBLIT_VAR}/temp" >> /opt/gitblit/etc/system.properties ; \
79+
echo "server.httpPort = 8080" >> /opt/gitblit/etc/system.properties ; \
80+
echo "server.httpsPort = 8443" >> /opt/gitblit/etc/system.properties ; \
81+
echo "server.redirectToHttpsPort = true" >> /opt/gitblit/etc/system.properties ; \
4882
\
4983
# Create a properties file for settings that can be set via environment variables from docker
5084
printf '\
@@ -58,10 +92,14 @@ RUN set -eux ; \
5892
''# Do not define your custom settings in this file. Your overrides or\n\
5993
''# custom settings should be defined in the "gitblit.properties" file.\n\
6094
''#\n\
95+
include = /opt/gitblit/etc/defaults.properties,/opt/gitblit/etc/system.properties\
6196
\n' > $gbetc/gitblit-docker.properties ; \
6297
# Currently RPC is enabled by default
6398
echo "web.enableRpcManagement=true" >> $gbetc/gitblit-docker.properties ; \
6499
echo "web.enableRpcAdministration=true" >> $gbetc/gitblit-docker.properties ; \
100+
sed -i -e 's/^web.enableRpcManagement.*/#web.enableRpcManagement=true/' \
101+
-e 's/^web.enableRpcAdministration.*/#web.enableRpcAdministration=true/' \
102+
$gbetc/defaults.properties ; \
65103
\
66104
# Create the gitblit.properties file that the user can use for customization.
67105
printf '\
@@ -81,7 +119,7 @@ RUN set -eux ; \
81119
''# The present files define the default settings for the docker container. If you\n\
82120
''# remove them or change the order, things may break.\n\
83121
''#\n\
84-
include = defaults.properties,/opt/gitblit/system.properties,gitblit-docker.properties\n\
122+
include = gitblit-docker.properties\n\
85123
\n\
86124
''#\n\
87125
''# Define your overrides or custom settings below\n\

Dockerfile.alpine

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,50 @@ RUN set -eux ; \
3535
mv /opt/gitblit/data $gbetc ; \
3636
ln -s $gbetc /opt/gitblit/data ; \
3737
\
38+
# Make sure that the most current default properties file is available
39+
# unedited to Gitblit.
40+
mkdir -p /opt/gitblit/etc/ ; \
41+
mv $gbetc/defaults.properties /opt/gitblit/etc ; \
42+
printf "\
43+
6 c\\\n\
44+
\\\n\
45+
\\\n\
46+
""#\\\n\
47+
""# DO NOT EDIT THIS FILE. IT CAN BE OVERWRITTEN BY UPDATES.\\\n\
48+
""# FOR YOUR OWN CUSTOM SETTINGS USE THE FILE ${gbetc}/gitblit.properties\\\n\
49+
""# THIS FILE IS ONLY FOR REFERENCE.\\\n\
50+
""#\\\n\
51+
\\\n\
52+
\\\n\
53+
\n\
54+
/^# Base folder for repositories/,/^git.repositoriesFolder/d\n\
55+
/^# The location to save the filestore blobs/,/^filestore.storageFolder/d\n\
56+
/^# Specify the location of the Lucene Ticket index/,/^tickets.indexFolder/d\n\
57+
/^# The destination folder for cached federation proposals/,/^federation.proposalsFolder/d\n\
58+
/^# The temporary folder to decompress/,/^server.tempFolder/d\n\
59+
s/^server.httpPort.*/#server.httpPort = 8080/\n\
60+
s/^server.httpsPort.*/#server.httpsPort = 8443/\n\
61+
s/^server.redirectToHttpsPort.*/#server.redirectToHttpsPort = true/\n\
62+
" > /tmp/defaults.sed ; \
63+
sed -f /tmp/defaults.sed /opt/gitblit/etc/defaults.properties > $gbetc/defaults.properties ; \
64+
rm -f /tmp/defaults.sed ; \
65+
# Check that removal worked
66+
grep "^git.repositoriesFolder" $gbetc/defaults.properties && false ; \
67+
grep "^filestore.storageFolder" $gbetc/defaults.properties && false ; \
68+
grep "^tickets.indexFolder" $gbetc/defaults.properties && false ; \
69+
grep "^federation.proposalsFolder" $gbetc/defaults.properties && false ; \
70+
grep "^server.tempFolder" $gbetc/defaults.properties && false ; \
71+
\
3872
# Create a system.properties file that sets the defaults for this docker setup.
3973
# This is not available outside and should not be changed.
40-
echo "git.repositoriesFolder = ${gbsrv}/git" > /opt/gitblit/system.properties ; \
41-
echo "filestore.storageFolder = ${gbsrv}/lfs" >> /opt/gitblit/system.properties ; \
42-
echo "tickets.indexFolder = ${gbsrv}/tickets/lucene" >> /opt/gitblit/system.properties ; \
43-
echo "federation.proposalsFolder = ${gbsrv}/fedproposals" >> /opt/gitblit/system.properties ; \
44-
echo "server.tempFolder = ${GITBLIT_VAR}/temp" >> /opt/gitblit/system.properties ; \
45-
echo "server.httpPort=8080" >> /opt/gitblit/system.properties ; \
46-
echo "server.httpsPort=8443" >> /opt/gitblit/system.properties ; \
47-
echo "server.redirectToHttpsPort=true" >> /opt/gitblit/system.properties ; \
74+
echo "git.repositoriesFolder = ${gbsrv}/git" > /opt/gitblit/etc/system.properties ; \
75+
echo "filestore.storageFolder = ${gbsrv}/lfs" >> /opt/gitblit/etc/system.properties ; \
76+
echo "tickets.indexFolder = ${gbsrv}/tickets/lucene" >> /opt/gitblit/etc/system.properties ; \
77+
echo "federation.proposalsFolder = ${gbsrv}/fedproposals" >> /opt/gitblit/etc/system.properties ; \
78+
echo "server.tempFolder = ${GITBLIT_VAR}/temp" >> /opt/gitblit/etc/system.properties ; \
79+
echo "server.httpPort = 8080" >> /opt/gitblit/etc/system.properties ; \
80+
echo "server.httpsPort = 8443" >> /opt/gitblit/etc/system.properties ; \
81+
echo "server.redirectToHttpsPort = true" >> /opt/gitblit/etc/system.properties ; \
4882
\
4983
# Create a properties file for settings that can be set via environment variables from docker
5084
printf '\
@@ -58,10 +92,14 @@ RUN set -eux ; \
5892
''# Do not define your custom settings in this file. Your overrides or\n\
5993
''# custom settings should be defined in the "gitblit.properties" file.\n\
6094
''#\n\
95+
include = /opt/gitblit/etc/defaults.properties,/opt/gitblit/etc/system.properties\
6196
\n' > $gbetc/gitblit-docker.properties ; \
6297
# Currently RPC is enabled by default
6398
echo "web.enableRpcManagement=true" >> $gbetc/gitblit-docker.properties ; \
6499
echo "web.enableRpcAdministration=true" >> $gbetc/gitblit-docker.properties ; \
100+
sed -i -e 's/^web.enableRpcManagement.*/#web.enableRpcManagement=true/' \
101+
-e 's/^web.enableRpcAdministration.*/#web.enableRpcAdministration=true/' \
102+
$gbetc/defaults.properties ; \
65103
\
66104
# Create the gitblit.properties file that the user can use for customization.
67105
printf '\
@@ -81,7 +119,7 @@ RUN set -eux ; \
81119
''# The present files define the default settings for the docker container. If you\n\
82120
''# remove them or change the order, things may break.\n\
83121
''#\n\
84-
include = defaults.properties,/opt/gitblit/system.properties,gitblit-docker.properties\n\
122+
include = gitblit-docker.properties\n\
85123
\n\
86124
''#\n\
87125
''# Define your overrides or custom settings below\n\

0 commit comments

Comments
 (0)