-
Notifications
You must be signed in to change notification settings - Fork 466
129 lines (114 loc) · 4.36 KB
/
build-envd-base-image.yml
File metadata and controls
129 lines (114 loc) · 4.36 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: Build envd Base Image
on:
push:
branches: [master]
paths:
- 'docker/Dockerfile.cube-base'
- 'docker/cube-entrypoint.sh'
- '.github/workflows/build-envd-base-image.yml'
pull_request:
paths:
- 'docker/Dockerfile.cube-base'
- 'docker/cube-entrypoint.sh'
- '.github/workflows/build-envd-base-image.yml'
workflow_dispatch:
inputs:
envd_ref:
description: 'Upstream e2b-dev/infra ref (tag/branch/SHA) to compile envd from'
required: false
default: '2026.16'
env:
ENVD_REF_DEFAULT: '2026.16'
IMAGE_NAME: ghcr.io/tencentcloud/cubesandbox-base
BASE_OS_TAG_SUFFIX: ubuntu22.04
concurrency:
group: build-envd-base-image-${{ github.ref }}-${{ github.event.inputs.envd_ref || 'default' }}
cancel-in-progress: false
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Resolve envd ref
id: meta_ref
run: |
envd_ref="${{ github.event.inputs.envd_ref || env.ENVD_REF_DEFAULT }}"
echo "envd_ref=${envd_ref}" >> "${GITHUB_OUTPUT}"
echo "Compiling envd from e2b-dev/infra@${envd_ref}"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
if: github.repository == 'TencentCloud/CubeSandbox' && github.ref == 'refs/heads/master'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract image metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.IMAGE_NAME }}
tags: |
type=raw,value=${{ steps.meta_ref.outputs.envd_ref }},enable=${{ github.repository == 'TencentCloud/CubeSandbox' && github.ref == 'refs/heads/master' }}
type=raw,value=${{ steps.meta_ref.outputs.envd_ref }}-${{ env.BASE_OS_TAG_SUFFIX }},enable=${{ github.repository == 'TencentCloud/CubeSandbox' && github.ref == 'refs/heads/master' }}
type=raw,value=latest,enable=${{ github.repository == 'TencentCloud/CubeSandbox' && github.ref == 'refs/heads/master' }}
type=sha,prefix=sha-,format=short
labels: |
io.cubesandbox.envd.ref=${{ steps.meta_ref.outputs.envd_ref }}
- name: Build image (load locally for smoke test)
uses: docker/build-push-action@v6
with:
context: docker
file: docker/Dockerfile.cube-base
platforms: linux/amd64
push: false
load: true
tags: cubesandbox-base:ci-smoke
labels: ${{ steps.meta.outputs.labels }}
build-args: |
ENVD_REF=${{ steps.meta_ref.outputs.envd_ref }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Smoke test envd /health
run: |
set -euo pipefail
cid="$(docker run -d --rm cubesandbox-base:ci-smoke)"
trap 'docker rm -f "${cid}" >/dev/null 2>&1 || true' EXIT
ok=""
for attempt in 1 2 3 4 5 6 7 8 9 10; do
code="$(docker exec "${cid}" curl -s -o /dev/null -w "%{http_code}" \
http://127.0.0.1:49983/health || true)"
echo "attempt ${attempt}: envd /health => ${code}"
if [ "${code}" = "204" ]; then
ok="yes"
break
fi
sleep 1
done
if [ -z "${ok}" ]; then
echo "envd /health probe never returned 204" >&2
docker exec "${cid}" cat /var/log/envd.log >&2 || true
exit 1
fi
echo "envd inside container:"
docker exec "${cid}" /usr/bin/envd -version
docker exec "${cid}" /usr/bin/envd -commit
- name: Push image
if: github.repository == 'TencentCloud/CubeSandbox' && github.ref == 'refs/heads/master'
uses: docker/build-push-action@v6
with:
context: docker
file: docker/Dockerfile.cube-base
platforms: linux/amd64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
ENVD_REF=${{ steps.meta_ref.outputs.envd_ref }}
cache-from: type=gha
cache-to: type=gha,mode=max