Skip to content

Commit dfdd7ca

Browse files
committed
fix: enhance docker image build github action
1 parent 722480d commit dfdd7ca

File tree

1 file changed

+107
-8
lines changed

1 file changed

+107
-8
lines changed

.github/workflows/docker-images.yml

Lines changed: 107 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,141 @@
1-
name: Build lowcoder dev image
1+
name: 'Build lowcoder docker images'
22

33
on:
4+
workflow_dispatch:
5+
inputs:
6+
image_tag:
7+
type: choice
8+
description: 'Choose a tag for built docker image(s)'
9+
required: true
10+
default: latest
11+
options:
12+
- latest
13+
- test
14+
build_allinone:
15+
type: boolean
16+
description: 'Build the All-In-One image'
17+
default: true
18+
build_frontend:
19+
type: boolean
20+
description: 'Build the Frontend image'
21+
default: true
22+
build_nodeservice:
23+
type: boolean
24+
description: 'Build the Node service image'
25+
default: true
26+
build_apiservice:
27+
type: boolean
28+
description: 'Build the API service image'
29+
default: true
30+
431
push:
532
branches: dev
33+
paths:
34+
- 'client/**'
35+
- 'server/**'
36+
- 'deploy/docker/**'
37+
38+
release:
39+
types: [released]
640

741
jobs:
842
build:
943
runs-on: ubuntu-latest
1044
steps:
11-
- name: Checkout lowcoder from 'dev' branch
45+
- name: Set environment variables
46+
run: |
47+
# Get the short SHA of last commit
48+
echo "SHORT_SHA=$(echo ${{ github.sha }} | cut -c1-7)" >> "${GITHUB_ENV}"
49+
# Get branch name - we don't use github.ref_head_name since we don't build on PRs
50+
echo "BRANCH_NAME=${{ github.ref_name }}" >> "${GITHUB_ENV}"
51+
# Set docker image tag
52+
echo "IMAGE_TAG=${{ inputs.image_tag || github.ref_name }}" >> "${GITHUB_ENV}"
53+
# Control which images to build
54+
echo "BUILD_ALLINONE=${{ inputs.build_allinone || true }}" >> "${GITHUB_ENV}"
55+
echo "BUILD_FRONTEND=${{ inputs.build_frontend || true }}" >> "${GITHUB_ENV}"
56+
echo "BUILD_NODESERVICE=${{ inputs.build_nodeservice || true }}" >> "${GITHUB_ENV}"
57+
echo "BUILD_APISERVICE=${{ inputs.build_apiservice || true }}" >> "${GITHUB_ENV}"
58+
59+
- name: Checkout lowcoder source
1260
uses: actions/checkout@v4
1361
with:
14-
ref: dev
15-
- name: Get commit short SHA
16-
run: echo "SHORT_SHA=$(echo ${{ github.sha }} | cut -c1-7)" >> $GITHUB_ENV
62+
ref: ${{ env.BRANCH_NAME }}
63+
1764
- name: Log into Docker Hub
1865
uses: docker/login-action@v3
1966
with:
2067
username: ${{ secrets.DOCKER_LOGIN }}
2168
password: ${{ secrets.DOCKER_PASSWORD }}
69+
2270
- name: Setup Docker Buildx with cloud driver
2371
uses: docker/setup-buildx-action@v3
2472
with:
2573
version: "lab:latest"
2674
driver: cloud
2775
endpoint: "lowcoderorg/lowcoder-cloud-builder"
76+
2877
- name: Build and push the all-in-one image
78+
if: ${{ env.BUILD_ALLINONE == 'true' }}
2979
uses: docker/build-push-action@v6
3080
env:
3181
NODE_ENV: production
3282
with:
3383
file: ./deploy/docker/Dockerfile
3484
build-args: |
3585
REACT_APP_ENV=production
36-
REACT_APP_COMMIT_ID="dev #${SHORT_SHA}"
86+
REACT_APP_COMMIT_ID="dev #${{ env.SHORT_SHA }}"
87+
platforms: |
88+
linux/amd64
89+
linux/arm64
90+
push: false
91+
tags: lowcoderorg/lowcoder-ce:${{ env.IMAGE_TAG }}
92+
93+
- name: Build and push the frontend image
94+
if: ${{ env.BUILD_FRONTEND == 'true' }}
95+
uses: docker/build-push-action@v6
96+
env:
97+
NODE_ENV: production
98+
with:
99+
file: ./deploy/docker/Dockerfile
100+
target: lowcoder-ce-frontend
101+
build-args: |
102+
REACT_APP_ENV=production
103+
REACT_APP_COMMIT_ID="dev #${{ env.SHORT_SHA }}"
104+
platforms: |
105+
linux/amd64
106+
linux/arm64
107+
push: false
108+
tags: lowcoderorg/lowcoder-ce:${{ env.IMAGE_TAG }}
109+
110+
- name: Build and push the node service image
111+
if: ${{ env.BUILD_NODESERVICE == 'true' }}
112+
uses: docker/build-push-action@v6
113+
env:
114+
NODE_ENV: production
115+
with:
116+
file: ./deploy/docker/Dockerfile
117+
target: lowcoder-ce-node-service
118+
build-args: |
119+
REACT_APP_ENV=production
120+
REACT_APP_COMMIT_ID="dev #${{ env.SHORT_SHA }}"
121+
platforms: |
122+
linux/amd64
123+
linux/arm64
124+
push: false
125+
tags: lowcoderorg/lowcoder-ce:${{ env.IMAGE_TAG }}
126+
127+
- name: Build and push the API service image
128+
if: ${{ env.BUILD_APISERVICE == 'true' }}
129+
uses: docker/build-push-action@v6
130+
with:
131+
file: ./deploy/docker/Dockerfile
132+
target: lowcoder-ce-api-service
133+
build-args: |
134+
REACT_APP_ENV=production
135+
REACT_APP_COMMIT_ID="dev #${{ env.SHORT_SHA }}"
37136
platforms: |
38137
linux/amd64
39138
linux/arm64
40-
push: true
41-
tags: lowcoderorg/lowcoder-ce:dev
139+
push: false
140+
tags: lowcoderorg/lowcoder-ce:${{ env.IMAGE_TAG }}
42141

0 commit comments

Comments
 (0)