From c05edb1f5dccdbf46bc25976e3e6377c692be1db Mon Sep 17 00:00:00 2001 From: avishayp Date: Tue, 23 Oct 2018 01:05:27 +0300 Subject: [PATCH] Dockerized tests --- .dockerignore | 7 +++++-- Dockerfile | 17 ++++++++++++----- docker-compose.yml | 13 +++++++++++-- requirements.txt | 8 ++++++++ 4 files changed, 36 insertions(+), 9 deletions(-) create mode 100644 requirements.txt diff --git a/.dockerignore b/.dockerignore index 96f81bce..e91a3302 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,2 +1,5 @@ -Dockerfile -.git +** + +!/httpbin +!/requirements.txt +!/test_httpbin.py \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 6e391a6a..31267bd4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,23 @@ -FROM ubuntu:18.04 +FROM python:3-alpine LABEL name="httpbin" LABEL version="0.9.2" LABEL description="A simple HTTP service." LABEL org.kennethreitz.vendor="Kenneth Reitz" -RUN apt update -y && apt install python3-pip -y +WORKDIR /srv -EXPOSE 80 +# until we have precompiled gevent + brotli, we need this: +RUN apk add --no-cache --repository=http://nl.alpinelinux.org/alpine/v3.8/main \ + build-base \ + gcc \ + musl-dev + +COPY requirements.txt ./ +RUN pip install --no-cache-dir -r requirements.txt -ADD . /httpbin +COPY . . -RUN pip3 install --no-cache-dir gunicorn /httpbin +EXPOSE 80 CMD ["gunicorn", "-b", "0.0.0.0:80", "httpbin:app", "-k", "gevent"] diff --git a/docker-compose.yml b/docker-compose.yml index a7765f7b..0b698493 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,15 @@ version: '2' services: + + # run local httpbin server httpbin: - build: '.' + build: . + image: httpbin:latest ports: - - '80:80' \ No newline at end of file + - '80:80' + + # run tox-like tests (for python3 only) + unittest: + # reuse already built image + image: httpbin:latest + command: ./test_httpbin.py diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..1bd82b80 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,8 @@ +brotli==1.0.6 +decorator==4.3.0 +flasgger==0.9.1 +Flask==1.0.2 +gevent==1.3.7 +gunicorn==19.9.0 +six==1.11.0 +Werkzeug==0.14.1 \ No newline at end of file