Skip to content

razorops-public/ruby-docker-compose-demo

Repository files navigation

Razorops CI/CD pipeline demo with Docker-compose

If you have forked this repo, then connect with Razorops to create your demo pipeline by following the below button

Connect

This is an example code to demonstrate how to create Docker-Compose based pipeline on Razorops.

It's a Ruby based implementation of TodoBackend Spec, which implements the API using Sinatra framework.

Local Setup

  1. Use bundle to install the dependencies -

     bundle install
    
  2. Migrate the database

     export DATABASE_URL=postgres://<user>:<password>/<host>/<database> # replace accordingly
     bundle exec rake nuke_db
    

You can use sqlite, mysql or any sequel compatible database.

  1. To start the server in development mode run -

     export DATABASE_URL=postgres://..
     bundle exec rake server
    

Execute tests

Run following commands to execute the rspec suite -

    bundle exec rspec

To turn on coverage reports -

    COVERAGE=true bundle exec rspec

Using Docker-compose

Use can also use Docker-Compose based setup to bootstrap the project easily -

    docker-compose build
    docker-compose up -d
    docker-compose exec -T web rake nuke_db

To execute the tests -

    docker-compose exec -T web bundle exec rspec

CI/CD pipeline

If you're new to Razorops, feel free to fork this repository and use it to create a project.

.razorops.yaml contains the pipeline code to build and execute the tests for this project. To know more about how to write and customize, refer to the documentation.

It uses Docker-Compose commands to bootstrap the containers and exec into web container to run the tests. Here is the link of the pipeline workflows page.

License

Copyright (c) 2021 Razorops LLC

Distributed under the MIT License. See the file LICENSE.md.