|
6 | 6 | pull_request: |
7 | 7 | branches: [ "main" ] |
8 | 8 |
|
9 | | -jobs: |
| 9 | +env: |
| 10 | + # Enable BuildKit for all Docker operations |
| 11 | + DOCKER_BUILDKIT: 1 |
| 12 | + COMPOSE_DOCKER_CLI_BUILD: 1 |
10 | 13 |
|
| 14 | +jobs: |
11 | 15 | build: |
12 | 16 | name: Build Docker image and push to repositories |
13 | 17 | runs-on: ubuntu-latest |
14 | | - |
| 18 | + |
15 | 19 | steps: |
16 | 20 | - name: Checkout code |
17 | | - uses: actions/checkout@v3 |
| 21 | + uses: actions/checkout@v4 # Updated to v4 |
18 | 22 |
|
19 | 23 | - name: Generate docker .env |
20 | 24 | run: | |
21 | 25 | python3 ./scripts/docker/generate_env.py |
22 | 26 |
|
23 | 27 | - name: Show generated .env (debug) |
24 | 28 | run: | |
25 | | - echo "--- content of scripts/docker/.env ---" |
| 29 | + echo "--- Content of scripts/docker/.env ---" |
26 | 30 | cat scripts/docker/.env |
27 | | - echo "-------------------------------------" |
| 31 | + echo "--------------------------------------" |
28 | 32 |
|
29 | 33 | - name: Set up Docker Buildx |
30 | | - uses: docker/setup-buildx-action@v2 |
| 34 | + uses: docker/setup-buildx-action@v3 # Updated to v3 |
| 35 | + |
| 36 | + - name: Build base images (ubuntu and library) |
| 37 | + working-directory: scripts/docker |
| 38 | + run: | |
| 39 | + # Build in correct dependency order |
| 40 | + docker compose build cosim-ubuntu |
| 41 | + docker compose build cosim-library |
31 | 42 |
|
32 | | - - name: Install docker-compose |
| 43 | + - name: Build main image (cosim-build) |
| 44 | + working-directory: scripts/docker |
33 | 45 | run: | |
34 | | - sudo apt-get update |
35 | | - sudo apt-get install -y docker-compose |
| 46 | + # Build the main image |
| 47 | + docker compose build cosim-build |
36 | 48 |
|
37 | | - - name: Build (docker-compose) |
| 49 | + - name: List built images |
38 | 50 | run: | |
39 | | - cd scripts/docker |
40 | | - docker-compose --profile build build |
41 | | - # Note: running docker-compose from the directory containing the compose file |
42 | | - # ensures it picks up the generated .env in this directory. |
| 51 | + echo "--- Built Docker Images ---" |
| 52 | + docker images | grep -E "(cosim|tesp)" || echo "No matching images found" |
| 53 | + echo "---------------------------" |
43 | 54 |
|
44 | 55 | - name: Smoke test built image |
45 | 56 | run: | |
46 | | - # determine version used for tagging |
| 57 | + # Determine version used for tagging |
47 | 58 | VER=$(cat scripts/grid_version | tr -d '\n') |
48 | 59 | echo "Using grid_version=${VER}" |
49 | | - # quick smoke: run a simple Python command inside the built cosim-build image |
50 | | - docker run --rm cosim-build:tesp_${VER} python3 -c "import sys; print('smoke ok'); sys.exit(0)" |
| 60 | + |
| 61 | + # Quick smoke test: run a simple Python command inside the built image |
| 62 | + docker run --rm cosim-build:tesp_${VER} python3 -c " |
| 63 | + import sys |
| 64 | + print('Python version:', sys.version) |
| 65 | + try: |
| 66 | + import tesp_support |
| 67 | + print('tesp_support: OK') |
| 68 | + except ImportError as e: |
| 69 | + print('tesp_support: FAILED -', e) |
| 70 | + print('Smoke test: PASSED') |
| 71 | + sys.exit(0) |
| 72 | + " |
| 73 | +
|
| 74 | + # Optional: More comprehensive tests |
| 75 | + - name: Component verification |
| 76 | + run: | |
| 77 | + VER=$(cat scripts/grid_version | tr -d '\n') |
| 78 | + docker run --rm cosim-build:tesp_${VER} bash -c " |
| 79 | + echo '=== Component Verification ===' |
| 80 | + " |
51 | 81 |
|
52 | 82 |
|
53 | 83 | # - name: Test |
|
0 commit comments