-
Notifications
You must be signed in to change notification settings - Fork 0
72 lines (65 loc) · 2.09 KB
/
test-docker.yml
File metadata and controls
72 lines (65 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
name: Test Docker Support
on:
workflow_dispatch:
workflow_call:
jobs:
test-docker-basics:
name: Docker Basics
runs-on: [self-hosted, modal, "job-${{ github.run_id }}-docker-basics"]
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 }}-docker-services"]
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"