Update Caddyfile #42
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test Dockerfile | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build: | |
name: Test on Ubuntu | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check Docker daemon | |
run: docker info || sudo service docker start | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3.7.1 | |
- name: Install Docker Compose | |
run: | | |
sudo curl -L "https://github.com/docker/compose/releases/download/v2.30.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose | |
sudo chmod +x /usr/local/bin/docker-compose | |
docker-compose --version | |
- name: Create necessary directories on the host | |
run: | | |
mkdir -p ./humhub/protected/config | |
mkdir -p ./humhub/protected/runtime | |
mkdir -p ./humhub/protected/modules | |
touch ./humhub/protected/config/main.php # Example configuration file (you can add more files as necessary) | |
- name: Create test docker-compose file | |
run: | | |
cat > docker-compose.test.yml << 'EOF' | |
version: "3.8" | |
services: | |
humhub: | |
build: . | |
ports: | |
- "80:80" | |
- "443:443" | |
volumes: | |
- ./humhub:/app | |
environment: | |
- PHP_MEMORY_LIMIT=512M | |
- PHP_MAX_EXECUTION_TIME=300 | |
- HUMHUB_DB_HOST=db | |
- HUMHUB_DB_NAME=humhub_test | |
- HUMHUB_DB_USER=humhubuser | |
- HUMHUB_DB_PASSWORD=humhubpassword | |
- SERVER_NAME=:80 | |
- PHP_INI_MEMORY_LIMIT=512M | |
- PHP_INI_MAX_EXECUTION_TIME=300 | |
depends_on: | |
- db | |
networks: | |
- humhub_test_network | |
db: | |
image: mysql:8 | |
environment: | |
MYSQL_ROOT_PASSWORD: rootpassword | |
MYSQL_DATABASE: humhub_test | |
MYSQL_USER: humhubuser | |
MYSQL_PASSWORD: humhubpassword | |
healthcheck: | |
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "humhubuser", "-phumhubpassword"] | |
interval: 5s | |
timeout: 5s | |
retries: 10 | |
networks: | |
- humhub_test_network | |
networks: | |
humhub_test_network: | |
driver: bridge | |
EOF | |
- name: Build containers | |
run: docker-compose -f docker-compose.test.yml build --no-cache | |
- name: Start containers and debug | |
run: | | |
docker-compose -f docker-compose.test.yml up -d | |
echo "Waiting for containers to start..." | |
sleep 10 | |
echo "Docker compose ps:" | |
docker-compose -f docker-compose.test.yml ps | |
echo "Docker compose logs:" | |
docker-compose -f docker-compose.test.yml logs | |
echo "Container status:" | |
docker ps -a | |
- name: Debug container startup | |
if: failure() | |
run: | | |
echo "Checking humhub container logs..." | |
docker-compose -f docker-compose.test.yml logs humhub | |
echo "Checking container filesystem..." | |
docker-compose -f docker-compose.test.yml exec -T humhub ls -la /app || true | |
echo "Checking Caddyfile..." | |
docker-compose -f docker-compose.test.yml exec -T humhub cat /etc/caddy/Caddyfile || true | |
echo "Checking FrankenPHP processes..." | |
docker-compose -f docker-compose.test.yml exec -T humhub ps aux || true | |
- name: Verify MySQL is ready | |
run: | | |
echo "Waiting for MySQL to be ready..." | |
timeout 60s bash -c 'until docker-compose -f docker-compose.test.yml exec -T db mysqladmin -u root -prootpassword ping; do sleep 1; done' | |
- name: Grant MySQL privileges | |
run: | | |
RETRIES=5 | |
until docker-compose -f docker-compose.test.yml exec -T db mysql -u root -prootpassword -e "CREATE USER IF NOT EXISTS 'humhubuser'@'%' IDENTIFIED BY 'humhubpassword';" || [ $RETRIES -eq 0 ]; do | |
echo "Retrying MySQL user creation..." | |
((RETRIES--)) | |
sleep 5 | |
done | |
docker-compose -f docker-compose.test.yml exec -T db mysql -u root -prootpassword -e "GRANT ALL PRIVILEGES ON humhub_test.* TO 'humhubuser'@'%'; FLUSH PRIVILEGES;" | |
- name: Verify PHP and FrankenPHP | |
run: | | |
docker-compose -f docker-compose.test.yml exec -T humhub php -v || echo "::error::PHP verification failed" | |
docker-compose -f docker-compose.test.yml exec -T humhub frankenphp version || echo "::error::FrankenPHP verification failed" | |
- name: Verify PHP extensions | |
run: | | |
docker-compose -f docker-compose.test.yml exec -T humhub php -m || echo "::error::Unable to list PHP extensions" | |
- name: Verify HumHub files | |
run: | | |
docker-compose -f docker-compose.test.yml exec -T humhub ls -la /app || echo "::error::HumHub files verification failed" | |
docker-compose -f docker-compose.test.yml exec -T humhub ls -la /app/protected/config || echo "::error::Config directory not found" | |
docker-compose -f docker-compose.test.yml exec -T humhub ls -la /app/protected/modules || echo "::error::Modules directory not found" | |
docker-compose -f docker-compose.test.yml exec -T humhub ls -la /app/protected || echo "::error::Protected directory not found" | |
- name: Verify cron setup | |
run: | | |
docker-compose -f docker-compose.test.yml exec -T humhub ps aux | grep cron || echo "::error::Cron service is not running" | |
docker-compose -f docker-compose.test.yml exec -T humhub cat /etc/cron.d/humhub || echo "::error::Crontab is missing or not configured correctly" | |
docker-compose -f docker-compose.test.yml exec -T humhub ls -la /usr/local/bin/humhub-cron.sh || echo "::error::Cron script not found" | |
- name: Show container logs | |
if: always() | |
run: docker-compose -f docker-compose.test.yml logs | |
- name: Cleanup | |
if: always() | |
run: | | |
docker-compose -f docker-compose.test.yml down -v | |
docker-compose -f docker-compose.test.yml rm -f -v |