-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from NuCivic/civic-3300_basic_ahoy_setup
Ahoy + Docker setup
- Loading branch information
Showing
12 changed files
with
190 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
ahoyapi: v1 | ||
usage: DKAN cli app for development using ahoy. | ||
commands: | ||
docker: | ||
usage: A series of docker commands (experimental) | ||
import: .ahoy/docker.ahoy.yml | ||
api: | ||
usage: | ||
import: .ahoy/api.ahoy.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.dkan |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
ahoyapi: v1 | ||
version: 0.0.0 | ||
commands: | ||
dkan: | ||
usage: Sets DKAN URI environment variable | ||
cmd: | | ||
FILE=".ahoy/.dkan" | ||
if [ -f $FILE ]; then | ||
cat $FILE | ||
exit 0 | ||
else | ||
echo "DKAN uri not set. Type it followed by [ENTER]:" | ||
read URI | ||
echo "$URI" > .ahoy/.dkan | ||
exit 0 | ||
fi | ||
python: | ||
usage: | ||
cmd: | | ||
FILE=".ahoy/.dkan" | ||
if [ ! -f $FILE ]; then | ||
ahoy api dkan | ||
fi | ||
DKAN_URI=`cat $FILE` | ||
ahoy docker compose run -e DKAN_URI=$DKAN_URI pydkan ipython {{args}} | ||
prompt: | ||
usage: Steps in the pydkan container | ||
cmd: | | ||
FILE=".ahoy/.dkan" | ||
if [ ! -f $FILE ]; then | ||
ahoy api dkan | ||
fi | ||
DKAN_URI=`cat $FILE` | ||
ahoy docker compose run -e DKAN_URI=$DKAN_URI pydkan bash | ||
tests: | ||
usage: Runs nosetests | ||
cmd: | | ||
FILE=".ahoy/.dkan" | ||
if [ ! -f $FILE ]; then | ||
ahoy api dkan | ||
fi | ||
DKAN_URI=`cat $FILE` | ||
ahoy docker compose run -e DKAN_URI=$DKAN_URI pydkan nosetests --verbose |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
ahoyapi: v1 | ||
version: 0.0.0 | ||
commands: | ||
env: | ||
cmd: | | ||
cat << EOF | ||
# To initialize your environment to use docker. | ||
# Run: eval \$(ahoy docker env) | ||
# OR | ||
# Add the following to your ~/.bashrc | ||
which docker || (echo "you don't seem to have docker installed. Exiting."; exit 1) | ||
which docker-machine || (echo "you don't seem to have docker-machine installed. Exiting."; exit 1) | ||
which docker-compose || (echo "you don't seem to have docker-compose installed. Exiting."; exit 1) | ||
echo "Setting up docker environment" | ||
export AHOY_CMD_PROXY=DOCKER | ||
docker-machine start default | ||
$(docker-machine env default) | ||
ahoy docker build | ||
EOF | ||
usage: Outputs the commands needed to setup a docker environment. | ||
stop: | ||
cmd: "ahoy docker compose stop" | ||
usage: Stop the docker-compose containers (non-destructive). | ||
ps: | ||
cmd: "ahoy docker compose ps" | ||
usage: List the running docker-compose containers. | ||
ip: | ||
cmd: "docker-machine ip default" | ||
usage: Show the ip address f the default docker machine VM | ||
reset: | ||
cmd: "ahoy docker compose stop && ahoy docker compose rm && ahoy docker compose up -d" | ||
usage: Destroy and then restart the docker compose containers. | ||
destroy: | ||
cmd: "ahoy docker compose stop && ahoy docker compose rm" | ||
usage: Destroy all the docker compose containers. (use before deleting folder) | ||
build: | ||
usage: Rebuild containers images | ||
cmd: | | ||
ahoy docker compose build {{args}} | ||
compose: | ||
usage: Abstraction for docker-compose | ||
cmd: | | ||
docker-compose -f docker-compose.yml -p "${PWD##*/}" {{args}} | ||
cleanup: | ||
usage: Clean ups docker unused images and volumes. See http://blog.yohanliyanage.com/2015/05/docker-clean-up-after-yourself/. | ||
cmd: | | ||
EXITED=`docker ps -a -q -f status=exited` | ||
DANGLING=`docker images -f "dangling=true" -q` | ||
if [ ! -z "$EXITED" ] | ||
then | ||
docker rm -v $EXITED | ||
fi | ||
if [ ! -z "$DANGLING" ] | ||
then | ||
docker rmi $DANGLING | ||
fi | ||
docker run -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/docker:/var/lib/docker --rm martin/docker-cleanup-volumes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
FROM python:2.7 | ||
ENV PYTHONUNBUFFERED 1 | ||
RUN DEBIAN_FRONTEND=noninteractive apt-get update && DEBIAN_FRONTEND=noninteractive apt-get clean && \ | ||
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* | ||
RUN mkdir /opt/pydkan | ||
WORKDIR /opt/pydkan | ||
ADD requirements.txt /opt/pydkan/ | ||
RUN pip install -r requirements.txt | ||
RUN pip install ipython | ||
ENV PYTHONPATH=${PYTHONPATH:-/opt/pydkan/} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,66 @@ | ||
This is the very beggining of a python client to interface with the [dkan_dataset_rest_api](https://github.com/NuCivic/dkan_dataset/tree/7.x-1.x/modules/dkan_dataset_rest_api) web service. | ||
# PyDKAN | ||
|
||
### Usage | ||
This is a python client to interface with the [dkan_dataset_rest_api](https://github.com/NuCivic/dkan_dataset/tree/7.x-1.x/modules/dkan_dataset_rest_api) web service. | ||
|
||
look inside the examples folder | ||
## Installation | ||
|
||
### As a Library | ||
|
||
```bash | ||
# To install the latest of the latest | ||
$ pip install git+git://github.com/NuCivic/pydkan.git@master#egg=pydkan | ||
# To install a release | ||
$ pip install git+git://github.com/NuCivic/[email protected]#egg=pydkan | ||
``` | ||
|
||
### For development with docker and ahoy | ||
|
||
+ Install docker | ||
+ Install ahoy (See https://github.com/devinci-code/ahoy#installation) | ||
+ Run the following: | ||
|
||
``` | ||
$ ahoy docker build | ||
``` | ||
|
||
That's it. | ||
|
||
## Usage | ||
|
||
### As a library | ||
|
||
Check the examples folder, there are snippets for pretty much everything you can do with this library. | ||
|
||
### Docker + Ahoy setup | ||
|
||
#### Prompt into a container with the dev environment | ||
|
||
``` | ||
ahoy api prompt | ||
``` | ||
|
||
#### Prompt into an ipython console: | ||
|
||
``` | ||
ahoy api python | ||
``` | ||
|
||
#### Run a script | ||
|
||
``` | ||
ahoy api python examples/list_nodes.py | ||
``` | ||
|
||
#### Run the testsuite | ||
|
||
```` | ||
ahoy api tests | ||
```` | ||
|
||
#### Rebuild the image | ||
|
||
From time to time you'll need to rebuild the docker image. For instance, if you add a requirement to the requirements.txt file and you'll need it installed. Yoy can do that by: | ||
|
||
``` | ||
ahoy docker build --no-cache | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
pydkan: | ||
build: ./ | ||
volumes: | ||
- ".:/opt/pydkan" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
import sys | ||
sys.path.append('..') | ||
|
||
import os | ||
import json | ||
from dkan.client import DatasetAPI | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
import sys | ||
sys.path.append('..') | ||
|
||
import os | ||
import json | ||
from dkan.client import DatasetAPI | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
import sys | ||
sys.path.append('..') | ||
|
||
import os | ||
import json | ||
from dkan.client import DatasetAPI | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
import sys | ||
sys.path.append('..') | ||
|
||
import os | ||
import json | ||
from dkan.client import DatasetAPI | ||
|