Skip to content

Commit 83a118c

Browse files
authored
Merge pull request #1006 from akunzai/ci/e2e-faster
ci(e2e): pin tags, GHA cache warm, deepen Docker layers
2 parents 0561156 + bb6e0d6 commit 83a118c

7 files changed

Lines changed: 114 additions & 12 deletions

File tree

.devcontainer/Dockerfile

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
1+
# -----------------------------------------------------------------------------
2+
# Base stage: ASP.NET LTS runtime assets
3+
# -----------------------------------------------------------------------------
14
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS dotnet-lts-runtime
25

6+
# -----------------------------------------------------------------------------
7+
# Runtime stage: .NET 10.0 SDK + Playwright system dependencies
8+
# -----------------------------------------------------------------------------
39
# https://hub.docker.com/_/microsoft-dotnet-sdk/
410
# Using Debian-based image for better Playwright browser support
5-
FROM mcr.microsoft.com/dotnet/sdk:10.0
11+
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS dotnet-sdk
612

713
# install ASP.NET Core 8.0 Runtime
814
COPY --from=dotnet-lts-runtime /usr/share/dotnet /usr/share/dotnet
915

1016
# Install Playwright dependencies
1117
# https://playwright.dev/dotnet/docs/intro#system-requirements
12-
RUN apt-get update && apt-get install -y --no-install-recommends \
18+
# hadolint ignore=DL3008
19+
RUN --mount=type=cache,target=/var/lib/apt/lists,sharing=locked \
20+
--mount=type=cache,target=/var/cache/apt,sharing=locked \
21+
set -eux; \
22+
apt-get update && apt-get install -y --no-install-recommends \
1323
libnss3 \
1424
libnspr4 \
1525
libatk1.0-0 \
@@ -25,5 +35,5 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
2535
libasound2t64 \
2636
libpango-1.0-0 \
2737
libcairo2 \
28-
libatspi2.0-0 \
29-
&& rm -rf /var/lib/apt/lists/*
38+
libatspi2.0-0; \
39+
rm -rf /tmp/*;

.devcontainer/compose.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ services:
4747
- auth.dev.local
4848

4949
redis:
50-
# https://hub.docker.com/_/redis
51-
image: redis
50+
# https://hub.docker.com/_/redis — pin major tag for reproducible CI pulls / cache hits
51+
image: redis:8-alpine
5252
volumes:
5353
- type: volume
5454
source: redis_data
@@ -64,4 +64,4 @@ secrets:
6464

6565
volumes:
6666
keycloak_data:
67-
redis_data:
67+
redis_data:

.devcontainer/docker-bake.hcl

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Local parallel multi-target builds:
2+
// docker buildx bake -f docker-bake.hcl --load
3+
//
4+
// CI uses docker/build-push-action with type=gha (see .github/workflows/e2e-tests.yml).
5+
6+
variable "KEYCLOAK_VERSION" {
7+
default = "26.6.4"
8+
}
9+
10+
variable "KEYCLOAK_CAS_VERSION" {
11+
default = "26.6.4"
12+
}
13+
14+
group "default" {
15+
targets = ["keycloak", "dotnet"]
16+
}
17+
18+
target "keycloak" {
19+
context = "./keycloak"
20+
dockerfile = "Dockerfile"
21+
tags = ["keycloak:cas"]
22+
args = {
23+
KEYCLOAK_VERSION = KEYCLOAK_VERSION
24+
KEYCLOAK_CAS_VERSION = KEYCLOAK_CAS_VERSION
25+
}
26+
}
27+
28+
target "dotnet" {
29+
context = "."
30+
dockerfile = "Dockerfile"
31+
tags = ["dotnet-sdk:latest"]
32+
}

.devcontainer/keycloak/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@ ARG KEYCLOAK_CAS_VERSION
1010
# https://github.com/jacekkow/keycloak-protocol-cas
1111
ADD --chown=keycloak:keycloak https://github.com/jacekkow/keycloak-protocol-cas/releases/download/${KEYCLOAK_CAS_VERSION}/keycloak-protocol-cas-${KEYCLOAK_CAS_VERSION}.jar /opt/keycloak/providers/keycloak-protocol-cas.jar
1212

13-
WORKDIR /opt/keycloak
13+
WORKDIR /opt/keycloak
14+
15+
RUN /opt/keycloak/bin/kc.sh build --health-enabled=true
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Warm GHA BuildKit caches for e2e custom images on main so new PRs can
2+
# cache-from on their first run (PR jobs may restore caches from the default branch).
3+
# Scopes must match .github/workflows/e2e-tests.yml (keycloak).
4+
name: E2E Image Cache
5+
6+
on:
7+
push:
8+
branches:
9+
- main
10+
paths:
11+
- '.devcontainer/keycloak/**'
12+
- '.devcontainer/Dockerfile'
13+
- '.github/workflows/e2e-image-cache.yml'
14+
- '.github/workflows/e2e-tests.yml'
15+
workflow_dispatch:
16+
17+
permissions:
18+
contents: read
19+
actions: write
20+
21+
concurrency:
22+
group: ${{ github.workflow }}-${{ github.ref }}
23+
cancel-in-progress: true
24+
25+
jobs:
26+
warm-keycloak:
27+
runs-on: ubuntu-latest
28+
timeout-minutes: 15
29+
name: Warm Keycloak cache
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@v7
33+
34+
- name: Set up Docker Buildx
35+
uses: docker/setup-buildx-action@v4
36+
37+
# No load/push — only export type=gha layers for PR e2e cache-from.
38+
- name: Build Keycloak image (cache export)
39+
uses: docker/build-push-action@v7
40+
with:
41+
context: .devcontainer/keycloak
42+
cache-from: type=gha,scope=keycloak
43+
cache-to: type=gha,mode=max,scope=keycloak

.github/workflows/e2e-tests.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ concurrency:
3737
group: ${{ github.workflow }}-${{ github.ref }}
3838
cancel-in-progress: true
3939

40-
permissions: read-all
40+
permissions:
41+
contents: read
42+
# buildx type=gha cache-to needs write on private repos; harmless on public
43+
actions: write
4144

4245
jobs:
4346
build:
@@ -117,6 +120,15 @@ jobs:
117120
if: steps.check.outputs.run == 'true'
118121
uses: docker/setup-buildx-action@v4
119122

123+
# type=gha only persists reliably via docker/build-push-action (or bake-action).
124+
# Scopes match .github/workflows/e2e-image-cache.yml (main warms caches for
125+
# first-run PRs; PR jobs can restore from the default branch).
126+
- name: Pull service images
127+
if: steps.check.outputs.run == 'true'
128+
working-directory: .devcontainer
129+
# Tags come from compose.yaml (SSOT); only Hub services — not keycloak.
130+
run: docker compose pull redis
131+
120132
- name: Build Keycloak image with CAS protocol
121133
if: steps.check.outputs.run == 'true'
122134
uses: docker/build-push-action@v7
@@ -125,8 +137,8 @@ jobs:
125137
tags: keycloak:cas
126138
push: false
127139
load: true
128-
cache-from: type=gha
129-
cache-to: type=gha,mode=max
140+
cache-from: type=gha,scope=keycloak
141+
cache-to: type=gha,scope=keycloak,mode=max
130142

131143
- name: Start Keycloak
132144
if: steps.check.outputs.run == 'true'

.markdownlint-cli2.jsonc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
},
66
"ignores": [
77
"**/AGENTS.md",
8-
"**/CLAUDE.md"
8+
"**/CLAUDE.md",
9+
"**/node_modules/**",
10+
"**/bin/**",
11+
"**/obj/**"
912
]
1013
}

0 commit comments

Comments
 (0)