initial docker setup
This commit is contained in:
1 parent
2e3e8d8514
commit
6776bf9726
8 files changed
+119
-5
No files matched your search
+40
@@ -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"]
|
||||||
@@ -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
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<VirtualHost *:8069>
|
||||||
|
ServerAdmin webmaster@localhost
|
||||||
|
DocumentRoot /var/www/html
|
||||||
|
|
||||||
|
# Log files
|
||||||
|
ErrorLog /dev/stdout
|
||||||
|
CustomLog /dev/stdout combined
|
||||||
|
|
||||||
|
# If you need PHP processing
|
||||||
|
<Directory /var/www/html>
|
||||||
|
AllowOverride All
|
||||||
|
Require all granted
|
||||||
|
</Directory>
|
||||||
|
</VirtualHost>
|
||||||
+1
-1
@@ -4,7 +4,7 @@ import os
|
|||||||
from typing import List, Dict, Any, Optional
|
from typing import List, Dict, Any, Optional
|
||||||
|
|
||||||
# Path to the SQLite database file
|
# 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
|
# Ensure the database directory exists
|
||||||
os.makedirs(os.path.dirname(DB_PATH), exist_ok=True)
|
os.makedirs(os.path.dirname(DB_PATH), exist_ok=True)
|
||||||
|
|||||||
@@ -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"
|
||||||
|
|
||||||
|
|
||||||
|
...
|
||||||
@@ -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
|
||||||
+14
-4
@@ -32,11 +32,14 @@ function callApi(string $method, string $path, $body = null)
|
|||||||
$rateOptionsSetting = callApi('GET', '/settings/rate_options');
|
$rateOptionsSetting = callApi('GET', '/settings/rate_options');
|
||||||
$rateOptions = [];
|
$rateOptions = [];
|
||||||
if ($rateOptionsSetting && isset($rateOptionsSetting['value'])) {
|
if ($rateOptionsSetting && isset($rateOptionsSetting['value'])) {
|
||||||
|
$rateOptions = explode(',', $rateOptionsSetting['value']);
|
||||||
|
/*
|
||||||
$parsed = json_decode($rateOptionsSetting['value'], true);
|
$parsed = json_decode($rateOptionsSetting['value'], true);
|
||||||
if (is_array($parsed)) {
|
if (is_array($parsed)) {
|
||||||
$rateOptions = $parsed;
|
$rateOptions = $parsed;
|
||||||
}
|
}
|
||||||
echo "Rate options:".$parsed;
|
echo "Rate options:".$rateOptionsSetting['value'];
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update form handling to process selected rates
|
// Update form handling to process selected rates
|
||||||
@@ -110,6 +113,10 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<form method="post" action="">
|
<form method="post" action="">
|
||||||
|
<?php
|
||||||
|
echo $rateOptions[0];
|
||||||
|
|
||||||
|
?>
|
||||||
<label>Name:<br><input type="text" name="name" value="<?=htmlspecialchars($_POST['name'] ?? '')?>" required></label>
|
<label>Name:<br><input type="text" name="name" value="<?=htmlspecialchars($_POST['name'] ?? '')?>" required></label>
|
||||||
<label>Phone:<br><input type="text" name="phone" value="<?=htmlspecialchars($_POST['phone'] ?? '')?>"></label>
|
<label>Phone:<br><input type="text" name="phone" value="<?=htmlspecialchars($_POST['phone'] ?? '')?>"></label>
|
||||||
<label>Age:<br><input type="number" name="age" value="<?=htmlspecialchars($_POST['age'] ?? '')?>"></label>
|
<label>Age:<br><input type="number" name="age" value="<?=htmlspecialchars($_POST['age'] ?? '')?>"></label>
|
||||||
@@ -117,10 +124,13 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
<?php if (!empty($rateOptions)) : ?>
|
<?php if (!empty($rateOptions)) : ?>
|
||||||
<label>Rate Options:<br>
|
<label>Rate Options:<br>
|
||||||
<?php foreach ($rateOptions as $option) :
|
<?php foreach ($rateOptions as $option) :
|
||||||
$key = key($option);
|
// echo $option;
|
||||||
$value = $option[$key];
|
$key = $option;
|
||||||
|
$value = 0;
|
||||||
?>
|
?>
|
||||||
<input type="checkbox" name="rates[]" value="<?=htmlspecialchars($key . ':' . $value)?>" <?php if (in_array($key . ':' . $value, $selectedRates)) echo 'checked'; ?>> <?=htmlspecialchars($key)?>: <?=htmlspecialchars($value)?>
|
<input type="checkbox" name="rates[]" value="<?=htmlspecialchars($key . ':' . $value)?>"
|
||||||
|
<?php if (in_array($key . ':' . $value, $selectedRates)) echo 'checked'; ?>>
|
||||||
|
<?=htmlspecialchars($key)?>: <?=htmlspecialchars($value)?> <br>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</label>
|
</label>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|||||||
Whitespace-only changes.
Reference in new issue
Block a user