Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
9b44c5a
Merge branch 'release/2.19.2' into develop
exhuma May 20, 2017
5807c2d
Merge branch 'hotfix/2.19.4' into develop
exhuma May 21, 2017
f377865
Merge branch 'master' into develop
exhuma May 25, 2017
6df5ff6
Merge branch 'fix-ppm' into develop
exhuma May 25, 2017
28caf82
Merge branch 'hotfix/2.19.11' into develop
exhuma Apr 1, 2018
822bb7b
Use gouge-logging on the CLI
exhuma Apr 1, 2018
fb5190c
Merge branch 'hotfix/facebook-api' into develop
exhuma Apr 1, 2018
d3fb856
Move developemt tasks to "invoke"
exhuma Apr 6, 2019
1b2c2af
Remove login code (broken OAuth)
exhuma Apr 7, 2019
009ac5a
Migrate from fabric to invoke, fix dependencies
exhuma Apr 7, 2019
f7c1b6b
Remove Vagrant (in favor of docker)
exhuma Apr 7, 2019
fc86779
Add files for docker-image creation
exhuma Apr 7, 2019
2977e7a
Dockerfile cleanup
exhuma Apr 7, 2019
5f46ab4
Update docs
exhuma Apr 7, 2019
d7d59df
Update notes on the "misc" page
exhuma Apr 7, 2019
b5e77b2
Allow registration on an external URL
exhuma Apr 7, 2019
491b041
Fix docker tasks
exhuma Apr 7, 2019
da02fda
Fix type conversions for settings
exhuma Apr 7, 2019
eb2b286
Cleanup entry-point
exhuma Apr 7, 2019
46e169b
Give the DB a chance to boot up
exhuma Apr 8, 2019
45506f4
Merge branch 'release-2019' into develop
exhuma Apr 8, 2019
4d0c8d7
Address security alerts
exhuma Apr 8, 2019
95772de
Merge branch 'release-2019' into develop
exhuma Apr 8, 2019
07c907c
Use gallery and scoreboard from lost-tracker
exhuma May 11, 2019
807e0df
Update pythonapp.yml
exhuma Sep 17, 2019
c37d3fc
Merge branch 'develop' into github-actions
exhuma Jan 11, 2020
35c199e
Fix deprecations
exhuma Jan 11, 2020
bfb7340
Short-circuit unfinished unit-tests
exhuma Jan 11, 2020
4070939
Use setup.py instead of requirements.txt in CI
exhuma Jan 11, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
env
dist-env
30 changes: 30 additions & 0 deletions .github/workflows/pythonapp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Python application

on: [push]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- name: Set up Python 3.7
uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .[dev,test]
- name: Lint with flake8
run: |
pip install flake8
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pip install pytest
pytest
36 changes: 36 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
FROM ubuntu:xenial
RUN apt-get update && apt-get install -y \
libpq-dev \
libffi-dev \
python3-dev \
libjpeg-dev \
build-essential \
python3-pip \
git

RUN pip3 install -U pip
RUN pip install alembic gunicorn

ENV TRACKER_DSN=postgresql://lost@database/lost
ENV TRACKER_HELPDESK=
ENV TRACKER_PHOTO_FOLDER=/data/photos
ENV TRACKER_HTTP_LOGIN=http_login
ENV TRACKER_HTTP_PASSWORD=http_passwd
ENV TRACKER_SECRET_KEY=unsecure
ENV TRACKER_SHOUT=
ENV TRACKER_FLICKR_API_KEY=

COPY dist-requirements.txt /
COPY dist/docker.tar.gz /
COPY entry-point.bash /
RUN mkdir -p /alembic
ADD alembic /alembic/alembic
ADD alembic.ini /alembic
RUN chmod +x /entry-point.bash
RUN pip install -r /dist-requirements.txt
RUN pip install /docker.tar.gz
RUN mkdir -p /etc/mamerwiselen/lost-tracker
COPY app.ini.dist /
COPY materialize_config.py /
EXPOSE 8080
ENTRYPOINT ["/entry-point.bash"]
120 changes: 32 additions & 88 deletions INSTALL.rst
Original file line number Diff line number Diff line change
@@ -1,106 +1,50 @@
INSTALLATION
------------

.. note:: I recommend using virtualenv, but nothing prevents you installing
it into the root system
Since 2019, this application is available as a docker-container. You should be
able to run it using::

Requirements
~~~~~~~~~~~~
docker run exhuma/lost-tracker

When installing this package, it will build the Postgres client. So you'll need
the necessary headers, plus gcc on your machine.
Internally it will expose the port ``8080`` as HTTP

For Ubuntu, run the following::
Environment Variables
---------------------

sudo apt-get install libpq-dev python-dev build-essential
The following environment variables are available when running the container:

Installation procedure
~~~~~~~~~~~~~~~~~~~~~~
**TRACKER_DSN** (required)
An SQLAlchemy databse URL. For example:
``postgresql://john:password@dbhost/dbname``

- Download the latest package from http://www.github.com/exhuma/lost-tracker I
recommend using the latest tagged version, but if you want bleeding edge, you
may also download the "master" branch.
**TRACKER_HELPDESK**
A text which is available on each page

- untar the package::
**TRACKER_PHOTO_FOLDER**
A folder-name which contains photos which are shown on the web-page.
It is recommended to mount a host-folder into the running container to this
location.

tar xzf exhuma-lost-tracker-<version number+hash>.tar.gz
**TRACKER_HTTP_LOGIN**
A plain-text HTTP username used for API clients

- enter the folder::
**TRACKER_HTTP_PASSWORD**
A plain-text HTTP password used for API clients

cd exhuma-lost-tracker-<version number+hash>
**TRACKER_SECRET_KEY**
Internally used for security. Should be set to a random string

When not using virtualenv, you may skip this section
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**TRACKER_SHOUT**
A text shown on each page

.. note:: If you don't have virtualenv, run the following:
**TRACKER_FLICKR_API_KEY**
A key which is allowed to access the Flickr API. This is used for
additional photos.

``sudo apt-get install python-setuptools && easy_install virtualenv``
**TRACKER_REGISTER_URL**
An optional URL which will be used for registrations instead of the builtin
solution

- create a virtualenv::

virtualenv --no-site-packages /path/to/your/env

- activate the environment::

source /path/to/your/env/bin/activate

Without virtualenv
~~~~~~~~~~~~~~~~~~

- run the installer::

python setup.py install


Database initialisation
~~~~~~~~~~~~~~~~~~~~~~~

To initialise the database run the following commands::

# export MAMERWISELEN_LOST_TRACKER_PATH="/path/which/contains/app.ini"
# ./env/bin/alembic upgrade head


.. note::

The environment variable should point to the path *containing* ``app.ini``.
Not the filename itself!

Apache Config
~~~~~~~~~~~~~

Example::

<VirtualHost *:80>

ServerName www.lost.lu
ServerAlias lost.lu

DocumentRoot /var/www/lost.lu/www/htdocs

<Directory /var/www/lost.lu/www/htdocs>
Order allow,deny
Allow from all
</Directory>

WSGIDaemonProcess lost.lu processes=2 threads=15 display-name=%{GROUP} python-home=/var/www/lost.lu/www/env user=lost_tracker
WSGIProcessGroup lost.lu
WSGIScriptAlias / /var/www/lost.lu/www/wsgi/lost-tracker.wsgi

<Directory /var/www/lost.lu/www/wsgi>
Order allow,deny
Allow from all
</Directory>

</VirtualHost>


Configuration
-------------

Configuration is handled using ``ini`` style config files. An example file is
given in ``app.ini.dist``.

The file is looked up using config_resolver_.

.. _config_resolver:: https://config-resolver.readthedocs.org/en/latest/
When the container starts up it will automatically apply database upgrades as
necessary.
24 changes: 10 additions & 14 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,9 @@ Development
Required Tools
~~~~~~~~~~~~~~

* fabric (Python Task Runner). This is optional but highly convenient!
* Python 2.7 (Python 3.5 was tested half-arsedly, may work...)
* Oracle Java 1.7+ (Tested with OpenJDK with mixed results). This is needed for
live JS compilation. Without it, no JavaScript will run!
* A database. I recommend PostgreSQL as the application has been tested with
that one.
* invoke (Python Task Runner). This is optional but highly convenient!
* Python 3
* docker (for javascript compilation)


Additional Notes
Expand Down Expand Up @@ -72,22 +69,21 @@ Clone the code::
git clone https://github.com/exhuma/lost-tracker

Enter the cloned folder, switch to the ``develop`` branch and run the develop
fabric-task. Running that task will set up a virtual-env, download required
invoke-task. Running that task will set up a virtual-env, download required
dependencies and install the application into that environment::

cd lost-tracker
git checkout develop # Make sure you're on the latest developmen branch
fab develop # Prepares a virtualenv and downloads dependencies.
inv develop # Prepares a virtualenv and downloads dependencies.

When this successfully completes you should have an environment ready for happy
hacking.

One final note: JavaScript is compiled using the google-closure compiler with
the help of plovr_. Those dependencies should have been downloaded for you into
the ``__libs__`` folder. You *must* run plovr during development! As a
convenience, there is a fabric task to run this for you::
the help of plovr_. The compiler has been wrapped in a docker container and
should be downloaded and run transparently. An invoke task is available::

fab serve_plovr
inv serve_plovr


Configuration
Expand All @@ -107,12 +103,12 @@ look through the rest of the config file as well.

Once all is configured the development server can be run with::

fab serve_web
inv serve_web

During development (when ``DEBUG=True``), you also need to run the plovr_
server in parallel. Simply open a new shell and type::

fab serve_plovr
inv serve_plovr

Social Logins During Development
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
76 changes: 0 additions & 76 deletions Vagrantfile

This file was deleted.

Loading