GitLab Logo

Custom Docker Images

While talking to a client about what languages are being used and how their development process works, we quickly learned that no pre-made docker images would work, and that GitLab's Auto DevOps features were not a good fit for them. Because of this, we created some custom docker images with code-auditing tools they wanted.

  • They needed a way to automatically check for terms that were not allowed to be checked into their codebase and they wanted to be able to audit that code was formatted according to anEditorConfig file, so we came up with this Dockerfile that has grep and editorconfig-checker preinstalled.
    FROM alpine AS base

    RUN apk update && apk add --no-cache sed cppcheck grep jq uuidgen editorconfig-checker curl

    LABEL maintainer="deathcamel57"
  • They wanted to be able to run GNU Complexity to ensure that their code was easily maintainable, so we made sure this container has complexity preinstalled.
    FROM ubuntu AS base

    RUN ln -s /usr/bin/dpkg-split /usr/sbin/dpkg-split
    RUN ln -s /usr/bin/dpkg-deb /usr/sbin/dpkg-deb
    RUN ln -s /bin/rm /usr/sbin/rm
    RUN ln -s /bin/tar /usr/sbin/tar

    RUN apt-get update && apt-get install -y complexity tree jq sed

    LABEL maintainer="deathcamel57"
  • They wanted to have Doxygen automatically generate updated documentation on  every check in, so we went ahead and made another Docker image that had doxygen  preinstalled.
    FROM alpine AS base

    RUN apk update && apk add --no-cache doxygen

    LABEL maintainer="deathcamel57"

Multiple Architectures

Although creating Docker images for other architectures seems difficult, it's honestly one of the easiest parts of this kind of project. This is because Docker has a their Buildx tool.

To use it to produce images, we created a final CI/CD pipeline to build multiple architecture images and push them to our internal registry for their usage.

image: docker:20.10.12

variables:
  BUILDX_VERSION: "0.7.1"
  BUILDX_HOST: "linux"
  BUILDX_ARCH: "arm64"

before_script:
  - wget -O /usr/bin/docker-buildx https://github.com/docker/buildx/releases/download/v${BUILDX_VERSION}/buildx-v${BUILDX_VERSION}.${BUILDX_HOST}-${$BUILDX_ARCH}  - chmod +x /usr/bin/docker-buildx

build:
  tags:
    - no-dind
  stage: build
  script:
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
    - docker-buildx create --use
    - docker-buildx build
      --platform linux/amd64,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x
      --tag ${CI_REGISTRY_IMAGE}:latest
      --push
      .

These containers went on to be used in a GitLab CI/CD pipeline to provide automated code review.

Sugandese LLC is a small tech firm that specializes in custom solutions for your company's problems. We're particularly experienced in cloud infrastructure and self-hosted hyper converged clouds.