Skip to content

Latest commit

 

History

History
100 lines (68 loc) · 2.4 KB

README.md

File metadata and controls

100 lines (68 loc) · 2.4 KB

Using Couper with Docker

Introduction

Couper is also available as docker image from Docker Hub.

Running the Couper container requires a working Docker setup on your computer. Please visit the get started guide to get prepared.

Usage

To download the latest Couper image run:

docker pull coupergateway/couper

Couper needs a configuration file to know what to do. Create an empty couper.hcl file.

Copy/paste the following configuration to the file and save it:

server {
	endpoint "/**" {
        response {
            body = "Hello World!"
        }
    }
}

Then start the Couper container:

docker run --rm -p 8080:8080 -v "$(pwd)":/conf coupergateway/couper

Now Couper is serving on your computer's port 8080:

{"level":"info","message":"couper is serving: 0.0.0.0:8080","timestamp":"2022-01-03T04:20:00+01:00","type":"couper_daemon"}

Point your browser to http://localhost:8080/ or use curl to see what's going on.

You can press CTRL + c to stop the running Couper container.

Additional links

Build

To be able to add custom resources which could be served from Couper like files or a SPA you can create your own Dockerfile which inherits from the official Couper Image.

First we can create some content and place this into a new folder called htdocs. We have used a simple html-file here.

Next to our htdocs folder we will create a simple couper.hcl and insert a reference to htodcs.

server {
  files {
    # we will copy this folder to this location in the next step
    document_root = "/htdocs"
  }
}

Create a file named Dockerfile and insert the following content:

FROM coupergateway/couper

COPY htdocs/ /htdocs/
COPY couper.hcl /conf/

Now we can build and run our custom Couper image:

docker build --pull --output=type=docker -t my-couper .

Start our image named my-couper:

docker run --rm -p 8080:8080 my-couper

and visit http://localhost:8080/.

The complete Setup can be found here.