|
| 1 | +name: Build lowcoder docker images |
| 2 | + |
| 3 | +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 |
| 30 | + push: |
| 31 | + branches: dev |
| 32 | + paths: |
| 33 | + - 'client/**' |
| 34 | + - 'server/**' |
| 35 | + - 'deploy/docker/**' |
| 36 | + release: |
| 37 | + types: [released] |
| 38 | + |
| 39 | +jobs: |
| 40 | + build: |
| 41 | + runs-on: ubuntu-latest |
| 42 | + steps: |
| 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 | +
|
| 61 | + - name: Checkout lowcoder source |
| 62 | + uses: actions/checkout@v4 |
| 63 | + with: |
| 64 | + ref: ${{ env.BRANCH_NAME }} |
| 65 | + |
| 66 | + - name: Log into Docker Hub |
| 67 | + uses: docker/login-action@v3 |
| 68 | + with: |
| 69 | + username: ${{ secrets.DOCKER_LOGIN }} |
| 70 | + password: ${{ secrets.DOCKER_PASSWORD }} |
| 71 | + |
| 72 | + - name: Setup Docker Buildx with cloud driver |
| 73 | + uses: docker/setup-buildx-action@v3 |
| 74 | + with: |
| 75 | + version: "lab:latest" |
| 76 | + driver: cloud |
| 77 | + endpoint: "lowcoderorg/lowcoder-cloud-builder" |
| 78 | + |
| 79 | + - name: Build and push the all-in-one image |
| 80 | + if: ${{ env.BUILD_ALLINONE == 'true' }} |
| 81 | + uses: docker/build-push-action@v6 |
| 82 | + env: |
| 83 | + NODE_ENV: production |
| 84 | + with: |
| 85 | + file: ./deploy/docker/Dockerfile |
| 86 | + build-args: | |
| 87 | + REACT_APP_ENV=production |
| 88 | + REACT_APP_COMMIT_ID="dev #${{ env.SHORT_SHA }}" |
| 89 | + platforms: | |
| 90 | + linux/amd64 |
| 91 | + linux/arm64 |
| 92 | + push: true |
| 93 | + tags: lowcoderorg/lowcoder-ce:${{ env.IMAGE_TAG }} |
| 94 | + |
| 95 | + - name: Build and push the frontend image |
| 96 | + if: ${{ env.BUILD_FRONTEND == 'true' }} |
| 97 | + uses: docker/build-push-action@v6 |
| 98 | + env: |
| 99 | + NODE_ENV: production |
| 100 | + with: |
| 101 | + file: ./deploy/docker/Dockerfile |
| 102 | + target: lowcoder-ce-frontend |
| 103 | + build-args: | |
| 104 | + REACT_APP_ENV=production |
| 105 | + REACT_APP_COMMIT_ID="dev #${{ env.SHORT_SHA }}" |
| 106 | + platforms: | |
| 107 | + linux/amd64 |
| 108 | + linux/arm64 |
| 109 | + push: true |
| 110 | + tags: lowcoderorg/lowcoder-ce-frontend:${{ env.IMAGE_TAG }} |
| 111 | + |
| 112 | + - name: Build and push the node service image |
| 113 | + if: ${{ env.BUILD_NODESERVICE == 'true' }} |
| 114 | + uses: docker/build-push-action@v6 |
| 115 | + with: |
| 116 | + file: ./deploy/docker/Dockerfile |
| 117 | + target: lowcoder-ce-node-service |
| 118 | + platforms: | |
| 119 | + linux/amd64 |
| 120 | + linux/arm64 |
| 121 | + push: true |
| 122 | + tags: lowcoderorg/lowcoder-ce-node-service:${{ env.IMAGE_TAG }} |
| 123 | + |
| 124 | + - name: Build and push the API service image |
| 125 | + if: ${{ env.BUILD_APISERVICE == 'true' }} |
| 126 | + uses: docker/build-push-action@v6 |
| 127 | + with: |
| 128 | + file: ./deploy/docker/Dockerfile |
| 129 | + target: lowcoder-ce-api-service |
| 130 | + platforms: | |
| 131 | + linux/amd64 |
| 132 | + linux/arm64 |
| 133 | + push: true |
| 134 | + tags: lowcoderorg/lowcoder-ce-api-service:${{ env.IMAGE_TAG }} |
| 135 | + |
0 commit comments