I really love using Vapor and Consul. So i created a docker container where you can run both easily.

Dockerfile

FROM cpageler93/vapor_consul
 
# add your vapor application
ADD . $APP_PATH
 
# build in release configuration
RUN swift build --configuration release

Build

docker build -t my_vapor_application . 

Run

docker run -p 80:8080 -p 81:8500 -t my_vapor_application

Ports

  • 8080: Your Vapor Application is available on Port 80
  • 8500: Consul is available on Port 81

The default command will run both applications. By overriding the command you can pass parameters to your application.

For example

docker run -p 80:8080 -p 81:8500 -t my_vapor_application --help

will print:

  NAME:

    Vapor Application

  DESCRIPTION:

    Helper Application to start Vapor+Consul Application

  COMMANDS:
        
    help  Display global or [command] help documentation                
    start Starts the application        

  GLOBAL OPTIONS:
        
    -h, --help 
        Display help documentation
        
    -v, --version 
        Display version information
        
    -t, --trace 
        Display backtrace when an error occurs