Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker swarm support and fix getting variables from environment when in docker mode #9

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
all: build_aarch64

build_aarch64:
docker build -t wifimap:aarch64 -f wifimap/Dockerfile --no-cache=true wifimap/
upload_aarch64:
docker tag wifimap:aarch64 nulldevil/wifimap:aarch64
docker push nulldevil/wifimap:aarch64
up_aarch64:
COMPOSE_PROJECT_NAME=phpmyadmin COMPOSE_IGNORE_ORPHANS=True docker-compose -f docker-compose_aarch64_swarm.yml up -d
down_aarch64:
COMPOSE_PROJECT_NAME=phpmyadmin COMPOSE_IGNORE_ORPHANS=True docker-compose -f docker-compose_aarch64_swarm.yml down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ $ docker-compose up -d
````
Docker setup is explained in more [detail here](https://github.com/Znerox/wifimap/wiki/Running-in-Docker-(recommended)).
If you want to run the system in a more traditional way, by install a web server and database yourself, that's [no problem](https://github.com/Znerox/wifimap/wiki/Installation-without-Docker).

### Docker swarm support on ARM64 (aarch64) architecture

```
make up_aarch64
```


### How to use
If your Docker host is on 192.168.1.10, the various webpages will now be available on these ports/addresses:
* Map of WiFi networks: 192.168.1.10
Expand Down
61 changes: 61 additions & 0 deletions docker-compose_aarch64_swarm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
version: "3.2"

services:
wifimap:
image: nulldevil/wifimap:aarch64
hostname: wifimap
depends_on:
- wifimap-mysql
networks:
- traefik_public
- internal
deploy:
resources:
limits:
cpus: '1.75' # one cpu
memory: 380M
placement:
constraints: [node.labels.name == node3]
labels:
# traefik common
- traefik.enable=true
- traefik.docker.network=traefik_public

# traefikv1
- traefik.frontend.rule=Host:wifi.yourdomain.com
- traefik.port=80

# traefikv2
- "traefik.http.routers.wifi.rule=Host(`wifi.yourdomain.com`)"
- "traefik.http.services.wifi.loadbalancer.server.port=80"
environment:
api_key: "api key from google"
server: "wifimap-mysql"
database: "wifimap"
username: "root"
password: "password"
environment: "release"
wifimap-mysql:
image: mysql
hostname: wifimap-mysql
networks:
- internal
volumes:
- ./wifimap_db_data:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: "password"
deploy:
resources:
limits:
cpus: '1.75' # one cpu
memory: 380M
placement:
constraints: [node.labels.name == node3]
networks:
traefik_public:
external: true
internal:
driver: overlay
ipam:
config:
- subnet: 172.16.20.0/24
2 changes: 2 additions & 0 deletions wifimap/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
FROM php:8.1-apache
COPY . /var/www/html/
COPY init.sh /init.sh
RUN chmod -R 777 /var/www/html/tools/php/uploads
RUN docker-php-ext-install mysqli
ENTRYPOINT ["/init.sh"]
10 changes: 5 additions & 5 deletions wifimap/bluetooth/php/dbinfo.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
$username="MYSQL_USERNAME";
$password="MYSQL_PASSWORD";
$server="localhost";
$database="wifimap";
?>
$username=getenv('username') ?? "MYSQL_USERNAME";
$password=getenv('password') ?? "MYSQL_PASSWORD";
$server=getenv('server') ?? "localhost";
$database=getenv('database') ?? "wifimap";
?>
10 changes: 5 additions & 5 deletions wifimap/clients/php/dbinfo.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
$username="MYSQL_USERNAME";
$password="MYSQL_PASSWORD";
$server="localhost";
$database="wifimap";
?>
$username=getenv('username') ?? "MYSQL_USERNAME";
$password=getenv('password') ?? "MYSQL_PASSWORD";
$server=getenv('server') ?? "localhost";
$database=getenv('database') ?? "wifimap";
?>
6 changes: 6 additions & 0 deletions wifimap/init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh -e

sed -i "s/YOUR_API_KEY/${api_key}/g" index.html
sed -i "s/YOUR_API_KEY/${api_key}/g" js/API_key.js

docker-php-entrypoint apache2-foreground
10 changes: 5 additions & 5 deletions wifimap/location/php/dbinfo.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
$username="MYSQL_USERNAME";
$password="MYSQL_PASSWORD";
$server="localhost";
$database="wifimap";
?>
$username=getenv('username') ?? "MYSQL_USERNAME";
$password=getenv('password') ?? "MYSQL_PASSWORD";
$server=getenv('server') ?? "localhost";
$database=getenv('database') ?? "wifimap";
?>
10 changes: 5 additions & 5 deletions wifimap/php/dbinfo.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
$username="MYSQL_USERNAME";
$password="MYSQL_PASSWORD";
$server="localhost";
$database="wifimap";
?>
$username=getenv('username') ?? "MYSQL_USERNAME";
$password=getenv('password') ?? "MYSQL_PASSWORD";
$server=getenv('server') ?? "localhost";
$database=getenv('database') ?? "wifimap";
?>
10 changes: 5 additions & 5 deletions wifimap/tools/php/dbinfo.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
$username="MYSQL_USERNAME";
$password="MYSQL_PASSWORD";
$server="localhost";
$database="wifimap";
?>
$username=getenv('username') ?? "MYSQL_USERNAME";
$password=getenv('password') ?? "MYSQL_PASSWORD";
$server=getenv('server') ?? "localhost";
$database=getenv('database') ?? "wifimap";
?>