Files
crewsportswear/docker-compose.local.yml

153 lines
5.0 KiB
YAML

# ─────────────────────────────────────────────────────────────────────────────
# Local development stack
#
# Default (local MariaDB):
# docker compose -f docker-compose.local.yml up --build
#
# Remote DB via SSH private-key tunnel:
# 1. Set SSH_HOST, SSH_USER, SSH_KEY_PATH, SSH_DB_REMOTE_HOST,
# SSH_DB_REMOTE_PORT (and DB_* creds) in .env.local
# 2. docker compose -f docker-compose.local.yml --profile ssh-db up --build
# The app will talk to db-tunnel (port 3306) instead of the local db.
#
# App: http://localhost:8082
# phpMyAdmin: http://localhost:8083
# ─────────────────────────────────────────────────────────────────────────────
services:
db:
image: mariadb:10.6
platform: linux/arm64
container_name: crewsportswear_db_local
restart: unless-stopped
environment:
MYSQL_DATABASE: crewsportswear
MYSQL_ROOT_PASSWORD: root
MYSQL_USER: crewsportswear
MYSQL_PASSWORD: secret
ports:
- "3307:3306"
volumes:
- db_data:/var/lib/mysql
networks:
- crewsportswear-local
app:
build:
context: .
dockerfile: Dockerfile
container_name: crewsportswear_app_local
restart: unless-stopped
ports:
- "8082:80"
environment:
- APP_ENV=local
- APP_DEBUG=true
- APP_URL=http://localhost:8082
- DB_CONNECTION=mysql
- DB_PORT=${DB_PORT:-3306}
- PROD_PRIVATE=http://localhost:8082
- IMAGES_URL=http://localhost:8082
- UPLOAD_URL=http://localhost:8082/uploads/
- MAIL_DRIVER=log
- MAIL_HOST=localhost
- MAIL_PORT=1025
- MAIL_USERNAME=null
- MAIL_PASSWORD=null
- MAIL_ENCRYPTION=null
- CAPTCHA_SITE_KEY=test_key
- CAPTCHA_SECRET_KEY=test_secret
- ANALYTICS_SITE_ID=
- ANALYTICS_CLIENT_ID=
- ANALYTICS_SERVICE_EMAIL=
# MinIO S3 Storage (connect to production MinIO for testing)
- MINIO_ENDPOINT=https://minio.crewsportswear.app
- MINIO_KEY=${MINIO_KEY:-minioadmin}
- MINIO_SECRET=${MINIO_SECRET:-minioadmin}
- MINIO_BUCKET=crewsportswear
- MINIO_REGION=us-east-1
- MINIO_USE_PATH_STYLE=false
- MINIO_URL=https://minio.crewsportswear.app
# DB_HOST defaults to local container; set to db-tunnel in .env.local for SSH mode
- DB_HOST=${DB_HOST:-db}
- DB_DATABASE=${DB_DATABASE:-crewsportswear}
- DB_USERNAME=${DB_USERNAME:-crewsportswear}
- DB_PASSWORD=${DB_PASSWORD:-secret}
env_file:
- path: .env.local
required: false
volumes:
- ./:/var/www/html
- ./storage:/var/www/html/storage
- ./public/uploads:/var/www/html/public/uploads
# Keep the vendor/ directory from the image — prevents the bind-mount
# from wiping out the composer install done during docker build.
- vendor_local:/var/www/html/vendor
depends_on:
- db
networks:
- crewsportswear-local
# ── SSH tunnel to a remote database ────────────────────────────────────────
# Activated only with: --profile ssh-db
# Requires SSH_HOST, SSH_USER, SSH_KEY_PATH (and optionally SSH_PORT,
# SSH_DB_REMOTE_HOST, SSH_DB_REMOTE_PORT) set in .env.local.
db-tunnel:
profiles:
- ssh-db
image: alpine:3.19
container_name: crewsportswear_db_tunnel
restart: unless-stopped
environment:
- SSH_HOST=${SSH_HOST}
- SSH_PORT=${SSH_PORT:-22}
- SSH_USER=${SSH_USER:-root}
- SSH_DB_REMOTE_HOST=${SSH_DB_REMOTE_HOST:-127.0.0.1}
- SSH_DB_REMOTE_PORT=${SSH_DB_REMOTE_PORT:-3306}
volumes:
# Mount your private key read-only; path configured in .env.local
- ${SSH_KEY_PATH:-~/.ssh/id_rsa}:/ssh/id_rsa:ro
command:
- sh
- -c
- |
apk add --no-cache openssh-client
cp /ssh/id_rsa /tmp/id_rsa
chmod 600 /tmp/id_rsa
echo "Starting SSH tunnel to $$SSH_HOST..."
exec ssh -N \
-o StrictHostKeyChecking=no \
-o ServerAliveInterval=30 \
-o ServerAliveCountMax=3 \
-o ExitOnForwardFailure=yes \
-i /tmp/id_rsa \
-L "0.0.0.0:3306:$$SSH_DB_REMOTE_HOST:$$SSH_DB_REMOTE_PORT" \
-p "$$SSH_PORT" \
"$$SSH_USER@$$SSH_HOST"
networks:
- crewsportswear-local
phpmyadmin:
image: arm64v8/phpmyadmin
platform: linux/arm64
container_name: crewsportswear_phpmyadmin
restart: unless-stopped
ports:
- "8083:80"
environment:
PMA_HOST: db
PMA_PORT: 3306
MYSQL_ROOT_PASSWORD: root
depends_on:
- db
networks:
- crewsportswear-local
networks:
crewsportswear-local:
driver: bridge
volumes:
db_data:
vendor_local: