Container build

We use our own installation of GitLab for Source Code Management, Continuous Integration automation, docker containers registry and other development lifecycle tasks. It fully uses Nautilus Cluster resources, which provides our users unlimited storage and fast builds. All data from our GitLab except container images are backed up nightly to Google S3.

Step 1: Create a Git repo
  1. To use our GItLab installation, register at https://gitlab.nautilus.optiputer.net
  2. Use GitLab for storing your code like any git repository. Here’s GitLab basics guide.
  3. create a new project in your GitLab account
Step 2: Use Containers Registry

What makes GitLab especially useful for kubernetes cluster in integration with Docker Registry. You can store your containers directly in our cluster and avoid slow downloads from DockerHub (although you’re still free to do that as well). To use containers registry:

  1. go to your project’s general settings and enable the Container Registry. See this instructions Container Registry. (It’s enabled by default for all projects in our GitLab)
Step 3: Continuous Integration automation

To fully unleash the GitLab powers, introduce yourself to Continuous Integration automation

  1. create the .gitlab-ci.yml file in your project, see Quick start guide. The runners are already configured.
    There’s a list of CI templates available for most common languages.
  2. If you need to build your Dockerfile and create a container from it, adjust this .gitlab-ci.yml template:

    image: gcr.io/kaniko-project/executor:debug
       
    stages:
      - build-and-push
       
    build-and-push-job:
      stage: build-and-push
      script:
        - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
        - /kaniko/executor --cache=true --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:${CI_COMMIT_SHA:0:8} --destination $CI_REGISTRY_IMAGE:latest
    

    More advanced example

  3. Go to CI / CD -> Jobs tab to see in amazement your job running and image being uploaded to your registry.
  4. From the Packages -> Containers Registry tab get the URL of your image to be included in your pod definition:

    spec:
      containers:
      - name: my-container
        image: gitlab-registry.nautilus.optiputer.net/<your_group>/<your_project>:<optional_tag>
    
Build better containers

Make yourself familiar with Docker containers best practices

Use multi-stage builds when necessary