-
Notifications
You must be signed in to change notification settings - Fork 1.2k
executable file
·61 lines (55 loc) · 1.84 KB
/
Copy pathdocker.yml
File metadata and controls
executable file
·61 lines (55 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
name: Docker image
# Build-only. Nothing is published, so this adds no release surface or
# registry credentials — it exists so the Dockerfile cannot silently rot.
on:
push:
branches: [main]
paths:
- 'docker/**'
- '.dockerignore'
- 'xtask/**'
- '**/book.toml'
- '.github/workflows/docker.yml'
pull_request:
paths:
- 'docker/**'
- '.dockerignore'
- 'xtask/**'
- '**/book.toml'
- '.github/workflows/docker.yml'
workflow_dispatch:
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- name: Build image
uses: docker/build-push-action@v6
with:
context: .
file: docker/Dockerfile
push: false
load: true
tags: rust-training:ci
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Smoke test
run: |
docker run -d --name books -p 3000:8080 rust-training:ci
for i in $(seq 1 30); do
if curl -fsS http://localhost:3000/ >/dev/null 2>&1; then ok=1; break; fi
sleep 2
done
if [ "${ok:-0}" != "1" ]; then
echo "::error::server did not come up"; docker logs books; exit 1
fi
# Landing page and at least one book must resolve.
# NB: match the <title>; the <h1> is split by a <span> tag.
curl -fsS http://localhost:3000/ | grep -q "<title>Rust Training Books</title>"
curl -fsS -o /dev/null -w '%{http_code}\n' http://localhost:3000/async-book/ | grep -q 200
# Extensionless links must resolve via try_files.
curl -fsS -o /dev/null -w '%{http_code}\n' http://localhost:3000/async-book/ch00-introduction | grep -q 200
docker rm -f books