1+ name : Build and Publish Docker Images
2+
3+ on :
4+ push :
5+ branches : [ master ]
6+ pull_request :
7+ branches : [ master ]
8+ schedule :
9+ # Weekly builds to catch upstream updates
10+ - cron : ' 0 2 * * 1'
11+
12+ env :
13+ REGISTRY : docker.io
14+ IMAGE_NAME : keymetrics/pm2
15+
16+ jobs :
17+ build :
18+ runs-on : ubuntu-latest
19+ strategy :
20+ matrix :
21+ node-version : ['18', '20', '22', '24', 'latest']
22+ variant : ['alpine', 'bookworm', 'bullseye', 'buster', 'slim']
23+ exclude :
24+ # Remove buster for Node 22+ as it's deprecated
25+ - node-version : ' 22'
26+ variant : ' buster'
27+ - node-version : ' 24'
28+ variant : ' buster'
29+ # Remove bullseye for Node 24 as bookworm is preferred
30+ - node-version : ' 24'
31+ variant : ' bullseye'
32+
33+ steps :
34+ - name : Checkout
35+ uses : actions/checkout@v4
36+
37+ - name : Set up Docker Buildx
38+ uses : docker/setup-buildx-action@v3
39+
40+ - name : Log in to Docker Hub
41+ if : github.event_name != 'pull_request'
42+ uses : docker/login-action@v3
43+ with :
44+ registry : ${{ env.REGISTRY }}
45+ username : ${{ secrets.DOCKER_USERNAME }}
46+ password : ${{ secrets.DOCKER_PASSWORD }}
47+
48+ - name : Extract metadata
49+ id : meta
50+ uses : docker/metadata-action@v5
51+ with :
52+ images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
53+ tags : |
54+ type=raw,value=${{ matrix.node-version }}-${{ matrix.variant }}
55+
56+ - name : Build and push
57+ uses : docker/build-push-action@v5
58+ with :
59+ context : ./tags/${{ matrix.node-version }}/${{ matrix.variant }}
60+ platforms : linux/amd64,linux/arm64
61+ push : ${{ github.event_name != 'pull_request' }}
62+ tags : ${{ steps.meta.outputs.tags }}
63+ labels : ${{ steps.meta.outputs.labels }}
64+ cache-from : type=gha
65+ cache-to : type=gha,mode=max
66+
67+ test :
68+ needs : build
69+ runs-on : ubuntu-latest
70+ if : github.event_name != 'pull_request'
71+ strategy :
72+ matrix :
73+ tag : ['latest-alpine', 'latest-slim', '20-alpine', '22-alpine', '24-alpine']
74+
75+ steps :
76+ - name : Checkout
77+ uses : actions/checkout@v4
78+
79+ - name : Test Docker image
80+ run : |
81+ cd example-app
82+ # Update Dockerfile to use the built image
83+ sed -i "s|keymetrics/pm2:latest-alpine|keymetrics/pm2:${{ matrix.tag }}|g" Dockerfile
84+
85+ # Build test image
86+ docker build -t test-pm2:${{ matrix.tag }} .
87+
88+ # Run basic tests
89+ docker run --rm test-pm2:${{ matrix.tag }} pm2 --version
90+
91+ # Test multi-arch support
92+ docker manifest inspect keymetrics/pm2:${{ matrix.tag }}
0 commit comments