Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker: upgrade docker-compose setup #46

Merged
merged 1 commit into from
Sep 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions Dockerfile

This file was deleted.

17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- [Deprecation of Legacy Ratelimit Proto](#deprecation-of-legacy-ratelimit-proto)
- [Deprecation Schedule](#deprecation-schedule)
- [Building and Testing](#building-and-testing)
- [Docker-compose setup](#docker-compose-setup)
- [Configuration](#configuration)
- [The configuration format](#the-configuration-format)
- [Definitions](#definitions)
Expand Down Expand Up @@ -90,6 +91,22 @@ go [here](https://golang.org/doc/install).
USE_STATSD=false LOG_LEVEL=debug REDIS_SOCKET_TYPE=tcp REDIS_URL=localhost:6379 RUNTIME_ROOT=/home/user/src/runtime/data RUNTIME_SUBDIRECTORY=ratelimit
```

## Docker-compose setup

The docker-compose setup has three containers: redis, ratelimit-build, and ratelimit. In order to run the docker-compose setup from the root of the repo, run

```bash
glide install
docker-compose up
```

The ratelimit-build container will build the ratelimit binary. Then via a shared volume the binary will be shared with the ratelimit container. This dual container setup is used in order to use a
a minimal container to run the application, rather than the heftier container used to build it.

If you want to run with [two redis instances](#two-redis-instances), you will need to modify
the docker-compose.yaml file to run a second redis container, and change the environment variables
as explained in the [two redis instances](#two-redis-instances) section.

# Configuration

## The configuration format
Expand Down
31 changes: 18 additions & 13 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,33 @@ services:
expose:
- 6379
ports:
- "6379:6379"
- 6379:6379
networks:
- data
- ratelimit-network

# minimal container that builds the ratelimit service binary and exits.
ratelimit-build:
image: golang:1.10-alpine
working_dir: /go/src/github.com/lyft/ratelimit
command: go build -o /usr/local/bin/ratelimit /go/src/github.com/lyft/ratelimit/src/service_cmd/main.go
volumes:
- redis-data:/data
- .:/go/src/github.com/lyft/ratelimit
- binary:/usr/local/bin/

ratelimit:
build:
context: ./
dockerfile: Dockerfile
image: alpine:3.6
command: /usr/local/bin/ratelimit
ports:
- 8080:8080
- 6070:6070
depends_on:
- redis
- ratelimit-build
networks:
- data
links:
- redis
- ratelimit-network
volumes:
- ./examples:/data/
- binary:/usr/local/bin/
- ./examples:/data
environment:
- USE_STATSD=false
- LOG_LEVEL=debug
Expand All @@ -36,8 +42,7 @@ services:
- RUNTIME_SUBDIRECTORY=ratelimit

networks:
data:
ratelimit-network:

volumes:
redis-data:
ratelimit-data:
binary: