Merge branch 'main' of github.com:qvarforth/trackdirect into main

This commit is contained in:
Per Qvarforth 2022-02-07 21:25:54 +00:00
commit 007f84bc3f
33 changed files with 287 additions and 21 deletions

2
.dockerignore Normal file
View File

@ -0,0 +1,2 @@
heatmaps
db

4
.gitignore vendored
View File

@ -12,3 +12,7 @@ config/*
!config/trackdirect.ini !config/trackdirect.ini
ogndevices ogndevices
heatmaps
db

View File

@ -15,6 +15,8 @@ Information shared over the APRS network is for example coordinates, altitude, s
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes (but they are of course also valid for you who want to set up a public website). These instructions will get you a copy of the project up and running on your local machine for development and testing purposes (but they are of course also valid for you who want to set up a public website).
Further down you will find some information how to install trackdirect with Docker and Docker-Compose.
### Prerequisites ### Prerequisites
What things you need to install and how to install them. These instructions are for Ubuntu 20.04 What things you need to install and how to install them. These instructions are for Ubuntu 20.04
@ -252,6 +254,35 @@ Crontab example
### Server Requirements ### Server Requirements
How powerful server you need depends on what type of data source you are going to use. If you, for example, receive data from the APRS-IS network, you will probably need at least a server with 4 CPUs and 8 GB of RAM, but I recommend using a server with 8 CPUs and 16 GB of RAM. How powerful server you need depends on what type of data source you are going to use. If you, for example, receive data from the APRS-IS network, you will probably need at least a server with 4 CPUs and 8 GB of RAM, but I recommend using a server with 8 CPUs and 16 GB of RAM.
## Getting Started - Docker
There is everything prepared to run trackdirect inside of some docker containers. As there is a Docker-Compose file the setup is very simple and fast.
### Install Docker and Docker-Compose
Install [docker](https://docs.docker.com/get-docker/) and [docker-compose](https://docs.docker.com/compose/install/) from the published websites.
### Config file
Adopt your config in `config/aprsc.conf` and `config/trackdirect.ini`. In `trackdirect.ini` search for 'docker' and change the lines as described in the comments.
### Run Docker-Compose for development containers
To startup trackdirect in an development container run this docker-compose command:
```
docker-compose up
```
If you want to run the container in daemon mode add `-d` to the command.
### Run Docker-Compose for the last published docker images
@peterus is creating regular docker images from this repository. With the release Docker-Compose file you do not need to install and compile everything by your own.
```
docker-compose -f docker-compose-rel.yml up
```
## TODO ## TODO
- Rewrite backend to use Python 3 instead of Python 2. - Rewrite backend to use Python 3 instead of Python 2.
- Create a REST-API and replace the current website example with a new frontend written in Angular. - Create a REST-API and replace the current website example with a new frontend written in Angular.

23
aprsc.dockerfile Normal file
View File

@ -0,0 +1,23 @@
FROM ubuntu:20.04
RUN apt-get update && apt-get install -y \
gnupg \
&& rm -rf /var/lib/apt/lists/*
RUN printf "deb http://aprsc-dist.he.fi/aprsc/apt focal main" >> /etc/apt/sources.list
RUN gpg --keyserver keyserver.ubuntu.com --recv C51AA22389B5B74C3896EF3CA72A581E657A2B8D
RUN gpg --export C51AA22389B5B74C3896EF3CA72A581E657A2B8D | apt-key add -
RUN apt-get update && apt-get install -y \
aprsc \
&& rm -rf /var/lib/apt/lists/*
RUN rm /opt/aprsc/etc/aprsc.conf
VOLUME /opt/aprsc/etc/aprsc.conf
EXPOSE 10152
EXPOSE 14580
EXPOSE 10155
EXPOSE 14501
CMD /opt/aprsc/sbin/aprsc -u aprsc -t /opt/aprsc -c /etc/aprsc.conf

13
config/000-default.conf Normal file
View File

@ -0,0 +1,13 @@
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /root/trackdirect/htdocs/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<Directory "/root/trackdirect/htdocs/public">
Options Indexes MultiViews
AllowOverride All
Require all granted
</Directory>

View File

@ -28,4 +28,3 @@ HTTPStatusOptions ShowEmail=1
# from the configuration file. It's here only to avoid starting the # from the configuration file. It's here only to avoid starting the
# server up accidentally with an invalid configuration. # server up accidentally with an invalid configuration.
MagicBadness 42.7 MagicBadness 42.7

View File

@ -11,8 +11,10 @@ owner_email="no@name.com"
[database] [database]
;; Basic database settings ;; Basic database settings
;; If using docker, set host to "db"
host="127.0.0.1" host="127.0.0.1"
database="trackdirect" database="trackdirect"
;; If using docker, activate username and set to "root"
;username="username" ;username="username"
password="foobar" password="foobar"
port="5432" port="5432"
@ -50,6 +52,7 @@ frequency_limit="0"
;; First APRS IS server for the websocket server to connect to. ;; First APRS IS server for the websocket server to connect to.
;; Important: Please set up your own APRS IS server, do not use a public server. ;; Important: Please set up your own APRS IS server, do not use a public server.
;; If using docker, set aprs_host1 to "aprsc"
aprs_host1="127.0.0.1" aprs_host1="127.0.0.1"
aprs_port1="14580" aprs_port1="14580"
@ -88,6 +91,7 @@ max_queued_realtime_packets="30"
[collector0] [collector0]
;; If using docker, set host to "aprsc"
host="127.0.0.1" host="127.0.0.1"
port_full="10152" port_full="10152"
port_filtered="14580" port_filtered="14580"

3
db.dockerfile Normal file
View File

@ -0,0 +1,3 @@
FROM postgres
COPY misc/database/tables/* /docker-entrypoint-initdb.d/
VOLUME /var/lib/postgresql/data

65
docker-compose-rel.yml Normal file
View File

@ -0,0 +1,65 @@
version: "3.9"
services:
aprsc:
image: peterus/aprsc:latest
restart: always
ports:
- "10152:10152"
- "14580:14580"
- "10155:10155"
- "14501:14501"
volumes:
- $PWD/config/aprsc.conf:/opt/aprsc/etc/aprsc.conf
collector:
image: peterus/trackdirect-python2:latest
restart: always
volumes:
- $PWD/config/trackdirect.ini:/root/trackdirect/config/trackdirect.ini
command: /root/trackdirect/server/scripts/collector.sh trackdirect.ini 0
depends_on:
- "db"
- "aprsc"
websocket:
image: peterus/trackdirect-python2:latest
restart: always
volumes:
- $PWD/config/trackdirect.ini:/root/trackdirect/config/trackdirect.ini
command: /root/trackdirect/server/scripts/wsserver.sh trackdirect.ini
ports:
- "9000:9000"
depends_on:
- "db"
- "aprsc"
heatmaps:
image: peterus/trackdirect-python2:latest
restart: always
volumes:
- $PWD/config/trackdirect.ini:/root/trackdirect/config/trackdirect.ini
- $PWD/heatmaps:/root/trackdirect/htdocs/public/heatmaps
command: /root/trackdirect/server/scripts/heatmapcreator.sh trackdirect.ini /root/trackdirect/htdocs/public/heatmaps
depends_on:
- "db"
web:
image: peterus/trackdirect-apache:latest
restart: always
volumes:
- $PWD/config/trackdirect.ini:/root/trackdirect/config/trackdirect.ini
- $PWD/heatmaps:/root/trackdirect/htdocs/public/heatmaps
ports:
- "80:80"
depends_on:
- "db"
db:
image: peterus/trackdirect-db:latest
restart: always
environment:
POSTGRES_USER: root
POSTGRES_PASSWORD: foobar
POSTGRES_DB: trackdirect
volumes:
- $PWD/db:/var/lib/postgresql/data

77
docker-compose.yml Normal file
View File

@ -0,0 +1,77 @@
version: "3.9"
services:
aprsc:
build:
context: .
dockerfile: aprsc.dockerfile
restart: always
ports:
- "10152:10152"
- "14580:14580"
- "10155:10155"
- "14501:14501"
volumes:
- $PWD/config/aprsc.conf:/opt/aprsc/etc/aprsc.conf
collector:
build:
context: .
dockerfile: trackdirect-python2.dockerfile
restart: always
volumes:
- $PWD/config/trackdirect.ini:/root/trackdirect/config/trackdirect.ini
command: /root/trackdirect/server/scripts/collector.sh trackdirect.ini 0
depends_on:
- "db"
- "aprsc"
websocket:
build:
context: .
dockerfile: trackdirect-python2.dockerfile
restart: always
volumes:
- $PWD/config/trackdirect.ini:/root/trackdirect/config/trackdirect.ini
command: /root/trackdirect/server/scripts/wsserver.sh trackdirect.ini
ports:
- "9000:9000"
depends_on:
- "db"
- "aprsc"
heatmaps:
build:
context: .
dockerfile: trackdirect-python2.dockerfile
restart: always
volumes:
- $PWD/config/trackdirect.ini:/root/trackdirect/config/trackdirect.ini
- $PWD/heatmaps:/root/trackdirect/htdocs/public/heatmaps
command: /root/trackdirect/server/scripts/heatmapcreator.sh trackdirect.ini /root/trackdirect/htdocs/public/heatmaps
depends_on:
- "db"
web:
build:
context: .
dockerfile: trackdirect-apache.dockerfile
restart: always
volumes:
- $PWD/config/trackdirect.ini:/root/trackdirect/config/trackdirect.ini
- $PWD/heatmaps:/root/trackdirect/htdocs/public/heatmaps
ports:
- "80:80"
depends_on:
- "db"
db:
build:
context: .
dockerfile: db.dockerfile
restart: always
environment:
POSTGRES_USER: root
POSTGRES_PASSWORD: foobar
POSTGRES_DB: trackdirect
volumes:
- $PWD/db:/var/lib/postgresql/data

View File

@ -15,26 +15,26 @@ psql -p $PORT $DATABASE << EOF
begin transaction; begin transaction;
\i $SQLPATH/map.sql \i $SQLPATH/01_map.sql
\i $SQLPATH/marker.sql \i $SQLPATH/02_marker.sql
\i $SQLPATH/ogn_address_type.sql \i $SQLPATH/03_ogn_address_type.sql
\i $SQLPATH/ogn_aircraft_type.sql \i $SQLPATH/04_ogn_aircraft_type.sql
\i $SQLPATH/ogn_device.sql \i $SQLPATH/05_ogn_device.sql
\i $SQLPATH/ogn_hidden_station.sql \i $SQLPATH/06_ogn_hidden_station.sql
\i $SQLPATH/packet_type.sql \i $SQLPATH/07_packet_type.sql
\i $SQLPATH/sender.sql \i $SQLPATH/08_sender.sql
\i $SQLPATH/source.sql \i $SQLPATH/09_source.sql
\i $SQLPATH/station_type.sql \i $SQLPATH/10_station_type.sql
\i $SQLPATH/station.sql \i $SQLPATH/11_station.sql
\i $SQLPATH/station_telemetry_bits.sql \i $SQLPATH/12_station_telemetry_bits.sql
\i $SQLPATH/station_telemetry_eqns.sql \i $SQLPATH/13_station_telemetry_eqns.sql
\i $SQLPATH/station_telemetry_param.sql \i $SQLPATH/14_station_telemetry_param.sql
\i $SQLPATH/station_telemetry_unit.sql \i $SQLPATH/15_station_telemetry_unit.sql
\i $SQLPATH/packet.sql \i $SQLPATH/16_packet.sql
\i $SQLPATH/packet_weather.sql \i $SQLPATH/17_packet_weather.sql
\i $SQLPATH/packet_telemetry.sql \i $SQLPATH/18_packet_telemetry.sql
\i $SQLPATH/packet_path.sql \i $SQLPATH/19_packet_path.sql
\i $SQLPATH/packet_ogn.sql \i $SQLPATH/20_packet_ogn.sql
commit; commit;

View File

@ -0,0 +1,24 @@
FROM php:7.2-apache
RUN apt-get update && apt-get install -y \
git \
libpq-dev \
postgresql-client-common \
postgresql-client \
libevent-dev \
libmagickwand-dev \
imagemagick \
inkscape \
&& rm -rf /var/lib/apt/lists/*
RUN pecl install imagick && docker-php-ext-enable imagick && docker-php-ext-install pdo pdo_pgsql
COPY . /root/trackdirect
COPY config/000-default.conf /etc/apache2/sites-enabled/
RUN a2enmod rewrite
RUN chmod a+rx / && chmod a+rx -R /root
RUN chmod 777 /root/trackdirect/htdocs/public/symbols
VOLUME /root/trackdirect/config/trackdirect.ini
VOLUME /root/trackdirect/htdocs/public/heatmaps

View File

@ -0,0 +1,21 @@
FROM ubuntu:20.04
RUN apt-get update && apt-get install -y \
python2 \
python2-dev \
git \
curl \
wget \
gcc \
&& rm -rf /var/lib/apt/lists/*
RUN curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py && python2 get-pip.py
RUN pip2 install psycopg2-binary autobahn[twisted] twisted pympler image_slicer jsmin psutil
RUN git clone https://github.com/rossengeorgiev/aprs-python && cd aprs-python && pip2 install .
RUN wget http://jjguy.com/heatmap/heatmap-2.2.1.tar.gz && tar xzf heatmap-2.2.1.tar.gz && cd heatmap-2.2.1 && python2 setup.py install
COPY . /root/trackdirect
VOLUME /root/trackdirect/config/trackdirect.ini
VOLUME /root/trackdirect/htdocs/public/heatmaps