Skip to content

Commit 304798c

Browse files
committed
Enable shutdown with gitblit-stop.shcommand.
Clean up by deleting not needed scripts for service start. For Alpine, change `/bin/bash` to `/bin/sh` so that the scripts can run. Add `/opt/gitblit` to the path. Together with the `WORKDIR` this enables calling scripts in `/opt/giblit` in a `docker exec` command. Alas, not every script does work with Alpine's shell.
1 parent 2b7c2b0 commit 304798c

File tree

4 files changed

+42
-9
lines changed

4 files changed

+42
-9
lines changed

Dockerfile

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ ENV GITBLIT_VERSION 1.9.0
44
ENV GITBLIT_DOWNLOAD_SHA 349302ded75edfed98f498576861210c0fe205a8721a254be65cdc3d8cdd76f1
55

66
LABEL maintainer="James Moger <james.moger@gitblit.com>, Florian Zschocke <f.zschocke+gitblit@gmail.com>" \
7-
author="Bala Raman <srbala [at] gmail.com>" \
87
org.label-schema.schema-version="1.0" \
98
org.label-schema.version="${GITBLIT_VERSION}"
109

@@ -25,7 +24,8 @@ RUN set -eux ; \
2524

2625

2726
# Move the data files to a separate directory and set some defaults
28-
RUN mv /opt/gitblit/data /opt/gitblit-data ; \
27+
RUN set -eux ; \
28+
mv /opt/gitblit/data /opt/gitblit-data ; \
2929
ln -s /opt/gitblit-data /opt/gitblit/data ; \
3030
# Create a system.properties file that sets the defaults for this docker setup.
3131
echo "server.httpPort=8080" >> /opt/gitblit/system.properties ; \
@@ -70,10 +70,16 @@ include = defaults.properties,/opt/gitblit/system.properties,gitblit-docker.prop
7070
''#\n\
7171
''# Define your overrides or custom settings below\n\
7272
''#\n\
73-
\n' > /opt/gitblit-data/gitblit.properties
73+
\n' > /opt/gitblit-data/gitblit.properties ; \
74+
\
75+
# Remove unneeded scripts.
76+
rm -f /opt/gitblit/install-service-*.sh ; \
77+
rm -r /opt/gitblit/service-*.sh ;
7478

7579

7680
# Setup the Docker container environment
81+
ENV PATH /opt/gitblit:$PATH
82+
7783
WORKDIR /opt/gitblit
7884

7985
EXPOSE 8080 8443 9418 29418

Dockerfile.alpine

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ ENV GITBLIT_VERSION 1.9.0
44
ENV GITBLIT_DOWNLOAD_SHA 349302ded75edfed98f498576861210c0fe205a8721a254be65cdc3d8cdd76f1
55

66
LABEL maintainer="James Moger <james.moger@gitblit.com>, Florian Zschocke <f.zschocke+gitblit@gmail.com>" \
7-
author="Bala Raman <srbala [at] gmail.com>" \
87
org.label-schema.schema-version="1.0" \
98
org.label-schema.version="${GITBLIT_VERSION}"
109

@@ -25,7 +24,8 @@ RUN set -eux; \
2524

2625

2726
# Move the data files to a separate directory and set some defaults
28-
RUN mv /opt/gitblit/data /opt/gitblit-data ; \
27+
RUN set -eux ; \
28+
mv /opt/gitblit/data /opt/gitblit-data ; \
2929
ln -s /opt/gitblit-data /opt/gitblit/data ; \
3030
# Create a system.properties file that sets the defaults for this docker setup.
3131
echo "server.httpPort=8080" >> /opt/gitblit/system.properties ; \
@@ -70,10 +70,23 @@ include = defaults.properties,/opt/gitblit/system.properties,gitblit-docker.prop
7070
''#\n\
7171
''# Define your overrides or custom settings below\n\
7272
''#\n\
73-
\n' > /opt/gitblit-data/gitblit.properties
73+
\n' > /opt/gitblit-data/gitblit.properties ; \
74+
\
75+
# Remove unneeded scripts.
76+
rm -f /opt/gitblit/install-service-*.sh ; \
77+
rm -r /opt/gitblit/service-*.sh ;
78+
79+
80+
# Change shell to 'sh' for Alpine
81+
RUN set -eux ; \
82+
for file in /opt/gitblit/*.sh ; do \
83+
sed -i -e 's;bin/bash;bin/sh;' $file ; \
84+
done
7485

7586

7687
# Setup the Docker container environment
88+
ENV PATH /opt/gitblit:$PATH
89+
7790
WORKDIR /opt/gitblit
7891

7992
EXPOSE 8080 8443 9418 29418

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ The followings commands should retrieve and execute the Gitblit image and launch
1616

1717
You should be able to browse to http://localhost:8080 or https://localhost:8443 and login as `admin/admin`.
1818

19-
You can stop your container with:
19+
You can shutdown your gitblit container with:
2020
```
21-
sudo docker stop gitblit
21+
sudo docker exec -it gitblit gitblit-stop.sh
2222
```
2323

24-
You can manually start your container with:
24+
You can manually re-start your container with:
2525
```
2626
sudo docker start gitblit
2727
```

hub-readme.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,20 @@ You can select which transports you want to make available from the container. F
3232
sudo docker run -d --name gitblit -p 8443:8443 -p 29418:29418 gitblit/gitblit:rpc
3333
```
3434

35+
### Stop the container
36+
37+
Gitblit can be shut down cleanly with the `gitblit-stop.h` script.
38+
39+
```console
40+
sudo docker exec -it gitblit gitblit-stop.sh
41+
```
42+
43+
You can also stop the container with a normal stop command.
44+
45+
```console
46+
sudo docker stop gitblit
47+
```
48+
3549

3650
# Image Variants
3751
The `gitblit/gitblit` images come in multiple flavors, each designed for a specific use case.

0 commit comments

Comments
 (0)