Skip to content

Commit 21d2577

Browse files
committed
more flexible docker
1 parent 77f4d3a commit 21d2577

File tree

4 files changed

+35
-28
lines changed

4 files changed

+35
-28
lines changed

contrib/docker/Dockerfile

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
FROM python:slim
1+
FROM python:alpine
22

3-
# Install python-gitlab
43
RUN pip install --upgrade python-gitlab
54

6-
# Copy sample configuration file
7-
COPY python-gitlab.cfg /
5+
COPY entrypoint-python-gitlab.sh /usr/local/bin/.
86

9-
# Define the entrypoint that enable a configuration file
10-
ENTRYPOINT ["gitlab", "--config-file", "/python-gitlab.cfg"]
7+
WORKDIR /src
8+
9+
ENTRYPOINT ["entrypoint-python-gitlab.sh"]
10+
CMD ["--version"]

contrib/docker/README.rst

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
python-gitlab docker image
22
==========================
33

4-
Dockerfile contributed by *oupala*:
5-
https://github.com/python-gitlab/python-gitlab/issues/295
6-
74
How to build
85
------------
96

10-
``docker build -t me/python-gitlab:VERSION .``
7+
``docker build -t python-gitlab:VERSION .``
118

129
How to use
1310
----------
1411

15-
``docker run -it -v /path/to/python-gitlab.cfg:/python-gitlab.cfg python-gitlab <command> ...``
12+
``docker run -it --rm -e GITLAB_PRIVATE_TOKEN=<your token> =/python-gitlab.cfg python-gitlab <command> ...``
13+
14+
To change the endpoint, add `-e GITLAB_URL=<your url>`
15+
16+
17+
Bring your own config file:
18+
``docker run -it --rm -v /path/to/python-gitlab.cfg:/python-gitlab.cfg -e GITLAB_CFG=/python-gitlab.cfg python-gitlab <command> ...``
1619

17-
To make things easier you can create a shell alias:
1820

19-
``alias gitlab='docker run --rm -it -v /path/to/python-gitlab.cfg:/python-gitlab.cfg python-gitlab``
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/sh
2+
3+
GITLAB_CFG=${GITLAB_CFG:-"/etc/python-gitlab-default.cfg"}
4+
5+
cat << EOF > /etc/python-gitlab-default.cfg
6+
[global]
7+
default = gitlab
8+
ssl_verify = ${GITLAB_SSL_VERIFY:-true}
9+
timeout = ${GITLAB_TIMEOUT:-5}
10+
api_version = ${GITLAB_API_VERSION:-4}
11+
per_page = ${GITLAB_PER_PAGE:-10}
12+
13+
[gitlab]
14+
url = ${GITLAB_URL:-https://gitlab.com}
15+
private_token = ${GITLAB_PRIVATE_TOKEN}
16+
oauth_token = ${GITLAB_OAUTH_TOKEN}
17+
http_username = ${GITLAB_HTTP_USERNAME}
18+
http_password = ${GITLAB_HTTP_PASSWORD}
19+
EOF
20+
21+
exec gitlab --config-file "${GITLAB_CFG}" $@

contrib/docker/python-gitlab.cfg

-15
This file was deleted.

0 commit comments

Comments
 (0)