Using official rust docker image

Build application

pipeline:
  build:
    image: rust:1.30.0
    commands:
      - cargo build --release

Build application with environment

pipeline:
  build:
    image: rust:1.30.0
    environment:
      # https://doc.rust-lang.org/cargo/reference/environment-variables.html
      - RUSTFLAGS=
    commands:
      - cargo build --release

Run tests

pipeline:
  test:
    image: rust:1.30.0
    commands:
      - cargo test

Run linter

pipeline:
  lint:
    image: rust:1.30.0
    commands:
      - rustup component add rustfmt-preview
      - cargo fmt

Read more how to use this image on docker docs