This repository has been archived by the owner on Apr 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
41 changed files
with
620 additions
and
243 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,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2015 HSR Hochschule für Technik, Rapperswil | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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 @@ | ||
source.tar |
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,79 @@ | ||
FROM debian:jessie | ||
|
||
MAINTAINER Tobias Blaser <[email protected]> | ||
|
||
# Update system | ||
RUN apt-get update | ||
RUN apt-get -y autoremove | ||
RUN apt-get -y install apt-utils | ||
|
||
# Install python 3 | ||
RUN apt-get -y install tar python3 python3-doc python3-setuptools python3-pip python-dev libpq-dev | ||
RUN pip3 install virtualenv | ||
|
||
# Install GEO libraries | ||
RUN apt-get -y install binutils libgeos-3.4. # GEOS | ||
RUN apt-get -y install libproj0 # PROJ.4 | ||
RUN apt-get -y install python-gdal # GDAL | ||
|
||
# Install database | ||
RUN apt-get -y install postgresql postgresql-client | ||
RUN apt-get -y install postgis osmctools postgresql-9.4-postgis-2.1 | ||
RUN apt-get -y install python3-psycopg2 | ||
RUN service postgresql start | ||
|
||
# Install apache | ||
RUN apt-get -y install apache2 apache2-utils libapache2-mod-wsgi-py3 | ||
RUN a2enmod wsgi | ||
RUN service apache2 restart | ||
|
||
USER postgres | ||
# Fix pg template ascii bug | ||
# @source: http://stackoverflow.com/questions/16736891/pgerror-error-new-encoding-utf8-is-incompatible | ||
RUN service postgresql start &&\ | ||
psql -c "UPDATE pg_database SET datistemplate = FALSE WHERE datname = 'template1';" &&\ | ||
psql -c "DROP DATABASE template1;" &&\ | ||
psql -c "CREATE DATABASE template1 WITH TEMPLATE = template0 ENCODING = 'UNICODE';" &&\ | ||
psql -c "UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template1';" &&\ | ||
psql -c "\c template1" &&\ | ||
psql -c "VACUUM FREEZE;" | ||
|
||
# Setup database | ||
RUN service postgresql start &&\ | ||
psql -c "CREATE USER osmaxx WITH PASSWORD 'osmaxx';" &&\ | ||
psql -c "CREATE DATABASE osmaxx ENCODING 'UTF8';" &&\ | ||
psql -c "GRANT ALL PRIVILEGES ON DATABASE osmaxx TO osmaxx;" | ||
|
||
RUN service postgresql start &&\ | ||
psql -c "CREATE EXTENSION postgis;" "osmaxx" &&\ | ||
psql -c "CREATE EXTENSION postgis_topology;" "osmaxx" | ||
USER root | ||
|
||
# Install osmaxx | ||
RUN cd /var/www; if [ ! -d "eda" ]; then mkdir "eda"; fi; cd "eda" | ||
RUN virtualenv-3.4 /var/www/eda/environment | ||
|
||
ADD source.tar /var/www/eda/ | ||
COPY requirementsProduction.txt /var/www/eda/requirementsProduction.txt | ||
RUN mv /var/www/eda/source /var/www/eda/projects; | ||
|
||
RUN cd "/var/www/eda/projects" | ||
RUN /var/www/eda/environment/bin/pip3 install -r /var/www/eda/requirementsProduction.txt | ||
RUN service postgresql start &&\ | ||
/var/www/eda/environment/bin/python /var/www/eda/projects/manage.py migrate | ||
RUN service postgresql start &&\ | ||
echo "from django.contrib.auth.models import User; User.objects.create_superuser('admin', '', 'osmaxx')" | /var/www/eda/environment/bin/python /var/www/eda/projects/manage.py shell | ||
|
||
RUN mkdir /var/www/eda/projects/data; chown root:www-data /var/www/eda/projects/data; chmod 777 /var/www/eda/projects/data | ||
|
||
# Create apache virtualhost | ||
COPY osmaxxProduction.vhost /etc/apache2/sites-available/osmaxx.conf | ||
RUN ln -s /etc/apache2/sites-available/osmaxx.conf /etc/apache2/sites-enabled/osmaxx.conf | ||
RUN a2ensite osmaxx | ||
|
||
COPY startApplication.sh /usr/local/bin/startApplication.sh | ||
RUN chmod +x /usr/local/bin/startApplication.sh | ||
|
||
EXPOSE 80 | ||
|
||
CMD /usr/local/bin/startApplication.sh && /bin/bash |
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,79 @@ | ||
# Deployment container for Docker | ||
|
||
|
||
## Docker installation | ||
|
||
See https://docs.docker.com/installation/ubuntulinux/ | ||
|
||
1. Be sure your kernel version is 3.10 or newer and wget is installed | ||
2. Install docker: | ||
|
||
```shell | ||
wget -qO- https://get.docker.com/ | sh | ||
``` | ||
3. Create a docker group and add you | ||
|
||
```shell | ||
sudo usermod -aG docker {yourUserName} | ||
``` | ||
|
||
|
||
## Build & run container | ||
|
||
1. Copy current source to docker data: | ||
|
||
```shell | ||
# use a clean repo to tar the source | ||
cd /tmp | ||
git clone [email protected]:geometalab/osmaxx.git --branch master --single-branch && cd osmaxx | ||
git submodule init && git submodule update | ||
tar -cf deployment/source.tar source | ||
# git archive not working with submodules | ||
# git archive master --format tar --output deployment/source.tar | ||
# tar from not-empty repository: | ||
tar -cf deployment/source.tar --exclude='*.git' --exclude='*.od*' --exclude='*.gitignore' --exclude='*.gitmodules' --exclude='*developmentEnvironment/' --exclude='*data/' --exclude='*.idea' --exclude='*test_db.sqlite' --exclude='*__pycache__/' source | ||
``` | ||
2. Build image: | ||
|
||
```shell | ||
docker build --tag=osmaxx --no-cache=true deployment/ | ||
``` | ||
3. Run container: | ||
|
||
```shell | ||
# map host port 8080 to port 80 of container | ||
docker run -d -p 8080:80 osmaxx | ||
``` | ||
**Note:** If you start the container with custom arguments (e.g. *docker run osmaxx /bin/bash*) you will override the CMD command to start the server. | ||
So you need to start the server by your self. | ||
|
||
|
||
## Management | ||
|
||
Run container interactive: | ||
```shell | ||
(sudo) docker run -i -t osmaxx /bin/bash | ||
``` | ||
|
||
Show running containers: | ||
```shell | ||
docker ps | ||
``` | ||
|
||
Stop running container: | ||
```shell | ||
docker stop {containerID} | ||
``` | ||
|
||
Save docker image to file: | ||
```shell | ||
docker save osmaxx > /tmp/osmaxx-alpha1.docker-img.tar | ||
``` | ||
|
||
Load docker image from file: | ||
```shell | ||
docker load < /tmp/osmaxx-alpha1.docker-img.tar | ||
``` |
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,14 @@ | ||
WSGIDaemonProcess osmaxx.dev python-path=/var/www/eda/environment/:/var/www/eda/environment/lib/python3.4/site-packages | ||
WSGIProcessGroup osmaxx.dev | ||
|
||
ErrorLog /var/log/apache2/osmaxx.log | ||
WSGIScriptAlias / /var/www/eda/projects/osmaxx/wsgi.py | ||
|
||
Alias "/static/admin" "/var/www/eda/environment/lib/python3.4/site-packages/django/contrib/admin/static/admin" | ||
Alias "/static/excerptexport" "/var/www/eda/projects/excerptexport/static/excerptexport" | ||
|
||
<Directory /var/www/eda/projects> | ||
<Files osmaxx/wsgi.py> | ||
Require all granted | ||
</Files> | ||
</Directory> |
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,3 @@ | ||
Django==1.7.4 | ||
django-enumfield==1.2 | ||
psycopg2==2.6 |
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,3 @@ | ||
#!/usr/bin/env bash | ||
|
||
service postgresql start && /usr/sbin/apache2ctl -D FOREGROUND |
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,18 @@ | ||
#!/usr/bin/env python3 | ||
import sys | ||
import os | ||
from flake8.hooks import git_hook | ||
|
||
COMPLEXITY = os.getenv('FLAKE8_COMPLEXITY', 10) | ||
STRICT = os.getenv('FLAKE8_STRICT', True) | ||
IGNORE = os.getenv('FLAKE8_IGNORE') | ||
LAZY = os.getenv('FLAKE8_LAZY', False) | ||
|
||
|
||
if __name__ == '__main__': | ||
sys.exit(git_hook( | ||
complexity=COMPLEXITY, | ||
strict=STRICT, | ||
ignore=IGNORE, | ||
lazy=LAZY, | ||
)) |
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
Oops, something went wrong.