|
| 1 | +name: Docker Test |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + pull_request: |
| 7 | + branches: [main] |
| 8 | + |
| 9 | +jobs: |
| 10 | + validate-compose-files: |
| 11 | + name: Validate Docker Compose Files |
| 12 | + runs-on: ubuntu-latest |
| 13 | + steps: |
| 14 | + - uses: actions/checkout@v3 |
| 15 | + |
| 16 | + - name: Setup environment file |
| 17 | + run: | |
| 18 | + cp env.example .env |
| 19 | +
|
| 20 | + - name: Validate base docker-compose file |
| 21 | + run: docker compose config |
| 22 | + |
| 23 | + - name: Validate docker-compose with NGINX |
| 24 | + run: | |
| 25 | + docker compose -f docker-compose.yml -f docker-compose.nginx.yml config |
| 26 | +
|
| 27 | + - name: Validate docker-compose without NGINX |
| 28 | + run: docker compose -f docker-compose.yml -f docker-compose.without-nginx.yml config |
| 29 | + |
| 30 | + test-docker-deployment: |
| 31 | + name: Test Docker Deployment |
| 32 | + runs-on: ubuntu-latest |
| 33 | + needs: validate-compose-files |
| 34 | + steps: |
| 35 | + - uses: actions/checkout@v3 |
| 36 | + |
| 37 | + - name: Create required directories |
| 38 | + run: | |
| 39 | + mkdir -p ./volumes/app/mattermost/{config,data,logs,plugins,client/plugins,bleve-indexes} |
| 40 | + sudo chown -R 2000:2000 ./volumes/app/mattermost |
| 41 | +
|
| 42 | + - name: Setup environment file |
| 43 | + run: | |
| 44 | + cp env.example .env |
| 45 | + sed -i 's/DOMAIN=mm.example.com/DOMAIN=localhost/g' .env |
| 46 | +
|
| 47 | + - name: Start Mattermost without NGINX |
| 48 | + run: | |
| 49 | + # Configure docker-compose to use without-nginx setup |
| 50 | + docker compose -f docker-compose.yml -f docker-compose.without-nginx.yml up -d |
| 51 | +
|
| 52 | + - name: Verify containers are running |
| 53 | + run: | |
| 54 | + # Allow time for containers to start |
| 55 | + sleep 30 |
| 56 | + docker ps |
| 57 | + docker compose ps |
| 58 | +
|
| 59 | + - name: Check container logs |
| 60 | + run: | |
| 61 | + # Check logs for any issues |
| 62 | + docker compose logs mattermost --tail 20 |
| 63 | + docker compose logs postgres --tail 20 |
| 64 | +
|
| 65 | + - name: Verify Mattermost API is accessible |
| 66 | + run: | |
| 67 | + # Check that API is responding |
| 68 | + curl -f --retry 10 --retry-delay 5 --retry-connrefused http://localhost:8065/api/v4/system/ping || exit 1 |
| 69 | +
|
| 70 | + - name: Stop containers |
| 71 | + run: | |
| 72 | + # Clean up containers |
| 73 | + docker compose down |
| 74 | + if: always() |
0 commit comments