Skip to content

Commit c0a1032

Browse files
committed
Provide a script to migrate configuration data to the new layout.
With the image for version 1.9.0 the directory layout changed, as well as how some properties are set for defaults and the docker image setup. If a previous container was run with a volume attached, then the old layout and data should be migrated to the new layout and container configuration. This can be done with the provided `migrate-data` script.
1 parent 61ddce6 commit c0a1032

File tree

7 files changed

+2317
-14
lines changed

7 files changed

+2317
-14
lines changed

Dockerfile

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
11
FROM openjdk:8-jre-slim
22

3-
ENV GITBLIT_VERSION 1.9.0
4-
ENV GITBLIT_DOWNLOAD_SHA 349302ded75edfed98f498576861210c0fe205a8721a254be65cdc3d8cdd76f1
5-
63
# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever packages get added
74
RUN groupadd -r -g 8117 gitblit && useradd -r -M -g gitblit -u 8117 -d /opt/gitblit gitblit
85

96

10-
LABEL maintainer="James Moger <james.moger@gitblit.com>, Florian Zschocke <f.zschocke+gitblit@gmail.com>" \
11-
org.label-schema.schema-version="1.0" \
12-
org.label-schema.version="${GITBLIT_VERSION}"
13-
7+
ENV GITBLIT_VERSION 1.9.0
8+
ENV GITBLIT_DOWNLOAD_SHA 349302ded75edfed98f498576861210c0fe205a8721a254be65cdc3d8cdd76f1
149

1510
ENV GITBLIT_DOWNLOAD_URL https://github.com/gitblit/gitblit/releases/download/v${GITBLIT_VERSION}/gitblit-${GITBLIT_VERSION}.tar.gz
1611

@@ -38,6 +33,14 @@ RUN set -eux ; \
3833

3934

4035

36+
LABEL maintainer="James Moger <james.moger@gitblit.com>, Florian Zschocke <f.zschocke+gitblit@gmail.com>" \
37+
org.label-schema.schema-version="1.0" \
38+
org.label-schema.name="gitblit" \
39+
org.label-schema.description="Gitblit is an open-source, pure Java stack for managing, viewing, and serving Git repositories." \
40+
org.label-schema.url="http://gitblit.com" \
41+
org.label-schema.version="${GITBLIT_VERSION}"
42+
43+
4144
ENV GITBLIT_VAR /var/opt/gitblit
4245

4346
# Move the data files to a separate directory and set some defaults
@@ -108,6 +111,8 @@ s/^server.redirectToHttpsPort.*/#server.redirectToHttpsPort = true/\n\
108111
''# Do not define your custom settings in this file. Your overrides or\n\
109112
''# custom settings should be defined in the "gitblit.properties" file.\n\
110113
''#\n\
114+
''# Do NOT change this include line. It makes sure that settings for this docker image are set.\n\
115+
''#\n\
111116
include = /opt/gitblit/etc/defaults.properties,/opt/gitblit/etc/system.properties\n\
112117
\n' > $gbetc/gitblit-docker.properties ; \
113118
\
@@ -160,6 +165,10 @@ include = gitblit-docker.properties\n\
160165

161166

162167

168+
# Provide script and data to migrate from earlier images to the new layout.
169+
COPY migrate/migrate-data /usr/local/bin/
170+
COPY migrate/non-etc-files migrate/defaults.* /usr/local/share/gitblit/
171+
163172

164173
# Setup the Docker container environment
165174
ARG GITBLIT_RPC

Dockerfile.alpine

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
11
FROM openjdk:8-jre-alpine
22

3-
ENV GITBLIT_VERSION 1.9.0
4-
ENV GITBLIT_DOWNLOAD_SHA 349302ded75edfed98f498576861210c0fe205a8721a254be65cdc3d8cdd76f1
5-
63
# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever packages get added
74
RUN addgroup -S -g 8117 gitblit && adduser -S -H -G gitblit -u 8117 -h /opt/gitblit gitblit
85

96

10-
LABEL maintainer="James Moger <james.moger@gitblit.com>, Florian Zschocke <f.zschocke+gitblit@gmail.com>" \
11-
org.label-schema.schema-version="1.0" \
12-
org.label-schema.version="${GITBLIT_VERSION}"
13-
7+
ENV GITBLIT_VERSION 1.9.0
8+
ENV GITBLIT_DOWNLOAD_SHA 349302ded75edfed98f498576861210c0fe205a8721a254be65cdc3d8cdd76f1
149

1510
ENV GITBLIT_DOWNLOAD_URL https://github.com/gitblit/gitblit/releases/download/v${GITBLIT_VERSION}/gitblit-${GITBLIT_VERSION}.tar.gz
1611

@@ -38,6 +33,14 @@ RUN set -eux; \
3833

3934

4035

36+
LABEL maintainer="James Moger <james.moger@gitblit.com>, Florian Zschocke <f.zschocke+gitblit@gmail.com>" \
37+
org.label-schema.schema-version="1.0" \
38+
org.label-schema.name="gitblit" \
39+
org.label-schema.description="Gitblit is an open-source, pure Java stack for managing, viewing, and serving Git repositories." \
40+
org.label-schema.url="http://gitblit.com" \
41+
org.label-schema.version="${GITBLIT_VERSION}"
42+
43+
4144
ENV GITBLIT_VAR /var/opt/gitblit
4245

4346
# Move the data files to a separate directory and set some defaults
@@ -108,6 +111,8 @@ s/^server.redirectToHttpsPort.*/#server.redirectToHttpsPort = true/\n\
108111
''# Do not define your custom settings in this file. Your overrides or\n\
109112
''# custom settings should be defined in the "gitblit.properties" file.\n\
110113
''#\n\
114+
''# Do NOT change this include line. It makes sure that settings for this docker image are set.\n\
115+
''#\n\
111116
include = /opt/gitblit/etc/defaults.properties,/opt/gitblit/etc/system.properties\n\
112117
\n' > $gbetc/gitblit-docker.properties ; \
113118
\
@@ -160,6 +165,10 @@ include = gitblit-docker.properties\n\
160165

161166

162167

168+
# Provide script and data to migrate from earlier images to the new layout.
169+
COPY migrate/migrate-data /usr/local/bin/
170+
COPY migrate/non-etc-files migrate/defaults.* /usr/local/share/gitblit/
171+
163172

164173
# Setup the Docker container environment
165174
ARG GITBLIT_RPC

README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,41 @@ sudo docker build -t my-gitblit .
6767
sudo docker run -d --name gitblit -p 8443:8443 -p 8080:8080 -p 9418:9418 -p 29418:29418 my-gitblit
6868
```
6969

70+
71+
## Migrating from an older image
72+
73+
The directory layout for the Gitblit data was changed with the image for version 1.9.0. If you had previously used a Docker image of Gitblit with a volume mounted on `/opt/gitblit-data`, migration of the configuration data is advised. A script `migrate-data` is available in the new image for this. Run the script from a container with your volume mounted under `/var/opt/gitblit`.
74+
75+
```console
76+
$ ls -l
77+
total 0
78+
drwxr-xr-x 6 beowulf staff 192 Mar 10 21:02 gitblit-data/
79+
80+
$ sudo docker run -it --rm -v $PWD/gitblit-data:/var/opt/gitblit my-gitblit migrate-data
81+
82+
Creating new directories 'etc' and 'srv' ...
83+
Moving existing files to new directories ...
84+
Moving to folder 'etc': certs
85+
Moving to folder 'etc': defaults.properties
86+
Moving to folder 'srv': git
87+
Moving to folder 'etc': gitblit.properties
88+
Moving to folder 'etc': gitignore
89+
Moving to folder 'etc': groovy
90+
Moving to folder 'srv': lfs
91+
Moving to folder 'etc': plugins
92+
Moving to folder 'etc': projects.conf
93+
Moving to folder 'etc': serverKeyStore.jks
94+
Moving to folder 'etc': serverTrustStore.jks
95+
Moving to folder 'etc': ssh-dsa-hostkey.pem
96+
Moving to folder 'etc': ssh-rsa-hostkey.pem
97+
Moving to folder 'etc': users.conf
98+
Adjusting 'include' setting in etc/gitblit.properties
99+
Checking the defaults.properties file for changes.
100+
There were changes detected in the defaults.properties file.
101+
These have been copied over into the gitblit.properties file.
102+
Please review these and adjust as required.
103+
The defaults.properties file should not be changed as it gets overwritten upon upgrade.
104+
Done.
105+
106+
$ sudo docker run -d --name gitblit -v $PWD/gitblit-data:/var/opt/gitblit -p 8080:8080 my-gitblit
107+
```

hub-readme.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,61 @@ uid=8117(gitblit) gid=8117(gitblit) groups=8117(gitblit)
233233
```
234234

235235

236+
# Caveats
237+
238+
## Migrating from an older image version
239+
240+
The directory layout for the Gitblit data was changed in the official `gitblit/gitblit` image for version 1.9.0. If you had previously used a Docker image of Gitblit with a volume mounted on `/opt/gitblit-data`, migration of the configuration data is advised. This will make updates easier in the future. A script `migrate-data` is available in the current image for this. Run the script from a container with your volume mounted under `/var/opt/gitblit`.
241+
242+
Below is an example for a container that had the local directory `gitblit-data` as a bind mount.
243+
244+
245+
```console
246+
$ sudo docker pull gitblit/gitblit
247+
248+
$ sudo docker stop gitblit
249+
250+
$ ls -l
251+
total 0
252+
drwxr-xr-x 6 beowulf staff 192 Mar 10 21:02 gitblit-data/
253+
254+
$ sudo docker run -it --rm -v $PWD/gitblit-data:/var/opt/gitblit gitblit/gitblit migrate-data
255+
256+
Creating new directories 'etc' and 'srv' ...
257+
Moving existing files to new directories ...
258+
Moving to folder 'etc': certs
259+
Moving to folder 'etc': defaults.properties
260+
Moving to folder 'srv': git
261+
Moving to folder 'etc': gitblit.properties
262+
Moving to folder 'etc': gitignore
263+
Moving to folder 'etc': groovy
264+
Moving to folder 'srv': lfs
265+
Moving to folder 'etc': plugins
266+
Moving to folder 'etc': projects.conf
267+
Moving to folder 'etc': serverKeyStore.jks
268+
Moving to folder 'etc': serverTrustStore.jks
269+
Moving to folder 'etc': ssh-dsa-hostkey.pem
270+
Moving to folder 'etc': ssh-rsa-hostkey.pem
271+
Moving to folder 'etc': users.conf
272+
Adjusting 'include' setting in etc/gitblit.properties
273+
Checking the defaults.properties file for changes.
274+
There were changes detected in the defaults.properties file.
275+
These have been copied over into the gitblit.properties file.
276+
Please review these and adjust as required.
277+
The defaults.properties file should not be changed as it gets overwritten upon upgrade.
278+
Done.
279+
280+
$ sudo docker run -d --name gitblit -v $PWD/gitblit-data:/var/opt/gitblit -p 8080:8080 giblit/gitblit
281+
```
282+
283+
Cou could, alternatively, also run a container with the existing data directory without migration. Be advised, that in this case you will need to make sure that you have paths for temp and git folders in your `gitblit.properties` file. Also, **do not** have any custom settings in the `defaults.properties` file as this file will get **overwritten**.
284+
Mount your not migrated volume under `/var/opt/gitblit/etc` which is the default for the `baseFolder`, or provide the path to where you mount the volume to the container in the `--baseFolder` parameter when running the container.
285+
286+
```console
287+
$ sudo docker run -v /some/path/data:/opt/gitblit-data gitblit/gitblit --baseFolder /opt/gitblit-data
288+
```
289+
290+
236291

237292
# Image Variants
238293
The `gitblit/gitblit` images come in multiple flavors.

0 commit comments

Comments
 (0)