podman compose, etc.
This commit is contained in:
+51
-34
@@ -1,50 +1,67 @@
|
|||||||
---
|
---
|
||||||
services:
|
services:
|
||||||
app:
|
spaces:
|
||||||
build: .
|
build: ./web
|
||||||
container_name: spaces
|
container_name: spaces
|
||||||
ports:
|
ports:
|
||||||
- "2025:2025"
|
- "2025:2025" # Standard HTTP port for the web server
|
||||||
volumes:
|
volumes:
|
||||||
# Mounts the project code into the container.
|
|
||||||
# This makes git pulls faster after the first run.
|
|
||||||
- ./web:/var/www/html
|
- ./web:/var/www/html
|
||||||
environment:
|
|
||||||
# --- Git Settings ---
|
|
||||||
# ⚠️ Use a secure Personal Access Token (PAT) for the URL
|
|
||||||
- GIT_REPO_URL=https://${GITHUB_USER}:${GITHUB_PAT}@github.com/${GITHUB_USER}/${SPACES_REPO}.git
|
|
||||||
- GIT_BRANCH=main
|
|
||||||
|
|
||||||
# --- Database Connection Settings (for your PHP app) ---
|
|
||||||
- DB_HOST=db
|
|
||||||
- DB_DATABASE=mydatabase
|
|
||||||
- DB_USER=myuser
|
|
||||||
- DB_PASSWORD=mypassword
|
|
||||||
|
|
||||||
# --- Backup Script Settings ---
|
|
||||||
# These credentials are used by mysqldump inside the container
|
|
||||||
- MARIADB_USER=${DB_USER}
|
|
||||||
- MARIADB_PASSWORD=${DB_PASSWORD}
|
|
||||||
- MARIADB_DATABASE=${DB_DATABASE}
|
|
||||||
- MARIADB_HOST=db # The service name from this compose file
|
|
||||||
depends_on:
|
depends_on:
|
||||||
- db # Ensures the 'db' container starts before the 'app' container
|
- spaces_api
|
||||||
|
|
||||||
db:
|
spaces_api:
|
||||||
image: mariadb:latest
|
build: ./api
|
||||||
|
container_name: spaces_api
|
||||||
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- "7476:7476"
|
||||||
|
volumes:
|
||||||
|
- spaces_api_logs:/app/logs # Persistent volume for logs
|
||||||
|
depends_on:
|
||||||
|
spaces_db:
|
||||||
|
condition: service_healthy
|
||||||
|
environment:
|
||||||
|
# Pass DB credentials to the Go API
|
||||||
|
- VIPER_DBUSER=vintage
|
||||||
|
- VIPER_DBPASS=changeme
|
||||||
|
- VIPER_DBNAME=vintagecoding
|
||||||
|
- VIPER_DBHOST=spaces_db
|
||||||
|
|
||||||
|
spaces_api_tester:
|
||||||
|
build: ./api
|
||||||
|
container_name: spaces_api_tester
|
||||||
|
depends_on:
|
||||||
|
spaces_db:
|
||||||
|
condition: service_healthy
|
||||||
|
environment:
|
||||||
|
- VIPER_DBUSER=vintage
|
||||||
|
- VIPER_DBPASS=changeme
|
||||||
|
- VIPER_DBNAME=vintagecoding_test
|
||||||
|
- VIPER_DBHOST=spaces_db
|
||||||
|
- VIPER_DBPORT=3306
|
||||||
|
command: ["go", "test", "-v"]
|
||||||
|
|
||||||
|
spaces_db:
|
||||||
|
image: docker.io/mariadb:latest
|
||||||
container_name: spaces_db
|
container_name: spaces_db
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
|
||||||
|
interval: 10s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 3
|
||||||
volumes:
|
volumes:
|
||||||
# Persists database data on the host machine
|
- spaces_db_data:/var/lib/mysql
|
||||||
- db_data:/var/lib/mysql
|
|
||||||
environment:
|
environment:
|
||||||
- MARIADB_ROOT_PASSWORD=supersecretrootpassword
|
- MARIADB_ROOT_PASSWORD=QuaxlyQueen5012!
|
||||||
- MARIADB_DATABASE=mydatabase
|
- MARIADB_DATABASE=vintagecoding
|
||||||
- MARIADB_USER=myuser
|
- MARIADB_USER=vintage
|
||||||
- MARIADB_PASSWORD=mypassword
|
- MARIADB_PASSWORD=changeme
|
||||||
|
- MARIADB_EXTRA_DATABASES=vintagecoding_test
|
||||||
ports:
|
ports:
|
||||||
# Optional: Expose DB port to host for debugging with a GUI client
|
|
||||||
- "3306:3306"
|
- "3306:3306"
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
db_data: # Defines the named volume for the database
|
spaces_db_data:
|
||||||
|
spaces_api_logs:
|
||||||
|
|||||||
+1
-23
@@ -1,28 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
|
||||||
|
|
||||||
# --- Shutdown Handler ---
|
composer install
|
||||||
# This function will be called when the container receives a shutdown signal
|
|
||||||
cleanup() {
|
|
||||||
echo "SIGTERM received, initiating backup..."
|
|
||||||
/usr/local/bin/backup.sh # Execute the backup script
|
|
||||||
echo "Backup script finished. Exiting."
|
|
||||||
exit 0
|
|
||||||
}
|
|
||||||
|
|
||||||
# Trap the SIGTERM signal (sent by 'podman-compose down') and call the cleanup function
|
|
||||||
trap 'cleanup' SIGTERM
|
|
||||||
|
|
||||||
# --- Startup Logic ---
|
|
||||||
# Check if the target directory is a git repo. If not, clone it.
|
|
||||||
if [ ! -d "/var/www/html/.git" ]; then
|
|
||||||
echo "No git repository found. Cloning..."
|
|
||||||
# Clone the specified branch of the repository
|
|
||||||
git clone --branch ${GIT_BRANCH} ${GIT_REPO_URL} .
|
|
||||||
else
|
|
||||||
echo "Git repository found. Pulling latest changes..."
|
|
||||||
git pull origin ${GIT_BRANCH}
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Starting PHP built-in web server..."
|
echo "Starting PHP built-in web server..."
|
||||||
# Use 'exec' to replace the script process with the PHP server process.
|
# Use 'exec' to replace the script process with the PHP server process.
|
||||||
|
|||||||
Reference in New Issue
Block a user