Rake tasks for building, verifying and distributing Docker containers hosting http_stub servers.
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
- Ruby >= 2.3
- Docker >= 17.06
-
In your
Gemfile
:gem 'http_stub_docker'
-
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 )
-
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
-
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
andAWS_REGION
- Ensure the AWS user has write access to ECR
- Run
docker:publish
task
In your Rakefile
:
task default: %w{ docker:setup docker:commit docker:publish }
Thanks to Ryan Davis for his contributions on publishing to ECR.