summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Donner <hans@hansdonner.nl>2018-09-29 15:54:25 +0200
committerHans Donner <hans@hansdonner.nl>2018-09-29 15:54:25 +0200
commit21d257782bb1aea9d154e797986ed0f6cdd36fad (patch)
treed21b13e9b5174e553912c63d3139b9d985b5e6b4
parent77f4d3af9c1e5f08b8f4e3aa32c7944c9814dab0 (diff)
downloadgitlab-21d257782bb1aea9d154e797986ed0f6cdd36fad.tar.gz
more flexible docker
-rw-r--r--contrib/docker/Dockerfile12
-rw-r--r--contrib/docker/README.rst15
-rwxr-xr-xcontrib/docker/entrypoint-python-gitlab.sh21
-rw-r--r--contrib/docker/python-gitlab.cfg15
4 files changed, 35 insertions, 28 deletions
diff --git a/contrib/docker/Dockerfile b/contrib/docker/Dockerfile
index 6663cac..6812c32 100644
--- a/contrib/docker/Dockerfile
+++ b/contrib/docker/Dockerfile
@@ -1,10 +1,10 @@
-FROM python:slim
+FROM python:alpine
-# Install python-gitlab
RUN pip install --upgrade python-gitlab
-# Copy sample configuration file
-COPY python-gitlab.cfg /
+COPY entrypoint-python-gitlab.sh /usr/local/bin/.
-# Define the entrypoint that enable a configuration file
-ENTRYPOINT ["gitlab", "--config-file", "/python-gitlab.cfg"]
+WORKDIR /src
+
+ENTRYPOINT ["entrypoint-python-gitlab.sh"]
+CMD ["--version"]
diff --git a/contrib/docker/README.rst b/contrib/docker/README.rst
index 90a576c..1627661 100644
--- a/contrib/docker/README.rst
+++ b/contrib/docker/README.rst
@@ -1,19 +1,20 @@
python-gitlab docker image
==========================
-Dockerfile contributed by *oupala*:
-https://github.com/python-gitlab/python-gitlab/issues/295
-
How to build
------------
-``docker build -t me/python-gitlab:VERSION .``
+``docker build -t python-gitlab:VERSION .``
How to use
----------
-``docker run -it -v /path/to/python-gitlab.cfg:/python-gitlab.cfg python-gitlab <command> ...``
+``docker run -it --rm -e GITLAB_PRIVATE_TOKEN=<your token> =/python-gitlab.cfg python-gitlab <command> ...``
+
+To change the endpoint, add `-e GITLAB_URL=<your url>`
+
+
+Bring your own config file:
+``docker run -it --rm -v /path/to/python-gitlab.cfg:/python-gitlab.cfg -e GITLAB_CFG=/python-gitlab.cfg python-gitlab <command> ...``
-To make things easier you can create a shell alias:
-``alias gitlab='docker run --rm -it -v /path/to/python-gitlab.cfg:/python-gitlab.cfg python-gitlab``
diff --git a/contrib/docker/entrypoint-python-gitlab.sh b/contrib/docker/entrypoint-python-gitlab.sh
new file mode 100755
index 0000000..6422ad0
--- /dev/null
+++ b/contrib/docker/entrypoint-python-gitlab.sh
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+GITLAB_CFG=${GITLAB_CFG:-"/etc/python-gitlab-default.cfg"}
+
+cat << EOF > /etc/python-gitlab-default.cfg
+[global]
+default = gitlab
+ssl_verify = ${GITLAB_SSL_VERIFY:-true}
+timeout = ${GITLAB_TIMEOUT:-5}
+api_version = ${GITLAB_API_VERSION:-4}
+per_page = ${GITLAB_PER_PAGE:-10}
+
+[gitlab]
+url = ${GITLAB_URL:-https://gitlab.com}
+private_token = ${GITLAB_PRIVATE_TOKEN}
+oauth_token = ${GITLAB_OAUTH_TOKEN}
+http_username = ${GITLAB_HTTP_USERNAME}
+http_password = ${GITLAB_HTTP_PASSWORD}
+EOF
+
+exec gitlab --config-file "${GITLAB_CFG}" $@
diff --git a/contrib/docker/python-gitlab.cfg b/contrib/docker/python-gitlab.cfg
deleted file mode 100644
index 0e51954..0000000
--- a/contrib/docker/python-gitlab.cfg
+++ /dev/null
@@ -1,15 +0,0 @@
-[global]
-default = somewhere
-ssl_verify = true
-timeout = 5
-api_version = 3
-
-[somewhere]
-url = https://some.whe.re
-private_token = vTbFeqJYCY3sibBP7BZM
-api_version = 4
-
-[elsewhere]
-url = http://else.whe.re:8080
-private_token = CkqsjqcQSFH5FQKDccu4
-timeout = 1