-
Notifications
You must be signed in to change notification settings - Fork 1.2k
177 lines (171 loc) · 6.03 KB
/
docker_build.yaml
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
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
name: Docker Build
on:
workflow_dispatch:
inputs:
dinky_version:
description: 'dinky version'
required: true
jobs:
build_front:
name: Build_NPM
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
frontend:
- 'dinky-web/**'
- uses: actions/setup-node@v3
with:
node-version: 16
- name: Get npm cache directory
id: npm-cache-dir
run: |
echo "::set-output name=dir::$(npm config get cache)"
- uses: actions/cache@v3
id: npm-cache # use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true'
with:
path: |
${{ steps.npm-cache-dir.outputs.dir }}
dinky-web/dist
key: ${{ runner.os }}-node-${{ hashFiles('dinky-web/**/package.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install Dependencies
run: cd dinky-web && npm install --no-audit --progress=false --legacy-peer-deps
- name: Npm Web Build
run: cd dinky-web && npm run build
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: dinky-web
path: ./dinky-web/dist
build_release:
name: Build Release
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
flink: [ '1.14', '1.15', '1.16', '1.17', '1.18', '1.19', '1.20' ]
env:
MAVEN_OPTS: -Xmx2G -Xms2G
steps:
- uses: actions/checkout@v3
# maven编译
- name: Set up JDK
uses: actions/setup-java@v2
with:
java-version: 8
distribution: 'adopt'
- name: Cache local Maven repository
uses: actions/cache@v3
with:
path: |
~/.m2/repository/*/*/*
!~/.m2/repository/org/apache/flink
key: ${{ runner.os }}-maven-${{ hashFiles('pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Cache local Flink repository
uses: actions/cache@v3
with:
path: ~/.m2/repository/org/apache/flink
key: ${{ runner.os }}-${{ matrix.flink }}-maven-${{ hashFiles('pom.xml') }}
restore-keys: |
${{ runner.os }}-${{ matrix.flink }}-maven-
- name: Build and Package
run: |
./mvnw -B clean install \
-Dmaven.test.skip=true \
-Dspotless.check.skip=true \
-Denforcer.skip=false \
-Dmaven.javadoc.skip=true \
-P prod,flink-single-version,flink-${{ matrix.flink }},maven-central \
--no-snapshot-updates
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: dinky-realease-${{ matrix.flink }}
path: ./build/dinky-release*.tar.gz
build_image:
name: build image
runs-on: ubuntu-latest
needs: [build_front,build_release]
strategy:
fail-fast: true
matrix:
flink: ["1.14","1.15","1.16","1.17","1.18","1.19","1.20"]
steps:
# git checkout 代码
- name: Checkout
uses: actions/checkout@v4
- name: Download backed artifact
uses: actions/download-artifact@v4
with:
name: dinky-realease-${{ matrix.flink }}
path: ./build
- name: Download front artifact
uses: actions/download-artifact@v4
with:
name: dinky-web
path: ./build/dist
- run: |
tree ./build
# 设置 QEMU, 后面 docker buildx 依赖此.
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
# 设置 Docker buildx, 方便构建 Multi platform 镜像
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# 登录 docker hub
- name: Login to DockerHub
uses: docker/login-action@v3
with:
# GitHub Repo => Settings => Secrets 增加 docker hub 登录密钥信息
# DOCKERHUB_USERNAME 是 docker hub 账号名.
# DOCKERHUB_TOKEN: docker hub => Account Setting => Security 创建.
username: ${{ secrets.DOCKER_IO_USER }}
password: ${{ secrets.DOCKER_IO_PASS }}
# 登录 aliyun docker hub
- name: Login to Aliyun Docker
uses: docker/login-action@v3
with:
registry: registry.cn-hangzhou.aliyuncs.com
username: ${{ secrets.DOCKER_ALIYUN_USER }}
password: ${{ secrets.DOCKER_ALIYUN_PASS }}
# 构建 Docker 并推送到 Docker hub
- name: Build and push
id: docker_build
uses: docker/build-push-action@v5
with:
platforms: linux/amd64,linux/arm64
file: ./deploy/docker/Dockerfile
# 是否 docker push
push: true
context: .
build-args: |
FLINK_VERSION=${{ matrix.flink }}
DINKY_VERSION=${{ inputs.dinky_version }}
tags: |
dinkydocker/dinky-standalone-server:${{ inputs.dinky_version }}-flink${{ matrix.flink }}
registry.cn-hangzhou.aliyuncs.com/dinky/dinky-standalone-server:${{ inputs.dinky_version }}-flink${{ matrix.flink }}
cache-from: type=gha
cache-to: type=gha,mode=max