diff --git a/README.md b/README.md index ae28b95..074fe2f 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![Docker Pulls](https://img.shields.io/docker/pulls/pgollor/gitbucket.svg)](https://hub.docker.com/r/pgollor/gitbucket/) [![](https://images.microbadger.com/badges/image/pgollor/gitbucket:develop.svg)](https://microbadger.com/images/pgollor/gitbucket:develop "Get your own image badge on microbadger.com") [![](https://images.microbadger.com/badges/version/pgollor/gitbucket:develop.svg)](https://microbadger.com/images/pgollor/gitbucket:develop "Get your own version badge on microbadger.com") -![](https://img.shields.io/github/tag-date/gitbucket/gitbucket.svg?label=gitbucket%20latest) +[![](https://img.shields.io/github/tag-date/gitbucket/gitbucket.svg?label=gitbucket%20latest)](https://github.com/gitbucket/gitbucket/releases/latest) This docker container of [gitbucket](https://github.com/gitbucket/gitbucket.git) is in beta state! @@ -58,10 +58,6 @@ ### Configuration Please use the configuration file `gitbucket.conf` for your personal changes. -There are three configs for gitbucket: -- `GITBUCKET_BIND`: ip address to bind to -- `GITBUCKET_WEB_PORT`: web port to bind to -- `GITBUCKET_SSH_PORT`: ssh port to bind to ### Update @@ -86,7 +82,7 @@ #### do update -1. Commit your local changes. Changes in `gitbucket.conf` will be ignored! +1. Commit your local changes. Changes in `gitbucket.conf` will be ignored! Pull changes from repository master via `git pull` or `git merge`. 2. Backup ``` @@ -130,6 +126,7 @@ ``` ./backup.sh backup all ``` +**Plese check if `COMPOSE_PROJECT_NAME` exists in your local `gitbucket.conf`!!!** #### Full Backup via `backup.sh` For backuping the mysql database and the repositories you could use the `backup.sh` script and combine it with a daily cronjob. diff --git a/backup.sh b/backup.sh index 4809798..481044e 100755 --- a/backup.sh +++ b/backup.sh @@ -1,8 +1,11 @@ #!/bin/bash +# get script dir path +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + # backup directory -backupDir=./backup +backupDir="${SCRIPT_DIR}/backup" # current date currentDate=$(date +"%Y-%m-%d_%H-%M-%S") @@ -32,10 +35,16 @@ fi +# get compose project name to backup data from correct container +source ${SCRIPT_DIR}/gitbucket.conf +CMPS_PRJ=$(echo $COMPOSE_PROJECT_NAME | tr -cd "[A-Za-z-_]") +echo "backup files from ${CMPS_PRJ} project" + + function backup() { - IDmain=$(docker ps -qf name=main-gitbucket) - IDdb=$(docker ps -qf name=mysql-gitbucket) + IDmain=$(docker ps -qf name=${CMPS_PRJ}_main-gitbucket) + IDdb=$(docker ps -qf name=${CMPS_PRJ}_mysql-gitbucket) while (( "$#" )); do case "$1" in @@ -109,7 +118,7 @@ exit 1 fi - IDmain=$(docker ps -qf name=main-gitbucket) + IDmain=$(docker ps -qf name=${CMPS_PRJ}_main-gitbucket) echo "restore ssh keys" docker cp "${backupDir}/gitbucket.ser" ${IDmain}:/srv/gitbucket/gitbucket.ser diff --git a/docker-compose.yml b/docker-compose.yml index f02ef95..a5ccfc9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,6 +3,7 @@ services: main-gitbucket: image: pgollor/gitbucket:develop + build: ./docker/ mem_limit: 2g restart: always depends_on: @@ -10,10 +11,11 @@ condition: service_healthy environment: - GITBUCKET_USER_ID=${GITBUCKET_USER_ID:-9000} - - GITBUCKET_DATABASE_HOST=172.22.2.251 + - GITBUCKET_DATABASE_HOST=database - GITBUCKET_DATABASE_NAME=${GITBUCKET_DATABASE_NAME} - GITBUCKET_DATABASE_USER=${GITBUCKET_DATABASE_USER} - GITBUCKET_DATABASE_PASSWORD=${GITBUCKET_DATABASE_PASSWORD} + - GITBUCKET_MAX_FILE_SIZE=${GITBUCKET_MAX_FILE_SIZE:-10485760} - TZ=${TZ} volumes: - ./data/repositories/:/srv/gitbucket/repositories/ @@ -30,7 +32,6 @@ - "${GITBUCKET_SSH_BIND:-127.0.0.1}:${GITBUCKET_SSH_PORT:-29418}:29418" networks: gitbucket-network: - ipv4_address: 172.22.2.250 aliases: - gitbucket @@ -54,9 +55,8 @@ - ./data/conf/mysql:/etc/mysql/conf.d/:ro networks: gitbucket-network: - ipv4_address: 172.22.2.251 aliases: - - mysql + - database networks: gitbucket-network: @@ -64,8 +64,6 @@ enable_ipv6: false ipam: driver: default - config: - - subnet: 172.22.2.0/24 volumes: mysql-vol-1: diff --git a/docker/Dockerfile b/docker/Dockerfile index 2d561cb..e949564 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,14 +1,21 @@ -FROM anapsix/alpine-java:8 +FROM openjdk:8-jre-alpine LABEL maintainer "Pascal Gollor " +ARG VCS_REF + +LABEL org.label-schema.vcs-url="https://gitbucket.pgollor.de/docker/gitbucket" \ + org.label-schema.vcs-ref=$VCS_REF + # ports EXPOSE 29418/tcp EXPOSE 8080/tcp # environment variables +ENV GITBUCKET_USER_ID 9000 ENV GITBUCKET_HOST 0.0.0.0 ENV GITBUCKET_PORT 8080 ENV GITBUCKET_HOME /srv/gitbucket +ENV GITBUCKET_MAX_FILE_SIZE=10485760 # create home RUN mkdir -p $GITBUCKET_HOME @@ -50,4 +57,4 @@ RUN chmod +x /docker-entrypoint.sh ENTRYPOINT ["/docker-entrypoint.sh"] -CMD su-exec gitbucket java -jar $GITBUCKET_HOME/latest.war --host=$GITBUCKET_HOST --port=$GITBUCKET_PORT --gitbucket.home=$GITBUCKET_HOME +CMD su-exec gitbucket java -jar $GITBUCKET_HOME/latest.war --host=$GITBUCKET_HOST --port=$GITBUCKET_PORT --gitbucket.home=$GITBUCKET_HOME --max_file_size=$GITBUCKET_MAX_FILE_SIZE diff --git a/gitbucket.conf.example b/gitbucket.conf.example index ef291bd..eb5378f 100644 --- a/gitbucket.conf.example +++ b/gitbucket.conf.example @@ -15,6 +15,9 @@ # use setUserID.sh GITBUCKET_USER_ID=9000 +# max file size for uploaded files in bytes +GITBUCKET_MAX_FILE_SIZE=10485760 + ## database configuration # mysql root user password @@ -32,3 +35,8 @@ # Timezone one of /usr/share/zoneinfo TZ=Europe/Berlin + + +## compose project name +# this have to be unique for more then one gitbucket instance per docker host +COMPOSE_PROJECT_NAME=gitbucket