Skip to content

Update Dockerfile

Update Dockerfile #25

Workflow file for this run

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 test docker-compose file
run: |
cat > docker-compose.test.yml << 'EOF'
version: '3.9'
services:
humhub:
build: .
ports:
- "8080:8080"
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
depends_on:
db:
condition: service_healthy
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: Start containers
run: |
docker-compose -f docker-compose.test.yml up -d
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 and Set Authentication
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 database connection
run: |
docker-compose -f docker-compose.test.yml exec -T db \
mysql -uhumhubuser -phumhubpassword -e "SELECT NOW();" humhub_test
- name: Verify Docker image and Check PHP and Apache status
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 apache2 -v || echo "::error::Apache verification failed"
- name: Verify HumHub files
run: |
docker-compose -f docker-compose.test.yml exec -T humhub ls /var/www/html/app || echo "::error::HumHub files verification failed"
docker-compose -f docker-compose.test.yml exec -T humhub ls /var/www/html/app/protected/config || echo "::error::Config directory not found"
docker-compose -f docker-compose.test.yml exec -T humhub ls /var/www/html/app/protected/modules || echo "::error::Modules directory not found"
docker-compose -f docker-compose.test.yml exec -T humhub ls /var/www/html/app/protected || echo "::error::Protected directory not found"
- name: Verify cron service is running
run: |
docker-compose -f docker-compose.test.yml exec -T humhub service cron status || echo "::error::Cron service is not running"
- name: Verify crontab contents
run: |
docker-compose -f docker-compose.test.yml exec -T humhub cat /etc/cron.d/humhub-cron || echo "::error::Crontab is missing or not configured correctly"
- name: Run cron jobs manually for testing
run: |
docker-compose -f docker-compose.test.yml exec -T humhub cron -f &
- 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