Skip to content

Commit

Permalink
Merge pull request #2 from WASAC/add-docker
Browse files Browse the repository at this point in the history
added docker
  • Loading branch information
Jin Igarashi authored Sep 20, 2020
2 parents d5eda1f + 5f3dd85 commit 48fec1d
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
/venv
/__pycache__
/epanet/__pycache__
/util/__pycache__
/util/__pycache__
/data
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM python:3.7
RUN mkdir -p /tmp/src
COPY . /tmp/src
WORKDIR /tmp/src
RUN pip install -r ./requirements.txt

RUN chmod a+x /tmp/src/entrypoint.sh
ENTRYPOINT ["./entrypoint.sh"]
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# PostGIS2EPANET
![GitHub](https://img.shields.io/github/license/wasac/postgis2epanet)
![Docker Cloud Automated build](https://img.shields.io/docker/cloud/automated/wasac/postgis2epanet)
![Docker Image Size (latest by date)](https://img.shields.io/docker/image-size/wasac/postgis2epanet)

## postgis2epanet.py

Expand Down Expand Up @@ -50,6 +53,28 @@ If you want to update elevation from DEM file, use ````-e```` parameter to updat
python postgis2epanet.py -e
````

## Using Docker
Firstly, please configure `docker-compose.yml`.
```yaml
- db_user=postgres
- db_password={your password}
- db_host=host.docker.internal
- db_port=5432
- database=rwss_assets
# If you want to specify districts to be exported, please put here like "51,52,53"
- districts=
```
Just execute the below command.
```
docker-compose up
```

If you changed any source code, please do the below.
```
docker-compose up --build
```

***
## Result of the Script:

Expand Down
15 changes: 15 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: '2'
services:
python:
image: wasac/postgis2epanet:v2.0.0
# build: .
environment:
- db_user=postgres
- db_password=wasacgis
- db_host=host.docker.internal
- db_port=5432
- database=rwss_assets
# If you want to specify districts to be exported, please put here like "51,52,53"
- districts=
volumes:
- ./data:/tmp/src/data
10 changes: 10 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

cd /tmp/src

target="${districts}"
if [ -n "$target" ]; then
python postgis2epanet.py -d $database -H $db_host -p $db_port -u $db_user -w $db_password -l $target
else
python postgis2epanet.py -d $database -H $db_host -p $db_port -u $db_user -w $db_password
fi
2 changes: 1 addition & 1 deletion epanet/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def __init__(self, args):
self.db = Database(args)
districts_obj = Districts(args.dist_id)
self.districts = districts_obj.get_wss_list_each_district(self.db)
self.main_dir = datetime.datetime.now().strftime('%Y%m%d_%H%M%S') + "_epanet_data"
self.main_dir = args.output + datetime.datetime.now().strftime('%Y%m%d_%H%M%S') + "_epanet_data"
self.exportdir_list = []
wss_list_obj = WaterSupplySystems()
if args.elevation == True:
Expand Down
3 changes: 3 additions & 0 deletions postgis2epanet.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ def create_argument_parser():
default=False,
help="If you use this option, the script is going to update elevation field of all layers.")

parser.add_argument("-o", "--output", default="./data/", type=str,
help="Output directory. Default is to export under data directory")

return parser.parse_args()


Expand Down

0 comments on commit 48fec1d

Please sign in to comment.