Skip to content

Commit a8ead64

Browse files
authored
[PMAR-290] Automate patching (#49)
* Add scheduled rebuild workflow * Remove dependency on instrumentisto/rsync-ssh Dependabot version checks aren't able to detect changes to the base image because the tag format (i.e. alpine3.20) is not standard semver. This prevents Dependabot from automatically updating the base image when a new version is released, creating the need to manually monitor for and apply base image updates. The instrumentisto/rsync-ssh base image isn't particularly complex and we're already running package updates and installing a few additional dependencies. Therefore, it makes sense to just use alpine directly and install all of the instrumentisto/rsync-ssh dependencies ourselves. This should allow Dependabot to automatically update the base image when a new version is released. * Update documentation * Drop unused v prefix for image tags
1 parent 5ff7c07 commit a8ead64

File tree

4 files changed

+93
-8
lines changed

4 files changed

+93
-8
lines changed

.changeset/flat-shrimps-hide.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@wpengine/site-deploy": patch
3+
---
4+
5+
Remove dependency on instrumentisto/rsync-ssh
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Scheduled Docker Rebuild
2+
3+
on:
4+
schedule:
5+
# Run monthly on the 1st at 00:00 UTC
6+
- cron: '0 0 1 * *'
7+
workflow_dispatch: # Allow manual triggers
8+
9+
jobs:
10+
rebuild:
11+
name: Rebuild Docker Image
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout Repo
15+
uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Get current version
20+
id: version
21+
run: |
22+
VERSION=$(jq -r '.version' package.json)
23+
MAJOR=$(echo $VERSION | cut -d. -f1)
24+
MINOR=$(echo $VERSION | cut -d. -f2)
25+
PATCH=$(echo $VERSION | cut -d. -f3)
26+
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
27+
echo "MAJOR=$MAJOR" >> $GITHUB_OUTPUT
28+
echo "MINOR=$MINOR" >> $GITHUB_OUTPUT
29+
echo "PATCH=$PATCH" >> $GITHUB_OUTPUT
30+
31+
- name: Checkout release tag
32+
run: git checkout v${{ steps.version.outputs.MAJOR }}.${{ steps.version.outputs.MINOR }}.${{ steps.version.outputs.PATCH }}
33+
34+
- name: Set up Docker Buildx
35+
uses: docker/setup-buildx-action@v3
36+
37+
- name: Login to Docker Hub
38+
uses: docker/login-action@v3
39+
with:
40+
username: ${{ secrets.DOCKERHUB_USERNAME }}
41+
password: ${{ secrets.DOCKERHUB_TOKEN }}
42+
43+
- name: Build and push
44+
uses: docker/build-push-action@v5
45+
with:
46+
context: .
47+
push: true
48+
tags: |
49+
wpengine/site-deploy:latest
50+
wpengine/site-deploy:${{ steps.version.outputs.MAJOR }}
51+
wpengine/site-deploy:${{ steps.version.outputs.MAJOR }}.${{ steps.version.outputs.MINOR }}
52+
wpengine/site-deploy:${{ steps.version.outputs.MAJOR }}.${{ steps.version.outputs.MINOR }}.${{ steps.version.outputs.PATCH }}
53+
# No cache - we want fresh base image layers for security patches
54+
no-cache: true
55+

DEVELOPMENT.md

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,35 @@ Any other customizations that are uniquely required can be added to the Dockerfi
3838

3939
## Updating the Docker Image
4040

41-
The `latest` Docker Image will be updated automatically after merging into the `main` branch.
42-
`wpengine/site-deploy:latest`
41+
### Automatic Builds
4342

43+
Docker images are built and pushed automatically:
4444

45-
A versioned Docker Image will be automatically generated for each release of this repository, based on the tag name
46-
`wpengine/site-deploy:{tagName}`
45+
| Trigger | Tags Updated | Source |
46+
|---------|--------------|--------|
47+
| Push to `main` | `latest` | Docker Hub Autobuild |
48+
| New version release | `latest`, `vX`, `vX.Y`, `vX.Y.Z` | Docker Hub Autobuild |
49+
| Monthly schedule (1st of month) | `latest`, `vX`, `vX.Y`, `vX.Y.Z` | GitHub Actions |
4750

48-
Additional Docker Images will be automatically generated for each branch to use in testing.
49-
`wpengine/site-deploy:branch-{branchName}`
51+
The scheduled monthly rebuild ensures security patches are applied even when there are no new releases. This workflow uses `no-cache` to pull fresh base image layers.
52+
53+
### Base Image Maintenance
54+
55+
The Dockerfile uses Alpine Linux as its base image. The base image follows this update pattern:
56+
57+
- **Dependabot** monitors for new Alpine versions and creates PRs automatically
58+
- **Scheduled rebuilds** pick up security patches from `apk upgrade` monthly
59+
- Alpine releases new versions every 6 months (roughly June and December)
60+
61+
When Dependabot opens a PR for a new Alpine version:
62+
63+
1. Review the [Alpine release notes](https://alpinelinux.org/releases/) for breaking changes
64+
2. Add a changeset to the PR (`npx changeset`) so a proper release is created when merged
65+
3. Merge the PR to trigger a new versioned release
66+
67+
### Docker Hub
68+
69+
Images are published to DockerHub: [wpengine/site-deploy](https://hub.docker.com/r/wpengine/site-deploy)
5070

5171
## Manually updating the Docker Image
5272

Dockerfile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
FROM instrumentisto/rsync-ssh:alpine3.20
2-
# Install dependencies
1+
FROM alpine:3.20
2+
33
RUN apk update \
44
&& apk upgrade \
55
&& apk add --no-cache \
6+
rsync \
7+
openssh-client-default sshpass \
8+
gettext-envsubst \
9+
ca-certificates tzdata \
610
bash \
711
php \
12+
&& update-ca-certificates \
813
&& rm -rf /var/cache/apk/*
914
# Add entrypoint and utils
1015
COPY utils /utils

0 commit comments

Comments
 (0)