Skip to content

Commit b3ea46c

Browse files
committed
psh
1 parent ed62159 commit b3ea46c

File tree

2 files changed

+129
-0
lines changed

2 files changed

+129
-0
lines changed

.github/workflows/README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# GitHub Actions Workflows
2+
3+
## Docker Multi-Architecture Build
4+
5+
This repository now uses GitHub Actions to build Docker images with multi-architecture support (AMD64 and ARM64).
6+
7+
### Migration from Travis CI
8+
9+
- **Before**: Travis CI built single-architecture images only
10+
- **After**: GitHub Actions builds both AMD64 and ARM64 architectures
11+
12+
### Required Secrets
13+
14+
Configure these secrets in the repository settings:
15+
16+
- `DOCKER_USERNAME`: Docker Hub username
17+
- `DOCKER_PASSWORD`: Docker Hub access token
18+
19+
### Build Triggers
20+
21+
- **Push to master**: Builds and publishes all image variants
22+
- **Pull requests**: Builds images for testing (no push)
23+
- **Weekly schedule**: Rebuilds to catch upstream Node.js updates
24+
25+
### Supported Architectures
26+
27+
All images now support:
28+
- `linux/amd64` (Intel/AMD 64-bit)
29+
- `linux/arm64` (ARM 64-bit, including Apple Silicon)
30+
31+
### Matrix Strategy
32+
33+
The workflow builds all combinations of:
34+
- Node versions: 18, 20, 22, 24, latest
35+
- Variants: alpine, bookworm, bullseye, buster, slim
36+
37+
Some combinations are excluded for compatibility reasons (e.g., buster with Node 22+).
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
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

Comments
 (0)