-
Notifications
You must be signed in to change notification settings - Fork 1
168 lines (153 loc) · 5.79 KB
/
container.yml
File metadata and controls
168 lines (153 loc) · 5.79 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
name: "Containers: Build and Publish SeaweedFS Enterprise Docker"
on:
push:
tags:
- '*'
workflow_dispatch:
inputs:
tag_name:
description: 'Tag name for the container'
required: true
default: 'latest'
permissions:
contents: read
packages: write
# Limit concurrent builds to avoid rate limits
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
jobs:
build-enterprise-containers:
runs-on: ubuntu-latest
strategy:
# Build sequentially to avoid rate limits
max-parallel: 2
matrix:
include:
# Normal volume container
- variant: "normal"
suffix: ""
build_args: ""
dockerfile: "Dockerfile.go_build"
platforms: "linux/amd64,linux/arm64,linux/arm"
# Large disk container
- variant: "large_disk"
suffix: "_large_disk"
build_args: "TAGS=5BytesOffset"
dockerfile: "Dockerfile.go_build"
platforms: "linux/amd64,linux/arm64,linux/arm"
# RocksDB with large disk support
- variant: "rocksdb_large"
suffix: "_large_disk_rocksdb"
build_args: ""
dockerfile: "Dockerfile.rocksdb_large"
platforms: "linux/amd64"
# Full features container
- variant: "full"
suffix: "_full"
build_args: "TAGS=elastic,gocdk,rclone,sqlite,tarantool,tikv,ydb"
dockerfile: "Dockerfile.go_build"
platforms: "linux/amd64"
# Full features with large disk support
- variant: "full_large"
suffix: "_large_disk_full"
build_args: "TAGS=5BytesOffset,elastic,gocdk,rclone,sqlite,tarantool,tikv,ydb"
dockerfile: "Dockerfile.go_build"
platforms: "linux/amd64"
steps:
# Checkout the current artifactory repo
- name: Checkout artifactory repo
uses: actions/checkout@v4
# Free disk space for large builds
- name: Free Disk Space
run: |
echo "Available disk space before cleanup:"
df -h
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache/CodeQL
sudo apt-get clean
sudo rm -rf /var/lib/apt/lists/*
sudo docker system prune -af --volumes
[ -d ~/.cache/go-build ] && rm -rf ~/.cache/go-build || true
[ -d /go/pkg ] && rm -rf /go/pkg || true
echo "Available disk space after cleanup:"
df -h
# Clone the private GitLab repository (SeaweedFS Enterprise)
- name: Clone private GitLab repo (SeaweedFS Enterprise)
env:
GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }}
run: |
git clone -b enterprise https://gitlab-ci-token:${GITLAB_TOKEN}@gitlab.com/chrislusf/seaweedfs.git seaweedfs-enterprise-source
cd seaweedfs-enterprise-source
echo "Cloned enterprise branch commit: $(git rev-parse HEAD)"
echo "COMMIT_SHA=$(git rev-parse --short=8 HEAD)" >> $GITHUB_ENV
# Docker meta for tagging
- name: Docker meta
id: docker_meta
uses: docker/metadata-action@v5
with:
images: |
chrislusf/seaweedfs-enterprise
ghcr.io/seaweedfs/seaweedfs-enterprise
tags: |
type=ref,event=tag,suffix=${{ matrix.suffix }}
type=raw,value=latest,suffix=${{ matrix.suffix }},enable={{is_default_branch}}
flavor: |
latest=false
labels: |
org.opencontainers.image.title=seaweedfs-enterprise
org.opencontainers.image.description=SeaweedFS Enterprise is the commercial version with additional features
org.opencontainers.image.vendor=Chris Lu
# Set up QEMU for multi-platform builds
- name: Set up QEMU
if: contains(matrix.platforms, 'arm')
uses: docker/setup-qemu-action@v3
# Configure BuildKit with Docker Hub mirror to reduce rate limit hits
- name: Create BuildKit config
run: |
cat > /tmp/buildkitd.toml <<EOF
[registry."docker.io"]
mirrors = ["https://mirror.gcr.io"]
EOF
# Set up Docker Buildx with mirror config
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
buildkitd-config: /tmp/buildkitd.toml
# Login to Docker Hub BEFORE building to avoid rate limits
- name: Login to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# Login to GHCR
- name: Login to GHCR
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Build and push Docker image
- name: Build and push Docker image
uses: docker/build-push-action@v5
env:
DOCKER_BUILDKIT: 1
with:
context: ./seaweedfs-enterprise-source
push: ${{ github.event_name != 'pull_request' }}
file: ./seaweedfs-enterprise-source/docker/${{ matrix.dockerfile }}
build-args: |
${{ matrix.build_args }}
BUILDKIT_INLINE_CACHE=1
platforms: ${{ matrix.platforms }}
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
cache-from: type=gha,scope=${{ matrix.variant }}
cache-to: type=gha,mode=max,scope=${{ matrix.variant }}
# Clean up build artifacts
- name: Clean up build artifacts
if: always()
run: |
sudo docker system prune -f
sudo rm -rf /tmp/go-build*