replace makefile with docker-compose (#13)

* replace makefile with docker-compose

* documentation update

* tweak smoketest
This commit is contained in:
Chris Chang 2016-08-02 13:44:44 -05:00 committed by GitHub
parent 63f4ba7be2
commit c0d39da957
4 changed files with 34 additions and 40 deletions

View File

@ -1,20 +0,0 @@
NAME = requestbin
build:
docker build -t $(NAME) .
bash: clean
docker run --rm -it --name $(NAME)_1 $(NAME) /bin/sh
# More env vars
# SESSION_SECRET_KEY
# BUGSNAG_KEY
run: clean
docker run -d --name $(NAME)_redis redis
docker run -d --name $(NAME)_1 \
--link $(NAME)_redis:redis \
-e REDIS_URL=redis://redis:6379/0 \
$(NAME)
clean:
docker rm -f $(NAME)_1 $(NAME)_redis 2>/dev/null && sleep 1 || true

View File

@ -8,14 +8,24 @@ Starts a [requestbin](https://github.com/Runscope/requestbin) server on port
Usage Usage
----- -----
This app is designed to work in conjunction with Redis. There's an example in ### With Docker-Compose
the Makefile that looks like:
If you check out this repository locally or grab the [docker-compose.yml],
you can get a server running on port 8000 quickly with:
docker-compose up
[docker-compose.yml]: https://github.com/crccheck/docker-requestbin/blob/master/docker-compose.yml
### Running a container by hand
If you wanted to run this manually, it would look something like:
docker run -d --name requestbin_redis redis docker run -d --name requestbin_redis redis
docker run -d --name requestbin \ docker run -d --name requestbin \
--link requestbin_redis:redis \ --link requestbin_redis:redis \
-e REDIS_URL=redis://redis:6379/0 \ -e REDIS_URL=redis://redis:6379/0 \
requestbin crccheck/requestbin
Prior Art Prior Art
@ -25,4 +35,4 @@ Prior Art
This image is 1.503 GB, compared to 174 MB for mine. This image is 1.503 GB, compared to 174 MB for mine.
[agaveapi/requestbin](https://registry.hub.docker.com/u/agaveapi/requestbin/): [agaveapi/requestbin](https://registry.hub.docker.com/u/agaveapi/requestbin/):
Not a verified Docker image. very similar to this project now, only uses a fork.

15
docker-compose.yml Normal file
View File

@ -0,0 +1,15 @@
version: '2'
services:
redis:
image: redis
requestbin:
image: crccheck/requestbin
# build: .
depends_on:
- redis
environment:
REDIS_URL: redis://redis:6370/0
# SESSION_SECRET_KEY
# BUGSNAG_KEY
ports:
- "8000:80"

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
container=requestbin_1 container=requestbin_requestbin_1
set -e set -e
@ -7,24 +7,13 @@ function lookfor {
grep --silent "$@" && echo " . . . PASS" || echo " . . . FAIL" grep --silent "$@" && echo " . . . PASS" || echo " . . . FAIL"
} }
make run > /dev/null host=localhost:8000
IP=$(docker inspect --format '{{.NetworkSettings.IPAddress}}' ${container})
# make sure we can start a docker container
if [ -z $IP ]; then
echo "Docker container ${container} not currently running"
exit 1
fi
sleep 1
echo -n "Homepage should load" echo -n "Homepage should load"
\curl --silent --head $IP | lookfor "HTTP/1.1 200 OK" \curl --silent --head ${host} | lookfor "HTTP/1.1 200 OK"
echo -n "CSS styles should load" echo -n "CSS styles should load"
\curl --silent --head $IP/static/css/bootstrap.css | lookfor "Content-Type: text/css" \curl --silent --head ${host}/static/css/bootstrap.css | lookfor "Content-Type: text/css"
echo -n "Static files should load" echo -n "Static files should load"
\curl --silent --head $IP/static/img/logo-2x.png | lookfor "Content-Type: image/png" \curl --silent --head ${host}/static/img/logo-2x.png | lookfor "Content-Type: image/png"
make clean > /dev/null