summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNejc Habjan <nejc.habjan@siemens.com>2022-01-22 02:25:13 +0100
committerNejc Habjan <nejc.habjan@siemens.com>2022-01-22 20:21:40 +0100
commit9aae4ed083ea43b33b674e3f2cdbb60c56cdac07 (patch)
tree787f9d48b0dcfc1461d3205b805e976b8951d61d
parentff049005cc9e5161eddda786e58ed4364639cf02 (diff)
downloadgitlab-feat/docker-slim.tar.gz
feat(docker): provide a Debian-based slim imagefeat/docker-slim
-rw-r--r--.dockerignore4
-rw-r--r--.gitlab-ci.yml26
-rw-r--r--Dockerfile5
-rw-r--r--README.rst26
4 files changed, 46 insertions, 15 deletions
diff --git a/.dockerignore b/.dockerignore
index 204be74..8a5eba4 100644
--- a/.dockerignore
+++ b/.dockerignore
@@ -1,5 +1,9 @@
+.tox/
+.venv/
venv/
dist/
build/
*.egg-info
+.coverage
.github/
+coverage.xml
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index d628e5b..bd96c9d 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -2,26 +2,30 @@ image: python:3.10
stages:
- deploy
- - deploy-latest
+ - promote
-deploy_image:
+deploy-images:
stage: deploy
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
script:
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
- - /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
- only:
- - tags
+ - executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG-alpine
+ - executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG-slim --build-arg PYTHON_FLAVOR=slim
+ rules:
+ - if: $CI_COMMIT_TAG
-deploy-latest:
- stage: deploy-latest
+tag-latest:
+ stage: promote
image:
name: gcr.io/go-containerregistry/crane:debug
entrypoint: [""]
script:
- - mkdir /root/.docker && echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /root/.docker/config.json
- - /ko-app/crane cp $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG $CI_REGISTRY_IMAGE:latest
- only:
- - tags
+ - crane auth login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
+ - crane tag $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG-alpine ${CI_COMMIT_TAG} # /python-gitlab:v1.2.3
+ - crane tag $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG-alpine latest # /python-gitlab:latest
+ - crane tag $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG-alpine alpine # /python-gitlab:alpine
+ - crane tag $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG-slim slim # /python-gitlab:slim
+ rules:
+ - if: $CI_COMMIT_TAG
diff --git a/Dockerfile b/Dockerfile
index 88f2be5..be9d2a9 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,10 +1,11 @@
-FROM python:3.10-alpine AS build
+ARG PYTHON_FLAVOR=alpine
+FROM python:3.10-${PYTHON_FLAVOR} AS build
WORKDIR /opt/python-gitlab
COPY . .
RUN python setup.py bdist_wheel
-FROM python:3.10-alpine
+FROM python:3.10-${PYTHON_FLAVOR}
WORKDIR /opt/python-gitlab
COPY --from=build /opt/python-gitlab/dist dist/
diff --git a/README.rst b/README.rst
index 838943c..ddb5340 100644
--- a/README.rst
+++ b/README.rst
@@ -53,8 +53,24 @@ From GitLab:
$ pip install git+https://gitlab.com/python-gitlab/python-gitlab.git
-Using the docker image
-----------------------
+Using the docker images
+-----------------------
+
+``python-gitlab`` provides Docker images in two flavors, based on the ``-alpine`` and ``-slim``
+python `base images <https://hub.docker.com/_/python>`__. The default tag is alpine, but you
+can explicitly use the alias (see below).
+
+The alpine image is smaller, but you may want to use the Debian-based ``-slim`` tag if you are
+running into issues or need a more complete environment with a bash shell, such as in CI jobs.
+
+The images are published on the GitLab registry, for example:
+
+* ``registry.gitlab.com/python-gitlab/python-gitlab:latest`` (latest, alpine alias)
+* ``registry.gitlab.com/python-gitlab/python-gitlab:alpine`` (latest alpine)
+* ``registry.gitlab.com/python-gitlab/python-gitlab:slim`` (latest slim)
+* ``registry.gitlab.com/python-gitlab/python-gitlab:v3.2.0`` (alpine alias)
+* ``registry.gitlab.com/python-gitlab/python-gitlab:v3.2.0-alpine``
+* ``registry.gitlab.com/python-gitlab/python-gitlab:v3.2.0-slim``
You can run the Docker image directly from the GitLab registry:
@@ -89,6 +105,12 @@ Run your own image:
$ docker run -it --rm -v python-gitlab:latest <command> ...
+Build a slim-based image:
+
+.. code-block:: console
+
+ $ docker build -t python-gitlab:latest --build-arg PYTHON_FLAVOR=slim .
+
Bug reports
-----------