Test Docker Support #2
This file contains hidden or 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 Docker Support | |
| on: | |
| workflow_dispatch: | |
| jobs: | |
| test-docker-basics: | |
| name: Docker Basics | |
| runs-on: [self-hosted, modal, "job-${{ github.run_id }}-${{ github.job }}"] | |
| steps: | |
| - name: Check Docker | |
| run: | | |
| docker version | |
| docker info | |
| - name: Run a container | |
| run: | | |
| docker run --rm hello-world | |
| - name: Docker build | |
| run: | | |
| mkdir -p /tmp/test-build | |
| cat > /tmp/test-build/Dockerfile <<'EOF' | |
| FROM alpine:3.19 | |
| RUN echo "build works" | |
| CMD ["echo", "hello from built image"] | |
| EOF | |
| docker build --network=host -t test-image /tmp/test-build | |
| docker run --rm test-image | |
| test-services: | |
| name: Docker Services (Postgres) | |
| runs-on: [self-hosted, modal, "job-${{ github.run_id }}-${{ github.job }}"] | |
| services: | |
| postgres: | |
| image: postgres:16-alpine | |
| env: | |
| POSTGRES_USER: test_user | |
| POSTGRES_PASSWORD: test_password | |
| POSTGRES_DB: test_db | |
| options: >- | |
| --health-cmd pg_isready | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| ports: | |
| - 5432:5432 | |
| steps: | |
| - name: Install psql | |
| run: | | |
| apt-get update && apt-get install -y postgresql-client | |
| - name: Test Postgres connection | |
| env: | |
| PGHOST: localhost | |
| PGPORT: 5432 | |
| PGUSER: test_user | |
| PGPASSWORD: test_password | |
| PGDATABASE: test_db | |
| run: | | |
| psql -c "SELECT version();" | |
| psql -c "CREATE TABLE test (id serial PRIMARY KEY, name varchar(100));" | |
| psql -c "INSERT INTO test (name) VALUES ('modal-docker-works');" | |
| psql -c "SELECT * FROM test;" | |
| - name: Summary | |
| if: always() | |
| run: | | |
| echo "## Docker Services Test" >> "$GITHUB_STEP_SUMMARY" | |
| echo "- Docker version: $(docker version --format '{{.Server.Version}}' 2>/dev/null || echo 'N/A')" >> "$GITHUB_STEP_SUMMARY" | |
| echo "- Status: ${{ job.status }}" >> "$GITHUB_STEP_SUMMARY" |