Skip to content

Commit 50462fe

Browse files
danilapogagolybev
authored andcommitted
Add the ability to custom separate build (#9)
Co-authored-by: danilapog <[email protected]> Co-committed-by: danilapog <[email protected]>
1 parent c847e4d commit 50462fe

File tree

3 files changed

+192
-47
lines changed

3 files changed

+192
-47
lines changed

.github/workflows/build.yaml

+158-40
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,60 @@
11
### This workflow setup instance then build and push images ###
2-
name: Multi-arch build
2+
name: Multi-arch build
3+
4+
run-name: >-
5+
Build Docs: [
6+
${{ inputs.docs-community && 'CE' || '-' }}
7+
${{ inputs.docs-enterprise && 'EE' || '-' }}
8+
${{ inputs.docs-developer && 'DE' || '-' }}
9+
]
10+
${{ inputs.docs-balancer && 'balancer: [✓]' || '' }}
11+
${{ inputs.docs-non-plugins && 'non-plugins: [✓]' || '' }}
12+
${{ inputs.docs-utils && 'utils: [✓]' || '' }}
13+
VER: [${{ inputs.tag }}]
314
415
on:
5-
push:
6-
tags:
7-
- "v*"
16+
workflow_dispatch:
17+
inputs:
18+
docs-community:
19+
type: boolean
20+
description: 'Build Docs-Community'
21+
default: true
22+
docs-enterprise:
23+
type: boolean
24+
description: 'Build Docs-Enterprise'
25+
default: true
26+
docs-developer:
27+
type: boolean
28+
description: 'Build Docs-Developer'
29+
default: true
30+
docs-non-plugins:
31+
type: boolean
32+
description: 'Build Docs-non-plugins'
33+
default: true
34+
docs-utils:
35+
type: boolean
36+
description: 'Build Docs-utils'
37+
default: true
38+
docs-balancer:
39+
type: boolean
40+
description: 'Build Docs-balancer'
41+
default: true
42+
tag:
43+
description: 'Specify tag (ex. 7.0.0 or 7.0.0-rc25)'
44+
type: string
45+
required: true
46+
test-repo:
47+
type: boolean
48+
description: 'Push to test repo'
49+
default: true
50+
test-version:
51+
type: string
52+
required: false
53+
description: 'Specify version if test-repo enabled'
54+
test-build:
55+
type: string
56+
required: false
57+
description: 'Specify build if test-repo enabled'
858

959
jobs:
1060
prepare-build:
@@ -13,69 +63,137 @@ jobs:
1363
outputs:
1464
sourceTag: ${{ steps.prepare.outputs.sourceTag }}
1565
dsHash: ${{ steps.prepare.outputs.dsHash }}
66+
matrix: ${{ steps.prepare.outputs.matrix }}
1667
steps:
1768
- name: prepare-build
1869
id: prepare
70+
shell: bash
1971
run: |
20-
echo "sourceTag=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"
21-
echo "dsHash=$(echo -n "$(date +'%Y.%m.%d-%H%M')" | md5sum | awk '{print $1}')" >> "$GITHUB_OUTPUT"
72+
### Check that test-repo specifyed with rc postfix ###
73+
if ${{ github.event.inputs.test-repo }}; then
74+
if ! [[ ${{ github.event.inputs.tag }} == *rc* ]]; then
75+
echo -e '\033[33m ⚠ ALERT ⚠ \033[0m'
76+
echo -e 'Test-Repo: enabled[\033[32m✓\033[0m]'
77+
echo -e 'Please specify tag with <rc>...'
78+
echo -e '\033[33mFor example:\033[0m ${{ github.event.inputs.tag }}-rc25'
79+
exit 1
80+
fi
81+
fi
82+
83+
### Make build matrix ###
84+
matrix='{"include": []}'
85+
if ${{ github.event.inputs.docs-community }}; then
86+
matrix=$(echo $matrix | jq '.include += [
87+
{
88+
"name": "Build Docs Community",
89+
"dockerfile": "Dockerfile",
90+
"edition": "",
91+
"images": "proxy docservice converter"
92+
}
93+
]')
94+
fi
95+
if ${{ github.event.inputs.docs-enterprise }}; then
96+
matrix=$(echo $matrix | jq '.include += [
97+
{
98+
"name": "Build Docs Enterprise",
99+
"dockerfile": "Dockerfile",
100+
"edition": "-ee",
101+
"images": "proxy docservice converter"
102+
}
103+
]')
104+
fi
105+
if ${{ github.event.inputs.docs-developer }}; then
106+
matrix=$(echo $matrix | jq '.include += [
107+
{
108+
"name": "Build Docs Developer",
109+
"dockerfile": "Dockerfile",
110+
"edition": "-de",
111+
"images": "proxy docservice converter"
112+
}
113+
]')
114+
fi
115+
if ${{ github.event.inputs.docs-non-plugins }}; then
116+
matrix=$(echo $matrix | jq '.include += [
117+
{
118+
"name": "Build Docs non-plugins",
119+
"dockerfile": "Dockerfile",
120+
"edition": "-de",
121+
"images": "proxy docservice converter",
122+
"postfix": "-noplugins"
123+
}
124+
]')
125+
fi
126+
if ${{ github.event.inputs.docs-utils }}; then
127+
matrix=$(echo $matrix | jq '.include += [
128+
{
129+
"name": "Build Docs utils",
130+
"dockerfile": "Dockerfile",
131+
"edition": "",
132+
"images": "example utils"
133+
}
134+
]')
135+
fi
136+
if ${{ github.event.inputs.docs-balancer }}; then
137+
matrix=$(echo $matrix | jq '.include += [
138+
{
139+
"name": "Build Docs balancer",
140+
"dockerfile": "Dockerfile.balancer",
141+
"edition": "",
142+
"images": "balancer"
143+
}
144+
]')
145+
fi
146+
147+
### Specify outputs ###
148+
echo "sourceTag=${{ github.event.inputs.tag }}" >> "$GITHUB_OUTPUT"
149+
echo "dsHash=$(echo -n "$(date +'%Y.%m.%d-%H%M')" | md5sum | awk '{print $1}')" >> "$GITHUB_OUTPUT"
150+
echo "matrix=$(echo $matrix | jq -c)" >> "$GITHUB_OUTPUT"
22151
23152
build:
24-
name: "${{ matrix.name }} ${{ matrix.edition }}"
153+
name: "${{ matrix.name }} ${{ github.event.inputs.tag }}"
25154
runs-on: ubuntu-latest
26155
needs: [prepare-build]
27156
strategy:
28157
fail-fast: false
29-
matrix:
30-
name: ["Build Docs"]
31-
dockerfile: ["Dockerfile"]
32-
edition: [ "", "-ee", "-de"]
33-
images: [ "proxy docservice converter" ]
34-
include:
35-
- edition: "-de"
36-
name: "Build Docs non-plugins"
37-
dockerfile: "Dockerfile.noplugins"
38-
images: "proxy docservice converter"
39-
postfix: "-noplugins"
40-
41-
- edition: ""
42-
name: "Build utils"
43-
dockerfile: "Dockerfile"
44-
images: "example utils"
45-
46-
- edition: ""
47-
name: "Build balancer"
48-
dockerfile: "Dockerfile.balancer"
49-
images: "balancer"
158+
matrix: ${{fromJSON(needs.prepare-build.outputs.matrix)}}
50159
steps:
51160
- name: Checkout code
52-
uses: actions/checkout@v3
161+
uses: actions/checkout@v4
53162

54163
- name: Set up QEMU
55-
uses: docker/setup-qemu-action@v2
164+
uses: docker/setup-qemu-action@v3
56165

57166
- name: Set up Docker Buildx
58-
uses: docker/setup-buildx-action@v2
59-
60-
- name: Login to Docker Hub
61-
uses: docker/login-action@v2
167+
uses: docker/setup-buildx-action@v3
168+
169+
- name: Login to Container Registry
170+
uses: docker/login-action@v3
62171
with:
63-
username: ${{ secrets.DOCKER_HUB_USERNAME }}
64-
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
172+
registry: ${{ inputs.test-repo && secrets.DOCKER_TEST_REGISTRY || 'docker.io' }}
173+
username: ${{ inputs.test-repo && secrets.DOCKER_TEST_USERNAME || secrets.DOCKER_HUB_USERNAME }}
174+
password: ${{ inputs.test-repo && secrets.DOCKER_TEST_ACCESS_TOKEN || secrets.DOCKER_HUB_ACCESS_TOKEN }}
65175

66-
- name: "Build Docs${{ matrix.edition }}"
176+
- name: "${{ matrix.name }}"
67177
env:
178+
REGISTRY: ${{ inputs.test-repo && secrets.DOCKER_TEST_REGISTRY || 'docker.io' }}
68179
DS_VERSION_HASH: ${{ needs.prepare-build.outputs.dsHash }}
69180
SOURCE_TAG: ${{ needs.prepare-build.outputs.sourceTag }}
70181
NOPLUG_POSTFIX: ${{ matrix.postfix }}
71182
DOCKERFILE: ${{ matrix.dockerfile }}
183+
TEST_VERSION: ${{ github.event.inputs.test-version }}
184+
TEST_BUILD: ${{ github.event.inputs.test-build }}
72185
run: |
73186
: ${DS_VERSION_HASH:?Should be set!}
74187
75-
DS_VERSION_HASH=${DS_VERSION_HASH} \
76-
DOCKER_TAG=$(echo ${SOURCE_TAG} | sed 's/^.//') \
188+
if ${{ github.event.inputs.test-repo }}; then
189+
: ${TEST_VERSION:?Should be set!}
190+
: ${TEST_BUILD:?Should be set!}
191+
export PRODUCT_BASEURL=${{ secrets.PRODUCT_BASEURL_RC }}
192+
export RELEASE_VERSION="-${TEST_VERSION}-${TEST_BUILD}.el7"
193+
fi
194+
77195
PRODUCT_EDITION=${{ matrix.edition }} \
78-
TAG=$DOCKER_TAG \
196+
TAG=${SOURCE_TAG} \
79197
docker buildx bake \
80198
-f docker-bake.hcl ${{ matrix.images }} \
81199
--push

Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ ARG TARGETARCH
3232
ARG DS_VERSION_HASH
3333
ARG PRODUCT_EDITION=
3434
ARG RELEASE_VERSION
35-
ARG PRODUCT_URL=https://download.onlyoffice.com/install/documentserver/linux/onlyoffice-documentserver$PRODUCT_EDITION$RELEASE_VERSION.$TARGETARCH.rpm
35+
ARG PRODUCT_BASEURL=https://download.onlyoffice.com/install/documentserver/linux/onlyoffice-documentserver
36+
ARG PRODUCT_URL=${PRODUCT_BASEURL}${PRODUCT_EDITION}${RELEASE_VERSION}.${TARGETARCH}.rpm
3637
ENV TARGETARCH=$TARGETARCH \
3738
DS_VERSION_HASH=$DS_VERSION_HASH
3839
WORKDIR /ds

docker-bake.hcl

+32-6
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,27 @@ variable "DS_VERSION_HASH" {
2727
default = ""
2828
}
2929

30+
variable "REGISTRY" {
31+
default = "docker.io"
32+
}
33+
34+
variable "PRODUCT_BASEURL" {
35+
default = "https://download.onlyoffice.com/install/documentserver/linux/onlyoffice-documentserver"
36+
}
37+
38+
variable "RELEASE_VERSION" {
39+
default = ""
40+
}
41+
3042
group "apps" {
3143
targets = ["proxy", "converter", "docservice", "example"]
3244
}
3345

3446
target "example" {
3547
target = "example"
3648
dockerfile = "${DOCKERFILE}"
37-
tags = ["docker.io/${COMPANY_NAME}/${PREFIX_NAME}-example${PRODUCT_EDITION}:${TAG}"]
49+
tags = equal("docker.io",REGISTRY) ? ["${REGISTRY}/${COMPANY_NAME}/${PREFIX_NAME}-example${PRODUCT_EDITION}:${TAG}"] : [
50+
"${REGISTRY}/${PREFIX_NAME}-example${PRODUCT_EDITION}:${TAG}" ]
3851
platforms = ["linux/amd64", "linux/arm64"]
3952
args = {
4053
"PRODUCT_EDITION": "${PRODUCT_EDITION}"
@@ -44,50 +57,63 @@ target "example" {
4457
target "proxy" {
4558
target = "proxy"
4659
dockerfile = "${DOCKERFILE}"
47-
tags = ["docker.io/${COMPANY_NAME}/${PREFIX_NAME}-proxy${PRODUCT_EDITION}:${TAG}${NOPLUG_POSTFIX}"]
60+
tags = equal("docker.io",REGISTRY) ? ["${REGISTRY}/${COMPANY_NAME}/${PREFIX_NAME}-proxy${PRODUCT_EDITION}:${TAG}${NOPLUG_POSTFIX}"] : [
61+
"${REGISTRY}/${PREFIX_NAME}-proxy${PRODUCT_EDITION}:${TAG}${NOPLUG_POSTFIX}" ]
4862
platforms = ["linux/amd64", "linux/arm64"]
4963
args = {
5064
"PRODUCT_EDITION": "${PRODUCT_EDITION}"
5165
"DS_VERSION_HASH": "${DS_VERSION_HASH}"
66+
"PRODUCT_BASEURL": "${PRODUCT_BASEURL}"
67+
"RELEASE_VERSION": "${RELEASE_VERSION}"
5268
}
5369
}
5470

5571
target "converter" {
5672
target = "converter"
5773
dockerfile = "${DOCKERFILE}"
58-
tags = ["docker.io/${COMPANY_NAME}/${PREFIX_NAME}-converter${PRODUCT_EDITION}:${TAG}${NOPLUG_POSTFIX}"]
74+
tags = equal("docker.io",REGISTRY) ? ["${REGISTRY}/${COMPANY_NAME}/${PREFIX_NAME}-converter${PRODUCT_EDITION}:${TAG}${NOPLUG_POSTFIX}"] : [
75+
"${REGISTRY}/${PREFIX_NAME}-converter${PRODUCT_EDITION}:${TAG}${NOPLUG_POSTFIX}" ]
5976
platforms = ["linux/amd64", "linux/arm64"]
6077
args = {
6178
"PRODUCT_EDITION": "${PRODUCT_EDITION}"
6279
"DS_VERSION_HASH": "${DS_VERSION_HASH}"
80+
"PRODUCT_BASEURL": "${PRODUCT_BASEURL}"
81+
"RELEASE_VERSION": "${RELEASE_VERSION}"
6382
}
6483
}
6584

6685
target "docservice" {
6786
target = "docservice"
6887
dockerfile = "${DOCKERFILE}"
69-
tags = ["docker.io/${COMPANY_NAME}/${PREFIX_NAME}-docservice${PRODUCT_EDITION}:${TAG}${NOPLUG_POSTFIX}"]
88+
tags = equal("docker.io",REGISTRY) ? ["${REGISTRY}/${COMPANY_NAME}/${PREFIX_NAME}-docservice${PRODUCT_EDITION}:${TAG}${NOPLUG_POSTFIX}"] : [
89+
"${REGISTRY}/${PREFIX_NAME}-docservice${PRODUCT_EDITION}:${TAG}${NOPLUG_POSTFIX}" ]
7090
platforms = ["linux/amd64", "linux/arm64"]
7191
args = {
7292
"PRODUCT_EDITION": "${PRODUCT_EDITION}"
7393
"DS_VERSION_HASH": "${DS_VERSION_HASH}"
94+
"PRODUCT_BASEURL": "${PRODUCT_BASEURL}"
95+
"RELEASE_VERSION": "${RELEASE_VERSION}"
7496
}
7597
}
7698

7799
target "utils" {
78100
target = "utils"
79101
dockerfile = "${DOCKERFILE}"
80-
tags = ["docker.io/${COMPANY_NAME}/${PREFIX_NAME}-utils:${TAG}"]
102+
tags = equal("docker.io",REGISTRY) ? ["${REGISTRY}/${COMPANY_NAME}/${PREFIX_NAME}-utils:${TAG}"] : [
103+
"${REGISTRY}/${PREFIX_NAME}-utils:${TAG}" ]
81104
platforms = ["linux/amd64", "linux/arm64"]
82105
args = {
83106
"DS_VERSION_HASH": "${DS_VERSION_HASH}"
107+
"PRODUCT_BASEURL": "${PRODUCT_BASEURL}"
108+
"RELEASE_VERSION": "${RELEASE_VERSION}"
84109
}
85110
}
86111

87112
target "balancer" {
88113
target = "balancer"
89114
dockerfile = "${DOCKERFILE}"
90-
tags = ["docker.io/${COMPANY_NAME}/${PREFIX_NAME}-balancer:${TAG}"]
115+
tags = equal("docker.io",REGISTRY) ? ["${REGISTRY}/${COMPANY_NAME}/${PREFIX_NAME}-balancer:${TAG}"] : [
116+
"${REGISTRY}/${PREFIX_NAME}-balancer:${TAG}" ]
91117
platforms = ["linux/amd64", "linux/arm64"]
92118
}
93119

0 commit comments

Comments
 (0)