├── .dockerignore ├── Dockerfile ├── LICENSE ├── README.md ├── assets ├── config.sh.tmpl ├── env-defaults └── functions └── entrypoint.sh /.dockerignore: -------------------------------------------------------------------------------- 1 | LICENSE 2 | README.md 3 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:edge 2 | MAINTAINER Mark Riedesel 3 | 4 | ENV GITLAB_MIRROR_ASSETS=/assets \ 5 | GITLAB_MIRROR_USER=git \ 6 | GITLAB_MIRROR_HOME=/config \ 7 | GITLAB_MIRROR_INSTALL_DIR=/opt/gitlab-mirror \ 8 | GITLAB_MIRROR_REPO_DIR=/data \ 9 | GITLAB_MIRROR_VERSION=0.6.0 10 | 11 | RUN apk update \ 12 | && apk add bash git gettext git-svn bzr mercurial python2 py-setuptools py2-pip libressl \ 13 | sudo perl-git openssh-client \ 14 | && rm -rf /var/cache/apk/* 15 | 16 | # git-bzr-helper 17 | RUN wget https://raw.github.com/felipec/git-remote-bzr/master/git-remote-bzr -O /usr/local/bin/git-remote-bzr \ 18 | && chmod 755 /usr/local/bin/git-remote-bzr 19 | 20 | # git-hg-helper 21 | RUN wget https://raw.github.com/felipec/git-remote-hg/master/git-remote-hg -O /usr/local/bin/git-remote-hg \ 22 | && chmod 755 /usr/local/bin/git-remote-hg 23 | 24 | # python-gitlab 25 | RUN pip install python-gitlab==1.4 26 | 27 | 28 | WORKDIR / 29 | 30 | # gitlab-mirrors scripts 31 | # Specific release: 32 | RUN mkdir -p "${GITLAB_MIRROR_INSTALL_DIR}" && \ 33 | wget https://github.com/samrocketman/gitlab-mirrors/archive/v${GITLAB_MIRROR_VERSION}.tar.gz -O - | \ 34 | tar xz --strip 1 --directory "${GITLAB_MIRROR_INSTALL_DIR}" 35 | 36 | # - OR - 37 | 38 | # Latest git version 39 | #RUN git clone --depth 1 https://github.com/samrocketman/gitlab-mirrors.git ${GITLAB_MIRROR_INSTALL_DIR} 40 | 41 | RUN echo 'env_keep+=SSH_AUTH_SOCK' >> /etc/visudo 42 | 43 | COPY assets ${GITLAB_MIRROR_ASSETS} 44 | COPY entrypoint.sh /sbin/entrypoint.sh 45 | RUN chmod 755 /sbin/entrypoint.sh 46 | 47 | VOLUME ["${GITLAB_MIRROR_REPO_DIR}", "${GITLAB_MIRROR_HOME}"] 48 | WORKDIR ${GITLAB_MIRROR_HOME} 49 | ENTRYPOINT ["/sbin/entrypoint.sh"] 50 | CMD ["help"] 51 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Mark Riedesel 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Docker Repository on Quay](https://quay.io/repository/klowner/gitlab-mirrors/status "Docker Repository on Quay")](https://quay.io/repository/klowner/gitlab-mirrors) 2 | 3 | # gitlab-mirrors for Docker 4 | 5 | This is [samrocketman/gitlab-mirrors](https://github.com/samrocketman/gitlab-mirrors) packaged inside a Docker container 6 | based on Alpine Linux. 7 | 8 | ## Quick-start 9 | Automated builds are available from [quay.io](https://quay.io) 10 | ```bash 11 | docker pull quay.io/klowner/gitlab-mirrors:latest 12 | ``` 13 | The `/config` volume serves as the `$HOME` for the container's user. A few files are required for this container to work. 14 | - `/config/.ssh/config`: any custom ssh configuration you need when connecting to the GitLab server. (See the ssh/config example further down the page). 15 | - `/config/.ssh/id_rsa`: an SSH private key associated with the GitLab user that will be pushing mirrors 16 | - `/config/private_token`: The private API token for the GitLab user, this can be obtained in your GitLab user profile in the web UI. 17 | - `/config/.bashrc`: *optional* add any pre-init for commands, such as starting `ssh-agent` or adding ssh keys. 18 | 19 | > You can initialize the `/config` volume by running the container with the `config` command. 20 | 21 | Test your configuration to verify that SSH keys and SSH configuration is correct 22 | ```bash 23 | docker run --rm -it \ 24 | -v ${PWD}/config:/config \ 25 | quay.io/klowner/gitlab-mirrors:latest \ 26 | run ssh git.example.com 27 | ``` 28 | 29 | Add a repo to mirror (this example shows mirroring the pcre2 library) 30 | ```bash 31 | docker run --rm -it \ 32 | -v "${PWD}/config:/config" \ 33 | -v "${PWD}/mirrors:/data/mirrors" \ 34 | -e GITLAB_MIRROR_GITLAB_USER=mark \ 35 | -e GITLAB_MIRROR_GITLAB_NAMESPACE=Mirrors \ 36 | -e GITLAB_MIRROR_GITLAB_URL=http://git.example.com \ 37 | -e GITLAB_MIRROR_SVN_OPTIONS='-r500:HEAD -T code/trunk/ -t code/tags/' \ 38 | quay.io/klowner/gitlab-mirrors:latest \ 39 | add --svn --project-name pcre2 --mirror svn://vcs.exim.org/pcre2 40 | ``` 41 | If all goes well, this will mirror `svn://vcs.exim.org/pcre2` to `http://git.example.com/Mirrors/pcre2`. 42 | 43 | I recommend making a short script such as this for running updates, etc. This example also exposes ssh-agent to the container for convenience. 44 | ```bash 45 | # gitlab-mirror.sh 46 | docker run --rm -i \ 47 | -v $(dirname $SSH_AUTH_SOCK):$(dirname $SSH_AUTH_SOCK) \ 48 | -v "${PWD}/config:/config" \ 49 | -v "${PWD}/mirrors:/data/Mirrors" \ 50 | -e SSH_AUTH_SOCK=$SSH_AUTH_SOCK \ 51 | -e GITLAB_MIRROR_UID=$(id -u) \ 52 | -e GITLAB_MIRROR_GITLAB_USER=mark \ 53 | -e GITLAB_MIRROR_GITLAB_NAMESPACE=Mirrors \ 54 | -e GITLAB_MIRROR_GITLAB_URL=http://git.klowner.com \ 55 | quay.io/klowner/gitlab-mirrors:latest ${@:1} 56 | ``` 57 | Then you can 58 | ```bash 59 | ./gitlab-mirror.sh update 60 | ``` 61 | 62 | ## Configuration Options 63 | #### Required parameters 64 | - **GITLAB_MIRROR_GITLAB_NAMESPACE:** GitLab namespace that mirrors will be pushed to (default: `'Mirrors'`) 65 | - **GITLAB_MIRROR_GITLAB_USER:** GitLab username to use for pushing to gitlab (default: `git`) 66 | - **GITLAB_MIRROR_GITLAB_URL:** http(s) URL of the GitLab server you'll be pushing mirrors to 67 | 68 | #### Optional parameters 69 | - **GITLAB_MIRROR_USER:** the system user that gitlab-mirrors will run as inside the container (default: `git`) 70 | - **GITLAB_MIRROR_UID:** the userid to use for the system user above (default: `1000`) 71 | - **GITLAB_MIRROR_HOME:** location of system user's home volume, this contains the gitlab `private_token` and `~/.ssh` (default: `/config`) 72 | - **GITLAB_MIRROR_INSTALL_DIR:** location of [gitlab-mirrors](https://github.com/samrocketman/gitlab-mirrors/) (default: `/opt/gitlab-mirrors`) 73 | - **GITLAB_MIRROR_REPO_DIR:** location of repositories volume, this should be persistent so you can run `update` later (default: `/data`) 74 | - **GITLAB_MIRROR_COLORS:** enable color output (default: true) 75 | - **GITLAB_MIRROR_SVN_OPTIONS:** additional parameters passed to `git-svn` (default: `'-s'`) 76 | - **GITLAB_MIRROR_NO_CREATE_SET:** Force gitlab-mirrors to not create the gitlab remote so a remote URL must be provided. (superceded by no_remote_set) 77 | - **GITLAB_MIRROR_NO_REMOTE_SET:** Force gitlab-mirrors to only allow local remotes only. 78 | - **GITLAB_MIRROR_FORCE_UPDATE:** Enable force fetching and pushing. Will overwrite references if upstream force pushed. Applies to git projects only. 79 | - **GITLAB_MIRROR_PRUNE_MIRRORS:** If a branch is deleted upstream then only that change will propagate into your GitLab mirror. Applies to git projects only (default: `false`) 80 | - **GITLAB_MIRROR_HTTP_REMOTE:** push to GitLab over http? Otherwise will push projects via SSH (default: false) 81 | 82 | #### These options affect the configuration options for new mirror repositories 83 | - **GITLAB_MIRROR_NEW_ISSUES_ENABLED:** (default: false) 84 | - **GITLAB_MIRROR_NEW_WALL_ENABLED:** (default: false) 85 | - **GITLAB_MIRROR_NEW_WIKI_ENABLED:** (default: false) 86 | - **GITLAB_MIRROR_NEW_SNIPPETS_ENABLED:** (default: false) 87 | - **GITLAB_MIRROR_NEW_MERGE_REQUESTS_ENABLED:** (default: false) 88 | - **GITLAB_MIRROR_NEW_PUBLIC:** (default: false) 89 | 90 | 91 | ## Example configuration using docker-compose 92 | Here's an example `docker-compose.yml` to simplify interacting with *docker-gitlab-mirrors*. 93 | ``` 94 | version: '2' 95 | 96 | services: 97 | gitlab-mirrors: 98 | image: quay.io/klowner/gitlab-mirrors:latest 99 | volumes: 100 | - /srv/gitlab-mirrors/config:/config 101 | - /srv/gitlab-mirrors/data:/data 102 | environment: 103 | - GITLAB_MIRROR_UID=1000 104 | - GITLAB_MIRROR_GITLAB_USER=mark 105 | - GITLAB_MIRROR_GITLAB_NAMESPACE=mirrors 106 | - GITLAB_MIRROR_GITLAB_URL=http://gitlab 107 | external_links: 108 | - gitlab:gitlab 109 | networks: 110 | - gitlab_front 111 | 112 | networks: 113 | gitlab_front: 114 | external: 115 | name: gitlab_front 116 | ``` 117 | - My `/config` and `/data` volumes are stored on the docker host's `/srv/gitlab-mirrors` directory. 118 | - The `external_links` specifies the name of my running `gitlab` container, this matches the `GITLAB_MIRROR_GITLAB_URL=http://gitlab`. 119 | - `gitlab_front` is a named Docker network, this is added so the `docker-gitlab-mirrors` container can connect to the `gitlab` container. 120 | 121 | Using the above example, you can run the container via `docker-compose` without the necessity to provide configuration options repeatedly. 122 | 123 | From the directory containing your `docker-compose.yml` 124 | ``` 125 | # docker-compose run --rm gitlab-mirrors 126 | Available options: 127 | mirrors - Update all mirrors 128 | add - Add a new mirror 129 | delete - Delete a mirror 130 | ls - List registered mirrors 131 | update - Update a single mirror 132 | config - Populate the /config volume with ~/.ssh and other things 133 | run - Run an arbitrary command inside the container 134 | ``` 135 | Run some commands! 136 | 137 | ## Example .ssh/config 138 | After running `config` your `/config` volume will be populated with some starter files. You can provide additional configuration settings by customizing the `/config/.ssh/config`. Here's something similar to what I use, you should be able to adapt it to your needs. 139 | ``` 140 | Host gitlab.example.com 141 | Hostname gitlab 142 | User git 143 | ForwardAgent yes 144 | StrictHostKeyChecking no 145 | IdentityFile ~/.ssh/id_rsa_for_mirror_user 146 | ``` 147 | If everything is set up properly, you can use the container's `run` command to try connecting to your gitlab server via ssh. eg. 148 | `docker-compose run --rm gitlab-mirrors run ssh gitlab.example.com` 149 | If all goes well, you should get a `"Welcome to GitLab, !"` repsonse. 150 | -------------------------------------------------------------------------------- /assets/config.sh.tmpl: -------------------------------------------------------------------------------- 1 | #Environment file 2 | 3 | # 4 | # gitlab-mirrors settings 5 | # 6 | 7 | #The user git-mirrors will run as. 8 | system_user="{{GITLAB_MIRROR_USER}}" 9 | #The home directory path of the $system_user 10 | user_home="{{GITLAB_MIRROR_HOME}}" 11 | #The repository directory where gitlab-mirrors will contain copies of mirrored 12 | #repositories before pushing them to gitlab. 13 | repo_dir="{{GITLAB_MIRROR_REPO_DIR}}" 14 | #colorize output of add_mirror.sh, update_mirror.sh, and git-mirrors.sh 15 | #commands. 16 | enable_colors={{GITLAB_MIRROR_COLORS}} 17 | #These are additional options which should be passed to git-svn. On the command 18 | #line type "git help svn" 19 | git_svn_additional_options="{{GITLAB_MIRROR_SVN_OPTIONS}}" 20 | #Force gitlab-mirrors to not create the gitlab remote so a remote URL must be 21 | #provided. (superceded by no_remote_set) 22 | no_create_set={{GITLAB_MIRROR_NO_CREATE_SET}} 23 | #Force gitlab-mirrors to only allow local remotes only. 24 | no_remote_set={{GITLAB_MIRROR_NO_REMOTE_SET}} 25 | #Enable force fetching and pushing. Will overwrite references if upstream 26 | #forced pushed. Applies to git projects only. 27 | force_update={{GITLAB_MIRROR_FORCE_UPDATE}} 28 | #This option is for pruning mirrors. If a branch is deleted upstream then that 29 | #change will propagate into your GitLab mirror. Aplies to git projects only. 30 | prune_mirrors={{GITLAB_MIRROR_PRUNE_MIRRORS}} 31 | 32 | # 33 | # Gitlab settings 34 | # 35 | 36 | #This is the Gitlab group where all project mirrors will be grouped. 37 | gitlab_namespace="{{GITLAB_MIRROR_GITLAB_NAMESPACE}}" 38 | #This is the base web url of your Gitlab server. 39 | gitlab_url="{{GITLAB_MIRROR_GITLAB_URL}}" 40 | #Special user you created in Gitlab whose only purpose is to update mirror sites 41 | #and admin the $gitlab_namespace group. 42 | gitlab_user="{{GITLAB_MIRROR_GITLAB_USER}}" 43 | #Generate a token for your $gitlab_user and set it here. 44 | gitlab_user_token_secret="$(head -n1 "${user_home}/private_token" 2> /dev/null || echo "")" 45 | #Verify signed SSL certificates? 46 | ssl_verify={{GITLAB_MIRROR_SSL_VERIFY}} 47 | #Push to GitLab over http? Otherwise will push projects via SSH. 48 | http_remote={{GITLAB_MIRROR_HTTP_REMOTE}} 49 | 50 | # 51 | # Gitlab new project default settings. If a project needs to be created by 52 | # gitlab-mirrors then it will assign the following values as defaults. 53 | # 54 | 55 | #values must be true or false 56 | issues_enabled={{GITLAB_MIRROR_NEW_ISSUES_ENABLED}} 57 | wall_enabled={{GITLAB_MIRROR_NEW_WALL_ENABLED}} 58 | wiki_enabled={{GITLAB_MIRROR_NEW_WIKI_ENABLED}} 59 | snippets_enabled={{GITLAB_MIRROR_NEW_SNIPPETS_ENABLED}} 60 | merge_requests_enabled={{GITLAB_MIRROR_NEW_MERGE_REQUESTS_ENABLED}} 61 | public={{GITLAB_MIRROR_NEW_PUBLIC}} 62 | -------------------------------------------------------------------------------- /assets/env-defaults: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | GITLAB_MIRROR_USER="${GITLAB_MIRROR_USER:-git}" 4 | GITLAB_MIRROR_UID="${GITLAB_MIRROR_UID:-1000}" 5 | GITLAB_MIRROR_INSTALL_DIR="${GITLAB_MIRROR_INSTALL_DIR:-/opt/gitlab-mirror}" 6 | GITLAB_MIRROR_HOME="${GITLAB_MIRROR_HOME:-/config}" 7 | GITLAB_MIRROR_REPO_DIR="${GITLAB_MIRROR_REPO_DIR:-/data}" 8 | GITLAB_MIRROR_COLORS="${GITLAB_MIRROR_COLORS:-true}" 9 | GITLAB_MIRROR_SVN_OPTIONS="${GITLAB_MIRROR_SVN_OPTIONS:--s}" 10 | GITLAB_MIRROR_NO_CREATE_SET="${GITLAB_MIRROR_NO_CREATE_SET:-false}" 11 | GITLAB_MIRROR_NO_REMOTE_SET="${GITLAB_MIRROR_NO_REMOTE_SET:-false}" 12 | GITLAB_MIRROR_FORCE_UPDATE="${GITLAB_MIRROR_FORCE_UPDATE:-false}" 13 | GITLAB_MIRROR_PRUNE_MIRRORS="${GITLAB_MIRROR_PRUNE_MIRRORS:-false}" 14 | 15 | # Gitlab 16 | GITLAB_MIRROR_GITLAB_NAMESPACE="${GITLAB_MIRROR_GITLAB_NAMESPACE:-Mirrors}" 17 | #GITLAB_MIRROR_GITLAB_URL="${GITLAB_MIRROR_GITLAB_URL:-https://gitlab.example.com}" 18 | GITLAB_MIRROR_GITLAB_USER="${GITLAB_MIRROR_GITLAB_USER:-$GITLAB_MIRROR_USER}" 19 | GITLAB_MIRROR_SSL_VERIFY="${GITLAB_MIRROR_SSL_VERIFY:-true}" 20 | GITLAB_MIRROR_HTTP_REMOTE="${GITLAB_MIRROR_HTTP_REMOTE:-false}" 21 | 22 | GITLAB_MIRROR_NEW_ISSUES_ENABLED="${GITLAB_MIRROR_NEW_ISSUES_ENABLED:-false}" 23 | GITLAB_MIRROR_NEW_WALL_ENABLED="${GITLAB_MIRROR_NEW_WALL_ENABLED:-false}" 24 | GITLAB_MIRROR_NEW_WIKI_ENABLED="${GITLAB_MIRROR_NEW_WIKI_ENABLED:-false}" 25 | GITLAB_MIRROR_NEW_SNIPPETS_ENABLED="${GITLAB_MIRROR_NEW_SNIPPETS_ENABLED:-false}" 26 | GITLAB_MIRROR_NEW_MERGE_REQUESTS_ENABLED="${GITLAB_MIRROR_NEW_MERGE_REQUESTS_ENABLED:-false}" 27 | GITLAB_MIRROR_NEW_PUBLIC="${GITLAB_MIRROR_NEW_PUBLIC:-false}" 28 | -------------------------------------------------------------------------------- /assets/functions: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | source ${GITLAB_MIRROR_ASSETS}/env-defaults 4 | 5 | check_environment() { 6 | if [[ -z $GITLAB_MIRROR_GITLAB_URL ]]; then 7 | echo "GITLAB_MIRROR_GITLAB_URL must be specified" 8 | exit 9 | fi 10 | } 11 | 12 | update_template() { 13 | local FILE=${1?missing argument} 14 | shift 15 | 16 | [[ ! -f ${FILE} ]] && return 1 17 | 18 | local VARIABLES=($@) 19 | local USR=$(stat -c %U ${FILE}) 20 | local tmp_file=$(mktemp) 21 | cp -a "${FILE}" ${tmp_file} 22 | 23 | local variable 24 | for variable in ${VARIABLES[@]}; do 25 | sed -ri "s/[{]{2}$variable[}]{2}/\${$variable}/g" ${tmp_file} 26 | done 27 | 28 | # Replace placeholders 29 | ( 30 | export ${VARIABLES[@]} 31 | local IFS=":"; sudo -HEu ${USR} envsubst "${VARIABLES[*]/#/$}" < ${tmp_file} > ${FILE} 32 | ) 33 | rm -rf ${tmp_file} 34 | } 35 | 36 | install_template() { 37 | local OWNERSHIP=${1} 38 | local SRC=${2} 39 | local DEST=${3} 40 | local MODE=${4:-0644} 41 | 42 | cp "${GITLAB_MIRROR_ASSETS}/${SRC}" "${DEST}" 43 | chmod ${MODE} ${DEST} 44 | chown ${OWNERSHIP} ${DEST} 45 | } 46 | 47 | add_user() { 48 | if [[ "${GITLAB_MIRROR_USER}" != 'root' ]]; then 49 | adduser -D -s /bin/bash -h ${GITLAB_MIRROR_HOME} -u ${GITLAB_MIRROR_UID} ${GITLAB_MIRROR_USER} 50 | fi 51 | } 52 | 53 | exec_as_user() { 54 | if [[ $(whoami) == "${GITLAB_MIRROR_USER}" ]]; then 55 | ${@:1} 56 | else 57 | sudo -HEu ${GITLAB_MIRROR_USER} -- bash -c "source .bashrc; ${*:1}" 58 | fi 59 | } 60 | 61 | fix_home_permissions() { 62 | if [[ "${GITLAB_MIRROR_USER}" != "root" ]]; then 63 | mkdir -p ${GITLAB_MIRROR_HOME}/.ssh 64 | chmod 700 ${GITLAB_MIRROR_HOME}/.ssh 65 | 66 | if [[ ! -f ${GITLAB_MIRROR_HOME}/.bashrc ]]; then 67 | touch ${GITLAB_MIRROR_HOME}/.bashrc 68 | chown ${GITLAB_MIRROR_USER}:${GITLAB_MIRROR_USER} ${GITLAB_MIRROR_HOME}/.bashrc 69 | fi 70 | 71 | chown ${GITLAB_MIRROR_USER} ${GITLAB_MIRROR_HOME} 72 | chown ${GITLAB_MIRROR_USER} ${GITLAB_MIRROR_HOME}/.ssh 73 | chown -R ${GITLAB_MIRROR_USER} ${GITLAB_MIRROR_REPO_DIR} 74 | chown -R ${GITLAB_MIRROR_USER} ${GITLAB_MIRROR_INSTALL_DIR} 75 | fi 76 | } 77 | 78 | configure_gitlab_mirror() { 79 | 80 | update_template "${GITLAB_MIRROR_ASSETS}/config.sh.tmpl" \ 81 | GITLAB_MIRROR_USER \ 82 | GITLAB_MIRROR_HOME \ 83 | GITLAB_MIRROR_REPO_DIR \ 84 | GITLAB_MIRROR_COLORS \ 85 | GITLAB_MIRROR_SVN_OPTIONS \ 86 | GITLAB_MIRROR_NO_CREATE_SET \ 87 | GITLAB_MIRROR_NO_REMOTE_SET \ 88 | GITLAB_MIRROR_FORCE_UPDATE \ 89 | GITLAB_MIRROR_PRUNE_MIRRORS \ 90 | GITLAB_MIRROR_GITLAB_NAMESPACE \ 91 | GITLAB_MIRROR_GITLAB_URL \ 92 | GITLAB_MIRROR_GITLAB_USER \ 93 | GITLAB_MIRROR_SSL_VERIFY \ 94 | GITLAB_MIRROR_HTTP_REMOTE \ 95 | GITLAB_MIRROR_NEW_ISSUES_ENABLED \ 96 | GITLAB_MIRROR_NEW_WALL_ENABLED \ 97 | GITLAB_MIRROR_NEW_WIKI_ENABLED \ 98 | GITLAB_MIRROR_NEW_SNIPPETS_ENABLED \ 99 | GITLAB_MIRROR_NEW_MERGE_REQUESTS_ENABLED \ 100 | GITLAB_MIRROR_NEW_PUBLIC 101 | 102 | install_template ${GITLAB_MIRROR_USER} "config.sh.tmpl" "${GITLAB_MIRROR_INSTALL_DIR}/config.sh" 0755 103 | } 104 | -------------------------------------------------------------------------------- /entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | source ${GITLAB_MIRROR_ASSETS}/functions 5 | 6 | add_user 7 | fix_home_permissions 8 | 9 | case ${1} in 10 | mirrors|add|delete|ls|update|config|run|check-ssh) 11 | check_environment 12 | configure_gitlab_mirror 13 | 14 | case ${1} in 15 | mirrors) 16 | exec_as_user "${GITLAB_MIRROR_INSTALL_DIR}/git-mirrors.sh" ${@:2} 17 | ;; 18 | add) 19 | exec_as_user "${GITLAB_MIRROR_INSTALL_DIR}/add_mirror.sh" ${@:2} 20 | ;; 21 | delete) 22 | exec_as_user "${GITLAB_MIRROR_INSTALL_DIR}/delete_mirror.sh" ${@:2} 23 | ;; 24 | ls) 25 | exec_as_user "${GITLAB_MIRROR_INSTALL_DIR}/ls-mirrors.sh" ${@:2} 26 | ;; 27 | update) 28 | exec_as_user "${GITLAB_MIRROR_INSTALL_DIR}/update_mirror.sh" ${@:2} 29 | ;; 30 | config) 31 | echo "Populated /config volume, please add ssh keys and configuration" 32 | ;; 33 | run) 34 | exec_as_user "${@:2}" 35 | ;; 36 | esac 37 | ;; 38 | help) 39 | echo "Available options:" 40 | echo " mirrors - Update all mirrors" 41 | echo " add - Add a new mirror" 42 | echo " delete - Delete a mirror" 43 | echo " ls - List registered mirrors" 44 | echo " update - Update a single mirror" 45 | echo " config - Populate the /config volume with ~/.ssh and other things" 46 | echo " run - Run an arbitrary command inside the container" 47 | ;; 48 | *) 49 | exec "$@" 50 | ;; 51 | esac 52 | 53 | if [[ -z $1 ]] 54 | then 55 | exec bash 56 | fi 57 | --------------------------------------------------------------------------------