Skip to content

Docker

This guide explains how to use Razorops to build a Docker image and push the image to Docker Registry. You need to add Dockerfile and add build configuration file to automate the process.

Preparing source files

You'll need some sample source code to build. In this section, you'll create a simple Hello World example and a Dockerfile.

  1. Create a file named quickstart.sh with the following content:

    #!/bin/sh
    echo "Hello, world! The time is $(date)."
    

    Afterward, you can make it executable by running chmod +x quickstart.sh in the shell.

  2. Create a file named Dockerfile with the following contents:

    FROM alpine
    COPY quickstart.sh /
    CMD ["/quickstart.sh"]
    
  3. Write Razorops YAML file

    In the same directory that contains above files, create .razorops.yaml file with the following content:

    tasks:
      build-image:
        steps:
        - checkout
        - docker/build:
            image: quay.io/docker/quickstart  ## Name of docker image with registry
            push: true
    

    This config instructs Razorops to perform tasks based on your specifications.

Commit changes

Now add Dockerfile, quickstart.sh and .razorops.yaml into git and push a commit to your Git provider, and you should be able to see a new workflow which builds you docker image and finally push to quay.io Docker registry.