forked from ClickHouse/ClickHouse
-
Notifications
You must be signed in to change notification settings - Fork 18
183 lines (158 loc) · 5.96 KB
/
docker_publish.yml
File metadata and controls
183 lines (158 loc) · 5.96 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
name: Republish Multiarch Docker Image
on:
workflow_dispatch:
inputs:
docker_image:
description: 'Multiarch Docker image with tag'
required: true
release_environment:
description: 'Select release type: "staging" or "production"'
type: choice
default: 'staging'
options:
- staging
- production
upload_artifacts:
description: 'Upload artifacts directly in this workflow'
type: boolean
default: true
s3_upload_path:
description: 'Upload artifacts to s3 path'
type: string
required: false
workflow_call:
inputs:
docker_image:
type: string
required: true
release_environment:
type: string
required: false
default: 'staging'
upload_artifacts:
type: boolean
required: false
default: false
s3_upload_path:
type: string
required: false
outputs:
image_archives_path:
description: 'Path to the image archives directory'
value: ${{ jobs.republish.outputs.image_archives_path }}
env:
IMAGE: ${{ github.event.inputs.docker_image || inputs.docker_image }}
jobs:
republish:
runs-on: [self-hosted, altinity-on-demand, altinity-style-checker-aarch64]
outputs:
image_archives_path: ${{ steps.set_path.outputs.image_archives_path }}
steps:
- name: Docker Hub Login
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Set clickhouse-server version as new tag
run: |
# Determine "clickhouse-server" or "clickhouse-keeper"
echo "Input IMAGE: $IMAGE"
COMPONENT=$(echo "$IMAGE" | sed -E 's|.*/(clickhouse-[^:]+):.*|\1|')
echo "Component determined: $COMPONENT"
echo "COMPONENT=$COMPONENT" >> $GITHUB_ENV
# Pull the image
echo "Pulling the image"
docker pull $IMAGE
# Create container for version and symtable checks
echo "Creating container for checks..."
CONTAINER_ID=$(docker create $IMAGE $COMPONENT --version)
# Check if binary has symbol table (not stripped)
echo "Checking if binary has symtable..."
# Try common binary locations
BINARY_PATH=""
for path in "/usr/bin/clickhouse" "/usr/bin/$COMPONENT"; do
if docker cp "$CONTAINER_ID:$path" /tmp/clickhouse-check 2>/dev/null; then
BINARY_PATH="$path"
break
fi
done
if [ -z "$BINARY_PATH" ]; then
echo "✗ Could not find clickhouse binary in container"
docker rm "$CONTAINER_ID"
exit 1
fi
echo "Found binary at $BINARY_PATH"
if readelf -S /tmp/clickhouse-check | grep -q '\.symtab'; then
echo "✓ Binary has symtable"
else
echo "✗ Binary is missing symtable"
docker rm "$CONTAINER_ID"
rm -f /tmp/clickhouse-check
exit 1
fi
rm -f /tmp/clickhouse-check
# Get version and clean it up
echo "Getting version from image..."
VERSION_OUTPUT=$(docker start -a "$CONTAINER_ID")
docker rm "$CONTAINER_ID"
echo "Raw version output: $VERSION_OUTPUT"
# Extract just the version number
NEW_TAG=$(echo "$VERSION_OUTPUT" | sed -E 's/.*version ([0-9.]+[^ ]*).*/\1/')
echo "Cleaned version: $NEW_TAG"
# Append "-prerelease" if necessary
if [ "${{ github.event.inputs.release_environment || inputs.release_environment }}" = "staging" ]; then
NEW_TAG="${NEW_TAG}-prerelease"
fi
if [[ "$IMAGE" == *-alpine* ]]; then
NEW_TAG="${NEW_TAG}-alpine"
fi
echo "New tag: $NEW_TAG"
# Export the new tag
echo "NEW_TAG=$NEW_TAG" >> $GITHUB_ENV
- name: Process multiarch manifest
run: |
echo "Re-tag multiarch image $IMAGE to altinity/$COMPONENT:$NEW_TAG"
docker buildx imagetools create --tag "altinity/$COMPONENT:$NEW_TAG" "$IMAGE"
# Create directory for image archives
mkdir -p image_archives
# Pull and save platform-specific images
for PLATFORM in "linux/amd64" "linux/arm64"; do
echo "Pulling and saving image for $PLATFORM..."
# Pull the specific platform image
docker pull --platform $PLATFORM "altinity/$COMPONENT:$NEW_TAG"
# Save the image to a tar file
ARCH=$(echo $PLATFORM | cut -d'/' -f2)
docker save "altinity/$COMPONENT:$NEW_TAG" -o "image_archives/${COMPONENT}-${NEW_TAG}-${ARCH}.tar"
done
# Save manifest inspection
docker buildx imagetools inspect "altinity/$COMPONENT:$NEW_TAG" > image_archives/manifest.txt
# Compress the archives
cd image_archives
for file in *.tar; do
gzip "$file"
done
cd ..
- name: Set image archives path
id: set_path
run: |
echo "image_archives_path=${{ github.workspace }}/image_archives" >> $GITHUB_OUTPUT
- name: Upload image archives
if: ${{ github.event.inputs.upload_artifacts || inputs.upload_artifacts }}
uses: actions/upload-artifact@v4
with:
name: docker-images-backup
path: image_archives/
retention-days: 90
- name: Install aws cli
if: ${{ inputs.s3_upload_path != '' }}
uses: unfor19/install-aws-cli-action@v1
with:
version: 2
arch: arm64
- name: Upload to S3
if: ${{ inputs.s3_upload_path != '' }}
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: |
aws s3 sync image_archives/ "${{ inputs.s3_upload_path }}"