Skip to content

Commit 0ef827c

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

File tree

1 file changed

+94
-8
lines changed

1 file changed

+94
-8
lines changed

.github/workflows/docker-images.yml

+94-8
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,66 @@
1-
name: Build lowcoder dev image
1+
name: Build lowcoder docker images
22

33
on:
4+
workflow_dispatch:
5+
inputs:
6+
imageTag:
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
430
push:
531
branches: dev
32+
paths:
33+
- 'client/**'
34+
- 'server/**'
35+
- 'deploy/docker/**'
36+
release:
37+
types: [released]
638

739
jobs:
840
build:
941
runs-on: ubuntu-latest
1042
steps:
11-
- name: Checkout lowcoder from 'dev' branch
43+
- name: Set environment variables
44+
shell: bash
45+
run: |
46+
# Get the short SHA of last commit
47+
echo "SHORT_SHA=$(echo ${{ github.sha }} | cut -c1-7)" >> "${GITHUB_ENV}"
48+
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+
52+
# Set docker image tag
53+
echo "IMAGE_TAG=${{ inputs.imageTag || github.ref_name }}" >> "${GITHUB_ENV}"
54+
55+
# Control which images to build
56+
echo "BUILD_ALLINONE=${{ inputs.build_allinone || true }}" >> "${GITHUB_ENV}"
57+
echo "BUILD_FRONTEND=${{ inputs.build_frontend || true }}" >> "${GITHUB_ENV}"
58+
echo "BUILD_NODESERVICE=${{ inputs.build_nodeservice || true }}" >> "${GITHUB_ENV}"
59+
echo "BUILD_APISERVICE=${{ inputs.build_apiservice || true }}" >> "${GITHUB_ENV}"
60+
- name: Checkout lowcoder source
1261
uses: actions/checkout@v4
1362
with:
14-
ref: dev
15-
- name: Get commit short SHA
16-
run: echo "SHORT_SHA=$(echo ${{ github.sha }} | cut -c1-7)" >> $GITHUB_ENV
63+
ref: ${{ env.BRANCH_NAME }}
1764
- name: Log into Docker Hub
1865
uses: docker/login-action@v3
1966
with:
@@ -26,17 +73,56 @@ jobs:
2673
driver: cloud
2774
endpoint: "lowcoderorg/lowcoder-cloud-builder"
2875
- name: Build and push the all-in-one image
76+
if: ${{ env.BUILD_ALLINONE == 'true' }}
2977
uses: docker/build-push-action@v6
3078
env:
3179
NODE_ENV: production
3280
with:
3381
file: ./deploy/docker/Dockerfile
3482
build-args: |
3583
REACT_APP_ENV=production
36-
REACT_APP_COMMIT_ID="dev #${SHORT_SHA}"
84+
REACT_APP_COMMIT_ID="dev #${{ env.SHORT_SHA }}"
3785
platforms: |
3886
linux/amd64
3987
linux/arm64
40-
push: true
41-
tags: lowcoderorg/lowcoder-ce:dev
88+
push: false
89+
tags: lowcoderorg/lowcoder-ce:${{ env.IMAGE_TAG }}
90+
- name: Build and push the frontend image
91+
if: ${{ env.BUILD_FRONTEND == 'true' }}
92+
uses: docker/build-push-action@v6
93+
env:
94+
NODE_ENV: production
95+
with:
96+
file: ./deploy/docker/Dockerfile
97+
target: lowcoder-ce-frontend
98+
build-args: |
99+
REACT_APP_ENV=production
100+
REACT_APP_COMMIT_ID="dev #${{ env.SHORT_SHA }}"
101+
platforms: |
102+
linux/amd64
103+
linux/arm64
104+
push: false
105+
tags: lowcoderorg/lowcoder-ce-frontend:${{ env.IMAGE_TAG }}
106+
- name: Build and push the node service image
107+
if: ${{ env.BUILD_NODESERVICE == 'true' }}
108+
uses: docker/build-push-action@v6
109+
with:
110+
file: ./deploy/docker/Dockerfile
111+
target: lowcoder-ce-node-service
112+
platforms: |
113+
linux/amd64
114+
linux/arm64
115+
push: false
116+
tags: lowcoderorg/lowcoder-ce-node-service:${{ env.IMAGE_TAG }}
117+
- name: Build and push the API service image
118+
if: ${{ env.BUILD_APISERVICE == 'true' }}
119+
uses: docker/build-push-action@v6
120+
with:
121+
file: ./deploy/docker/Dockerfile
122+
target: lowcoder-ce-api-service
123+
platforms: |
124+
linux/amd64
125+
linux/arm64
126+
push: false
127+
tags: lowcoderorg/lowcoder-ce-api-service:${{ env.IMAGE_TAG }}
42128

0 commit comments

Comments
 (0)