Skip to content

Commit 989c5cc

Browse files
authored
Published ghost-devcontainer image to GHCR on main merges (TryGhost#27548)
ref https://linear.app/ghost/issue/PLA-37/ Stacks on **TryGhost#27547** (pending merge). First piece of the Codespaces cold-start optimisation work from `DEVCONTAINER-FOLLOWUPS.md` (F1). Adds `.github/workflows/devcontainer-build.yml` — a GHA workflow that builds `docker/ghost-dev/Dockerfile` and publishes the result to `ghcr.io/tryghost/ghost-devcontainer:{latest,<sha>}` on merges to `main`. The published image is the prerequisite for switching `.devcontainer/devcontainer.json` to an `image:` reference, which would drop a fresh Codespace's cold start from the current ~5–10 min (image build + pnpm install) to ~30–60 s (image pull).
1 parent cbb3b7e commit 989c5cc

1 file changed

Lines changed: 74 additions & 0 deletions

File tree

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Publish ghost-devcontainer Image
2+
3+
# Builds the dev container base image used by .devcontainer/devcontainer.json
4+
# (VS Code Dev Containers + GitHub Codespaces) and publishes it to GHCR on
5+
# merges to main. Publishing means a new Codespace or `Reopen in Container`
6+
# can pull the pre-built image (with pnpm already installed) instead of
7+
# building the Dockerfile from scratch — saving ~3–5 min of cold-start time.
8+
9+
on:
10+
workflow_dispatch: # manual trigger from the Actions UI / gh CLI
11+
pull_request:
12+
paths:
13+
- 'docker/ghost-dev/**'
14+
- '.github/workflows/devcontainer-build.yml'
15+
- 'package.json'
16+
- 'pnpm-lock.yaml'
17+
- 'pnpm-workspace.yaml'
18+
- '.npmrc'
19+
- 'ghost/core/package.json'
20+
- 'ghost/i18n/package.json'
21+
- 'ghost/parse-email-address/package.json'
22+
push:
23+
branches: [main]
24+
paths:
25+
- 'docker/ghost-dev/**'
26+
- '.github/workflows/devcontainer-build.yml'
27+
- 'package.json'
28+
- 'pnpm-lock.yaml'
29+
- 'pnpm-workspace.yaml'
30+
- '.npmrc'
31+
- 'ghost/core/package.json'
32+
- 'ghost/i18n/package.json'
33+
- 'ghost/parse-email-address/package.json'
34+
35+
permissions:
36+
contents: read
37+
packages: write
38+
39+
jobs:
40+
publish:
41+
name: Build and push ghost-devcontainer to GHCR
42+
runs-on: ubuntu-latest
43+
if: github.repository == 'TryGhost/Ghost'
44+
concurrency:
45+
group: publish-ghost-devcontainer-${{ github.ref }}
46+
cancel-in-progress: true
47+
steps:
48+
- name: Checkout
49+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
50+
51+
- name: Set up Docker Buildx
52+
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4
53+
54+
- name: Login to GHCR
55+
# Only log in when we're going to push, i.e. on push-to-main and
56+
# workflow_dispatch. PR builds are validation-only.
57+
if: github.event_name != 'pull_request'
58+
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4
59+
with:
60+
registry: ghcr.io
61+
username: ${{ github.actor }}
62+
password: ${{ secrets.GITHUB_TOKEN }}
63+
64+
- name: Build (PR) / Build and push (main)
65+
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7
66+
with:
67+
context: .
68+
file: docker/ghost-dev/Dockerfile
69+
push: ${{ github.event_name != 'pull_request' }}
70+
tags: |
71+
ghcr.io/tryghost/ghost-devcontainer:latest
72+
ghcr.io/tryghost/ghost-devcontainer:${{ github.sha }}
73+
cache-from: type=gha
74+
cache-to: type=gha,mode=max

0 commit comments

Comments
 (0)