From b8e6c4605c9da05245018887f0c9ea6395b618ef Mon Sep 17 00:00:00 2001 From: Vincent Mahnke Date: Sat, 11 Oct 2025 21:36:20 +0200 Subject: [PATCH] tmp --- .forgejo/workflows/test.yml | 26 ++++++---- .gitignore | 1 - README.md | 2 +- docker-compose.yml | 48 ++++--------------- home/sunders/init_cameras/db/Dockerfile | 3 ++ .../{createDB.sql => scripts/01-createDB.sql} | 4 -- .../02-addStatistics.sql} | 0 .../02-exampleData.sql} | 0 .../sunders/update_cameras/config.php.example | 2 +- home/sunders/update_cameras/update_camera.php | 2 +- .../update_cameras/update_statistics.php | 2 +- www/sunders/Dockerfile | 13 +++++ www/sunders/camera.php | 4 +- www/sunders/config.php | 15 ++++++ www/sunders/config.php.example | 17 ------- www/sunders/stats/index.php | 2 +- 16 files changed, 66 insertions(+), 75 deletions(-) create mode 100644 home/sunders/init_cameras/db/Dockerfile rename home/sunders/init_cameras/db/{createDB.sql => scripts/01-createDB.sql} (65%) rename home/sunders/init_cameras/db/{addStatistics.sql => scripts/02-addStatistics.sql} (100%) rename home/sunders/init_cameras/db/{initializeDB_planet_20120912.sql => scripts/02-exampleData.sql} (100%) create mode 100644 www/sunders/Dockerfile create mode 100644 www/sunders/config.php delete mode 100644 www/sunders/config.php.example diff --git a/.forgejo/workflows/test.yml b/.forgejo/workflows/test.yml index 9ca4029..c8c4149 100644 --- a/.forgejo/workflows/test.yml +++ b/.forgejo/workflows/test.yml @@ -16,11 +16,6 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Build Hello World Docker image - run: | - echo -e 'FROM alpine\nCMD echo Hello, World!' > Dockerfile - docker build -t hello-world:latest . - - name: Login to Container Registry uses: docker/login-action@v3 with: @@ -28,7 +23,22 @@ jobs: username: ${{ secrets.REGISTRY_USERNAME }} password: ${{ secrets.REGISTRY_TOKEN }} - - name: Push Docker image to Container Registry + - name: Build and push web image to Container Registry run: | - docker tag hello-world:latest git.hamburg.ccc.de/ccchh/sunders/tmp:latest - docker push git.hamburg.ccc.de/ccchh/sunders/tmp:latest \ No newline at end of file + docker build -t web:latest . + docker tag web:latest git.hamburg.ccc.de/ccchh/sunders/web:latest + docker push git.hamburg.ccc.de/ccchh/sunders/web:latest + working-directory: ./www/sunders + + - name: Build and push db image to Container Registry + run: | + docker build -t db:latest . + docker tag db:latest git.hamburg.ccc.de/ccchh/sunders/db:latest + docker push git.hamburg.ccc.de/ccchh/sunders/db:latest + working-directory: ./home/sunders/init_cameras/db + + - name: Start Docker Compose services + run: | + docker compose up -d --wait + docker compose down + working-directory: / \ No newline at end of file diff --git a/.gitignore b/.gitignore index 248c90c..1dfd0f6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ change_file.osc* -config.php lastState.txt lastStatisticsUpdate.txt log.* diff --git a/README.md b/README.md index d86ca69..1cd6e04 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,7 @@ If you like to run Surveillance under Surveillance on your own LAMP or LNMP serv - Rename the file **config.php.example** to **config.php**. - - Open the file **config.php** and enter the **MYSQL_PASSWD** of the database user **camera**. Furthermore enter the **REPLICATE_URL** that fits to your project, e.g. from [planet.openstreetmap.org](https://planet.openstreetmap.org/replication/) or from [download.openstreetmap.fr](http://download.openstreetmap.fr/replication/). Here are some examples: + - Open the file **config.php** and enter the **MYSQL_PASSWORD** of the database user **camera**. Furthermore enter the **REPLICATE_URL** that fits to your project, e.g. from [planet.openstreetmap.org](https://planet.openstreetmap.org/replication/) or from [download.openstreetmap.fr](http://download.openstreetmap.fr/replication/). Here are some examples: `https://planet.openstreetmap.org/replication/minute/` `http://download.openstreetmap.fr/replication/planet/minute/` diff --git a/docker-compose.yml b/docker-compose.yml index 82ab0cd..21320b0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,12 +1,12 @@ version: '3.8' services: db: - image: mysql:9.4 + image: git.hamburg.ccc.de/ccchh/sunders/db:latest environment: - MYSQL_ROOT_PASSWORD: rootpassword - MYSQL_DATABASE: camera - MYSQL_USER: camera - MYSQL_PASSWORD: camerapassword + MYSQL_ROOT_PASSWORD: rootpassword # ${{secrets.MYSQL_ROOT_PASSWORD}} + MYSQL_DATABASE: camera # ${{secrets.MYSQL_DATABASE}} + MYSQL_USER: camera # ${{secrets.MYSQL_USER}} + MYSQL_PASSWORD: camerapassword # ${{secrets.MYSQL_PASSWORD}} ports: - "3306:3306" healthcheck: @@ -14,16 +14,14 @@ services: interval: 10s timeout: 5s retries: 5 - volumes: - - ./home/sunders/init_cameras/db:/docker-entrypoint-initdb.d web: - build: ./www/sunders + image: git.hamburg.ccc.de/ccchh/sunders/web:latest environment: MYSQL_HOST: db - MYSQL_DB: camera - MYSQL_USER: camera - MYSQL_PASSWORD: camerapassword + MYSQL_DB: camera # ${{secrets.MYSQL_DATABASE}} + MYSQL_USER: camera # ${{secrets.MYSQL_USER}} + MYSQL_PASSWORD: camerapassword # ${{secrets.MYSQL_PASSWORD}} DEFAULT_ZOOM: 12 DEFAULT_LAT: 0 DEFAULT_LON: 0 @@ -33,30 +31,4 @@ services: depends_on: - db volumes: - - ./www/sunders:/var/www/html - - # setup: - # image: alpine:latest - # volumes: - # - ./home/sunders/init_cameras/:/init_cameras - # working_dir: /init_cameras - # environment: - # MYSQL_ROOT_PASSWORD: rootpassword - # MYSQL_DATABASE: camera - # MYSQL_USER: camera - # MYSQL_PASSWORD: camerapassword - # entrypoint: ["/bin/sh", "-c", "./createInitialDataFiles.sh"] - # depends_on: - # - db - - # updater: - # build: ./home/sunders/update_cameras - # environment: - # MYSQL_PASSWORD: camerapassword - # depends_on: - # - db - # # Uncomment to run periodically - # # deploy: - # # replicas: 1 - # # restart_policy: - # # condition: on-failure \ No newline at end of file + - ./www/sunders:/var/www/html \ No newline at end of file diff --git a/home/sunders/init_cameras/db/Dockerfile b/home/sunders/init_cameras/db/Dockerfile new file mode 100644 index 0000000..292d6cd --- /dev/null +++ b/home/sunders/init_cameras/db/Dockerfile @@ -0,0 +1,3 @@ +FROM mysql:9.4 + +COPY ./scripts /docker-entrypoint-initdb.d/ \ No newline at end of file diff --git a/home/sunders/init_cameras/db/createDB.sql b/home/sunders/init_cameras/db/scripts/01-createDB.sql similarity index 65% rename from home/sunders/init_cameras/db/createDB.sql rename to home/sunders/init_cameras/db/scripts/01-createDB.sql index 71f574b..95a09d0 100644 --- a/home/sunders/init_cameras/db/createDB.sql +++ b/home/sunders/init_cameras/db/scripts/01-createDB.sql @@ -1,9 +1,5 @@ -create database camera; use camera; -grant all privileges on camera.* to camera@localhost identified by 'xxxxxxxx'; -grant select on camera.* to camselect@localhost; - CREATE TABLE position ( id BIGINT PRIMARY KEY, latitude INT, diff --git a/home/sunders/init_cameras/db/addStatistics.sql b/home/sunders/init_cameras/db/scripts/02-addStatistics.sql similarity index 100% rename from home/sunders/init_cameras/db/addStatistics.sql rename to home/sunders/init_cameras/db/scripts/02-addStatistics.sql diff --git a/home/sunders/init_cameras/db/initializeDB_planet_20120912.sql b/home/sunders/init_cameras/db/scripts/02-exampleData.sql similarity index 100% rename from home/sunders/init_cameras/db/initializeDB_planet_20120912.sql rename to home/sunders/init_cameras/db/scripts/02-exampleData.sql diff --git a/home/sunders/update_cameras/config.php.example b/home/sunders/update_cameras/config.php.example index 641fc38..a2539d3 100644 --- a/home/sunders/update_cameras/config.php.example +++ b/home/sunders/update_cameras/config.php.example @@ -5,7 +5,7 @@ define('REPLICATE_URL', 'https://planet.openstreetmap.org/replication/minute'); define('MYSQL_HOST', 'localhost'); define('MYSQL_DB', 'camera'); define('MYSQL_USER', 'camera'); -define('MYSQL_PASSWD', 'xxxxxxxx'); +define('MYSQL_PASSWORD', 'xxxxxxxx'); define('USE_STATISTICS', false); define('WEBSERVICE_COUNTRY_URL', 'http://api.geonames.org/countryCode'); diff --git a/home/sunders/update_cameras/update_camera.php b/home/sunders/update_cameras/update_camera.php index 21a2aaa..75bd3b4 100755 --- a/home/sunders/update_cameras/update_camera.php +++ b/home/sunders/update_cameras/update_camera.php @@ -15,7 +15,7 @@ $id = 0; $latitude = 0; $longitude = 0; -$mysqli = new mysqli(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWD, MYSQL_DB); +$mysqli = new mysqli(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DB); if($mysqli->connect_errno) { echo "Error while connecting to DB : $mysqli->error \n" ; diff --git a/home/sunders/update_cameras/update_statistics.php b/home/sunders/update_cameras/update_statistics.php index f6b9332..f6bcc7a 100644 --- a/home/sunders/update_cameras/update_statistics.php +++ b/home/sunders/update_cameras/update_statistics.php @@ -4,7 +4,7 @@ include "config.php"; if (USE_STATISTICS) { - $mysqli = new mysqli(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWD, MYSQL_DB); + $mysqli = new mysqli(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DB); if ($mysqli->connect_errno) { echo "Error while connecting to DB : ".$mysqli->error." \n" ; diff --git a/www/sunders/Dockerfile b/www/sunders/Dockerfile new file mode 100644 index 0000000..80133e8 --- /dev/null +++ b/www/sunders/Dockerfile @@ -0,0 +1,13 @@ +FROM php:8.2-apache +COPY . /var/www/html/ +WORKDIR /var/www/html/ +# Enable Apache mod_rewrite if needed +RUN a2enmod rewrite +# Set permissions if needed +ENV DEFAULT_ZOOM=12 +ENV DEFAULT_LAT=0 +ENV DEFAULT_LON=0 +ENV DEFAULT_LANGUAGE=en +ENV MYSQL_PASSWORD=changeme +# Optionally install extensions +RUN docker-php-ext-install mysqli bcmath \ No newline at end of file diff --git a/www/sunders/camera.php b/www/sunders/camera.php index 96707f7..6dba487 100644 --- a/www/sunders/camera.php +++ b/www/sunders/camera.php @@ -1,6 +1,6 @@ connect_errno) { header('Content-type: application/json'); $result = '{"error":"error while connecting to db : ' . $mysqli->error . '"}'; diff --git a/www/sunders/config.php b/www/sunders/config.php new file mode 100644 index 0000000..c874eca --- /dev/null +++ b/www/sunders/config.php @@ -0,0 +1,15 @@ + \ No newline at end of file diff --git a/www/sunders/config.php.example b/www/sunders/config.php.example deleted file mode 100644 index 6df3a3f..0000000 --- a/www/sunders/config.php.example +++ /dev/null @@ -1,17 +0,0 @@ - diff --git a/www/sunders/stats/index.php b/www/sunders/stats/index.php index 029e42c..7a0dac4 100644 --- a/www/sunders/stats/index.php +++ b/www/sunders/stats/index.php @@ -138,7 +138,7 @@ $statsQueryObject = $levelObject->{$statsKey}; /* Connect to database */ - $mysqli = new mysqli(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWD, MYSQL_DB); + $mysqli = new mysqli(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DB); if($mysqli->connect_errno) { echo 'Error while connecting to DB : $mysqli->error \n' ; exit(1);