Skip to content

Commit 7bba8a5

Browse files
committed
Built Dockerfile, README and run_python.sh
1 parent 94a183e commit 7bba8a5

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

examples/docker/Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM python:2.7.11
2+
MAINTAINER Fiona Hasanaj
3+
4+
# install necessary software
5+
RUN apt-get -y update && apt-get install -y vim && apt-get install -y git && pip install tox
6+
7+
COPY run_python.sh /python/examples/run_python.sh
8+
RUN chmod 755 /python/examples/run_python.sh
9+
WORKDIR /python/examples
10+
11+
# allow interactive bash inside docker container
12+
CMD ./run_python.sh $API_KEY $ALT_URL
13+
14+
VOLUME ["/source"]

examples/docker/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
# Docker Image for Python Examples
3+
---
4+
### Summary
5+
To simplify the running of the Python examples, the Dockerfile will build an image and install the latest rosette-api library from composer.
6+
7+
### Basic Usage
8+
Build the docker image, e.g. `docker build -t basistech/python:1.1 .`
9+
10+
Run an example as `docker run -e API_KEY=api-key -v "path-to-example-source:/source" basistech/python:1.1`
11+
12+
To test against an alternate url, add `-e ALT_URL=alternate_url` before the `-v`

examples/docker/run_python.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
# reference the API
4+
curl "https://api.rosette.com/rest/v1/ping" -H "user_key: $1"
5+
6+
cp /source/*.* .
7+
8+
if [ ! -z "$2" ]; then
9+
find -maxdepth 1 -name '*.py' -print -exec tox -- {} --key $1 --url $2 \;
10+
else
11+
find -maxdepth 1 -name '*.py' -print -exec tox -- {} --key $1 \;
12+
fi

0 commit comments

Comments
 (0)