From 6776bf9726dd5d1badfc26709ef1f6a3d6ae9121 Mon Sep 17 00:00:00 2001 From: matt Date: Sat, 17 Oct 2026 04:43:52 -0700 Subject: [PATCH] initial docker setup --- Dockerfile | 40 ++++++++++++++++++++++++++++++++++++++++ apache_ports.conf | 5 +++++ apache_vhost.conf | 14 ++++++++++++++ api/database.py | 2 +- docker-compose.yaml | 20 ++++++++++++++++++++ supervisord.conf | 25 +++++++++++++++++++++++++ web/add_provider.php | 18 ++++++++++++++---- web/index.php | 0 8 files changed, 119 insertions(+), 5 deletions(-) create mode 100644 Dockerfile create mode 100644 apache_ports.conf create mode 100644 apache_vhost.conf create mode 100644 docker-compose.yaml create mode 100644 supervisord.conf create mode 100644 web/index.php diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..99ca85f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,40 @@ + +# Base image +FROM php:8.1-apache + +# Install system packages +RUN apt-get update && apt-get install -y --no-install-recommends \ + # Python + python3 python3-venv python3-pip \ + # Process supervisor + supervisor \ + # Others + net-tools curl \ + # Clean up + && rm -rf /var/lib/apt/lists/* + +# Apache on 8069 +COPY apache_ports.conf /etc/apache2/ports.conf +COPY apache_vhost.conf /etc/apache2/sites-available/000-default.conf +COPY web/ /var/www/html/ + +# API on 5000 +RUN mkdir -p /opt/Fitness +RUN python3 -m venv /opt/Fitness/venv +# COPY apis/StorageSummary/requirements.txt /opt/Fitness/ +RUN /opt/Fitness/venv/bin/pip3 install --no-cache-dir +# -r /opt/Fitness/requirements.txt +# Copy the actual app code after installing deps +COPY api/ /opt/Fitness/ + +# Add supervisord configuration +COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf + +# Expose ports +EXPOSE 8069 + +# healthcheck looks for apache +HEALTHCHECK CMD netstat -ltn | grep -c ":8069" > /dev/null; if [ 0 != $? ]; then exit 1; fi; + +# Start supervisord +CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"] \ No newline at end of file diff --git a/apache_ports.conf b/apache_ports.conf new file mode 100644 index 0000000..4e3b231 --- /dev/null +++ b/apache_ports.conf @@ -0,0 +1,5 @@ +# Listen on 8069 inside the container +Listen 8069 + +# If you still want Apache to listen on 80 (rare), add it back: +# Listen 80 \ No newline at end of file diff --git a/apache_vhost.conf b/apache_vhost.conf new file mode 100644 index 0000000..376e5d3 --- /dev/null +++ b/apache_vhost.conf @@ -0,0 +1,14 @@ + + ServerAdmin webmaster@localhost + DocumentRoot /var/www/html + + # Log files + ErrorLog /dev/stdout + CustomLog /dev/stdout combined + + # If you need PHP processing + + AllowOverride All + Require all granted + + \ No newline at end of file diff --git a/api/database.py b/api/database.py index 818f2e3..0c86ab1 100644 --- a/api/database.py +++ b/api/database.py @@ -4,7 +4,7 @@ import os from typing import List, Dict, Any, Optional # Path to the SQLite database file -DB_PATH = os.path.join(os.path.dirname(__file__), "fitness.db") +DB_PATH = os.path.join(os.path.dirname(__file__), "/db_file/fitness.db") # Ensure the database directory exists os.makedirs(os.path.dirname(DB_PATH), exist_ok=True) diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..49186b6 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,20 @@ +--- +name: cosmostat +services: + + cosmostat-dash: + build: + context: . + dockerfile: Dockerfile + container_name: cosmostat-dash + image: cosmostat-dash:latest + restart: always + network_mode: bridge + ports: + - "8069:8069" + volumes: + # make sure to keep the database file + - "./database:/opt/Fitness/api/database" + + +... \ No newline at end of file diff --git a/supervisord.conf b/supervisord.conf new file mode 100644 index 0000000..3360855 --- /dev/null +++ b/supervisord.conf @@ -0,0 +1,25 @@ +[supervisord] +nodaemon=true +logfile=/dev/stdout +logfile_maxbytes=0 + +# ------------------------------------------------------------------ +# 1. Apache (from the base image) +# ------------------------------------------------------------------ +[program:apache2] +command=/usr/sbin/apache2ctl -D FOREGROUND +stdout_logfile=/dev/stdout +stderr_logfile=/dev/stderr +autorestart=true +priority=1 + +# ---------------------------------------------------------- +# 2. Fitness app +# ---------------------------------------------------------- +[program:Fitness] +command=/opt/Fitness/venv/bin/python3 /opt/Fitness/app.py +directory=/opt/Fitness +stdout_logfile=/dev/stdout +stderr_logfile=/dev/stderr +autorestart=true +priority=2 \ No newline at end of file diff --git a/web/add_provider.php b/web/add_provider.php index 4d90712..5b77eda 100644 --- a/web/add_provider.php +++ b/web/add_provider.php @@ -32,11 +32,14 @@ function callApi(string $method, string $path, $body = null) $rateOptionsSetting = callApi('GET', '/settings/rate_options'); $rateOptions = []; if ($rateOptionsSetting && isset($rateOptionsSetting['value'])) { + $rateOptions = explode(',', $rateOptionsSetting['value']); + /* $parsed = json_decode($rateOptionsSetting['value'], true); if (is_array($parsed)) { $rateOptions = $parsed; } - echo "Rate options:".$parsed; + echo "Rate options:".$rateOptionsSetting['value']; + */ } // Update form handling to process selected rates @@ -110,6 +113,10 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
+ @@ -117,10 +124,13 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { diff --git a/web/index.php b/web/index.php new file mode 100644 index 0000000..e69de29