Skip to content

Tools for building and distributing http_stub Docker containers

License

Notifications You must be signed in to change notification settings

dueckes/http_stub_docker

 
 

Repository files navigation

http_stub_docker

Rake tasks for building, verifying and distributing Docker containers hosting http_stub servers.

Status

Build Status Gem Version Code Climate

What Does It Do?

Provides rake tasks that:

  • Create standard Docker files for http_stub servers
  • Build, start, stop and connect to http_stub server Docker containers
  • Verify that the container is running correctly
  • Deploy the container to AWS ECR

Requirements

  • Ruby >= 2.3
  • Docker >= 17.06

How Do I Use It?

  1. In your Gemfile: gem 'http_stub_docker'

  2. In your Rakefile:

    require 'http_stub_docker/rake/task_generator'
    
    HttpStubDocker::Rake::TaskGenerator.new(
      stub_configurator: My::Configurator,
      stub_name:         :my_stub,
      stub_dir:          File.expand_path("..", __FILE__),
      port:              5005,                             # Optional: overrides default of 5000, also configurable via PORT environment variable
      external_base_uri: "http://some-host:5005",          # Optional: overrides default of http://localhost:<port>
      publish_tags:      %w{ 1.0.0 }                       # Optional: only required for ECR deployment
    )
  3. Use the generated Rake tasks:

    $ rake -T
    rake docker:build                  # Builds the image
    rake docker:clobber                # Removes created Dockerfile and other resources
    rake docker:commit                 # Ensures container runs
    rake docker:connect                # Connects to a running container
    rake docker:publish                # Publishes the container
    rake docker:setup                  # Creates Dockerfile and other resources in stub directory
    rake docker:start                  # Starts a container
    rake docker:stop                   # Stops all containers
    rake docker:test                   # Verifies container is running
    rake stub_server:restart           # Restart an potentially running stub_server
    rake stub_server:start             # Start a stub_server as a background process
    rake stub_server:start:foreground  # Start stub stub_server in the foreground
    rake stub_server:status            # Display the status of a stub_server process
    rake stub_server:stop              # Stop a running stub_server
    
  4. To publish to AWS ECR:

    • Ensure the AWS CLI is installed
    • Establish the following environment variables: AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_ID and AWS_REGION
    • Ensure the AWS user has write access to ECR
    • Run docker:publish task

Recommendations

In your Rakefile:

task default: %w{ docker:setup docker:commit docker:publish }

Acknowledgements

Thanks to Ryan Davis for his contributions on publishing to ECR.

About

Tools for building and distributing http_stub Docker containers

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 86.0%
  • Shell 10.2%
  • HTML 3.0%
  • HCL 0.8%