forked from britiger/bikeparkingberlin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First version to develop with docker
- Loading branch information
Showing
9 changed files
with
166 additions
and
4 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
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,38 @@ | ||
FROM postgres:13 | ||
|
||
RUN apt-get update; \ | ||
apt install -y --no-install-recommends \ | ||
postgis \ | ||
python3 \ | ||
python3-dev \ | ||
python3-pip \ | ||
python3-venv \ | ||
osm2pgsql \ | ||
postgresql-13-postgis-3 \ | ||
unzip \ | ||
wget \ | ||
gcc \ | ||
libz-dev | ||
|
||
# install/build current ogr2ogr into /usr/local | ||
RUN cd / ; \ | ||
apt install -y --no-install-recommends g++ libsqlite3-dev sqlite3 pkg-config libtiff-dev libcurl4-openssl-dev make libpq-dev; \ | ||
wget https://github.com/OSGeo/gdal/releases/download/v3.2.3/gdal-3.2.3.tar.gz; \ | ||
wget https://download.osgeo.org/proj/proj-8.0.1.tar.gz; \ | ||
tar xzf gdal-3.2.3.tar.gz; \ | ||
tar xzf proj-8.0.1.tar.gz; \ | ||
cd /proj-8.0.1; \ | ||
./configure; \ | ||
make -j8 ; \ | ||
make install ; \ | ||
ldconfig ; \ | ||
cd /gdal-3.2.3 ; \ | ||
./configure ; \ | ||
make -j8 ; \ | ||
make install ; \ | ||
ldconfig ; \ | ||
rm -f gdal-3.2.3 proj-8.0.1 gdal-3.2.3.tar.gz proj-8.0.1.tar.gz | ||
|
||
ADD docker/create_db.sql /docker-entrypoint-initdb.d/create_db.sql | ||
|
||
EXPOSE 5432 5000 |
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 +1,42 @@ | ||
# [bikeparking.lorenz.lu](https://bikeparking.lorenz.lu/) | ||
|
||
You can start it by your own using Docker. By the script the source directory is linked as volume into the container, so you can localy edit the webapp. | ||
|
||
1. Building a local image: | ||
``` | ||
./build-docker.sh | ||
``` | ||
2. Download and Link a pbf-File: | ||
``` | ||
# Here as example of Brandenburg incl. Berlin | ||
wget http://download.geofabrik.de/europe/germany/brandenburg-latest.osm.pbf | ||
ln -s brandenburg-latest.osm.pbf import.osm.pbf | ||
``` | ||
3. Start container and import data | ||
``` | ||
./run-docker.sh | ||
``` | ||
4. Work with the container | ||
``` | ||
# Start Webapp | ||
./run-docker.sh webapp | ||
# Need to Open the Browser http://127.0.0.1:5000/ | ||
# Update Database | ||
./run-docker.sh update | ||
# Import or update external data | ||
./run-docker.sh external | ||
# Import or update rental stations | ||
./run-docker.sh rental | ||
``` | ||
|
||
If you want to persit your data in the database you need to edit `run-docker.sh` by adding a database volume: | ||
```bash | ||
# create a Volume / otherwise you can use a local directory | ||
docker volume create pgdata | ||
|
||
# docker run -e POSTGRES_PASSWORD=bikeparking -p 127.0.0.1:5000:5000 -v `pwd`:/bikeparking --rm -d --name $CONTAINER_NAME bikeparking | ||
docker run -e POSTGRES_PASSWORD=bikeparking -p 127.0.0.1:5000:5000 -v `pwd`:/bikeparking -v pgdata:/var/lib/postgresql/data --rm -d --name $CONTAINER_NAME bikeparking | ||
``` |
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,7 @@ | ||
#!/bin/bash | ||
|
||
# goto this path | ||
cd `dirname $(readlink -f $0)` | ||
|
||
docker pull postgres:13 | ||
docker build -t bikeparking:latest . |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
CREATE USER osm PASSWORD 'osm'; | ||
CREATE DATABASE osm_parking OWNER osm; | ||
\c osm_parking | ||
CREATE EXTENSION postgis; | ||
CREATE EXTENSION hstore; |
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,69 @@ | ||
#!/bin/bash | ||
|
||
# goto this path | ||
cd `dirname $(readlink -f $0)` | ||
CMD=$1 | ||
|
||
CONTAINER_NAME=bikeparkingcontainer | ||
|
||
# Check Installed imposm | ||
if ! [ -f "database/tools/imposm-0.11.1-linux-x86-64.tar.gz" ] | ||
then | ||
wget -P database/tools/ https://github.com/omniscale/imposm3/releases/download/v0.11.1/imposm-0.11.1-linux-x86-64.tar.gz | ||
tar -xzf database/tools/imposm-0.11.1-linux-x86-64.tar.gz -C database/tools/ | ||
mv -f database/tools/imposm-0.11.1-linux-x86-64/* database/tools/ | ||
rm -rf database/tools/imposm-0.11.1-linux-x86-64 | ||
fi | ||
|
||
if ! [ -f config ] | ||
then | ||
cp config.sample config | ||
fi | ||
|
||
source ./config | ||
|
||
if ! [ "$( docker container inspect -f '{{.State.Status}}' $CONTAINER_NAME )" == "running" ] | ||
then | ||
echo "Container not running ..." | ||
# Start container | ||
docker run -e POSTGRES_PASSWORD=bikeparking -p 127.0.0.1:5000:5000 -v `pwd`:/bikeparking --rm -d --name $CONTAINER_NAME bikeparking | ||
echo "Waiting for statup ..." | ||
sleep 10 | ||
DO_IMPORT=1 | ||
else | ||
echo "Container is running." | ||
if [ -z "${CMD}" ] | ||
then | ||
echo "Use Parameter: " | ||
echo " external - Import/Update data of external sources" | ||
echo " reimport - Reimport Database from PBF-File" | ||
echo " rental - Import/Update data of rental sources" | ||
echo " update - Update Database from osm" | ||
echo " webapp - Start Webapp" | ||
fi | ||
fi | ||
|
||
if [ "${CMD}" == "reimport" ] || [ -n "${DO_IMPORT}" ] | ||
then | ||
# Import | ||
if [ -f "${IMPORT_PBF}" ] | ||
then | ||
docker exec -it $CONTAINER_NAME /bikeparking/database/import.sh | ||
else | ||
echo "Please Download a PBF-File (${IMPORT_PBF}) for import!" | ||
echo "After this you should run '$0 reimport' for import." | ||
fi | ||
elif [ "${CMD}" == "webapp" ] | ||
then | ||
# run webapp in container | ||
docker exec -it $CONTAINER_NAME /bikeparking/webapp/start.sh | ||
elif [ "${CMD}" == "update" ] | ||
then | ||
docker exec -it $CONTAINER_NAME /bikeparking/database/update.sh | ||
elif [ "${CMD}" == "external" ] | ||
then | ||
docker exec -it $CONTAINER_NAME /bikeparking/database/import_external.sh | ||
elif [ "${CMD}" == "rental" ] | ||
then | ||
docker exec -it $CONTAINER_NAME /bikeparking/database/import_rental.sh | ||
fi |
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,7 +1,6 @@ | ||
flask | ||
flask-sqlalchemy | ||
flask-babel | ||
psycopg2 | ||
psycopg2-binary | ||
pylint | ||
python-dotenv |
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