Skip to content

Commit 8db27b6

Browse files
committed
build: allinone
1 parent 5f14d8d commit 8db27b6

File tree

2 files changed

+136
-0
lines changed

2 files changed

+136
-0
lines changed
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
name: build-and-push
2+
3+
run-name: 构建镜像并推送仓库 ${{ github.event.inputs.dockerImageTag }} (${{ github.event.inputs.registry }}) (${{ github.event.inputs.architecture }})
4+
5+
on:
6+
workflow_dispatch:
7+
inputs:
8+
dockerImageTag:
9+
description: 'Image Tag'
10+
default: 'v0.9.0'
11+
required: true
12+
dockerImageTagWithLatest:
13+
description: '是否发布latest tag(正式发版时选择,测试版本切勿选择)'
14+
default: false
15+
required: true
16+
type: boolean
17+
architecture:
18+
description: 'Architecture'
19+
required: true
20+
default: 'linux/amd64'
21+
type: choice
22+
options:
23+
- linux/amd64
24+
- linux/arm64
25+
- linux/amd64,linux/arm64
26+
registry:
27+
description: 'Push To Registry'
28+
required: true
29+
default: 'aliyun-registry'
30+
type: choice
31+
options:
32+
- aliyun-registry
33+
- dockerhub
34+
- dockerhub, aliyun-registry
35+
36+
jobs:
37+
build-and-push-to-aliyun-registry:
38+
if: ${{ contains(github.event.inputs.registry, 'aliyun') }}
39+
runs-on: ubuntu-latest
40+
steps:
41+
- name: Checkout
42+
uses: actions/checkout@v4
43+
with:
44+
ref: ${{ github.ref_name }}
45+
- name: Prepare
46+
id: prepare
47+
run: |
48+
DOCKER_IMAGE=${{ secrets.ALIYUN_REGISTRY_HOST }}/dataease/sqlbot-python-pg
49+
DOCKER_PLATFORMS=${{ github.event.inputs.architecture }}
50+
TAG_NAME=${{ github.event.inputs.dockerImageTag }}
51+
TAG_NAME_WITH_LATEST=${{ github.event.inputs.dockerImageTagWithLatest }}
52+
if [[ ${TAG_NAME_WITH_LATEST} == 'true' ]]; then
53+
DOCKER_IMAGE_TAGS="--tag ${DOCKER_IMAGE}:${TAG_NAME} --tag ${DOCKER_IMAGE}:${TAG_NAME%%.*} --tag ${DOCKER_IMAGE}:latest"
54+
else
55+
DOCKER_IMAGE_TAGS="--tag ${DOCKER_IMAGE}:${TAG_NAME}"
56+
fi
57+
echo ::set-output name=buildx_args::--platform ${DOCKER_PLATFORMS} --memory-swap -1 \
58+
--build-arg DOCKER_IMAGE_TAG=${{ github.event.inputs.dockerImageTag }} --build-arg BUILD_AT=$(TZ=Asia/Shanghai date +'%Y-%m-%dT%H:%M') --build-arg GITHUB_COMMIT=`git rev-parse --short HEAD` --no-cache \
59+
${DOCKER_IMAGE_TAGS} .
60+
- name: Set up Docker Buildx
61+
uses: crazy-max/ghaction-docker-buildx@v3
62+
- name: Login to Aliyun Registry
63+
uses: docker/login-action@v2
64+
with:
65+
registry: ${{ secrets.ALIYUN_REGISTRY_HOST }}
66+
username: ${{ secrets.ALIYUN_REGISTRY_USERNAME }}
67+
password: ${{ secrets.ALIYUN_REGISTRY_PASSWORD }}
68+
- name: Docker Buildx (build-and-push)
69+
run: |
70+
docker buildx build -f Dockerfile-base --output "type=image,push=true" ${{ steps.prepare.outputs.buildx_args }}
71+
72+
build-and-push-to-dockerhub:
73+
if: ${{ contains(github.event.inputs.registry, 'dockerhub') }}
74+
runs-on: ubuntu-latest
75+
steps:
76+
- name: Checkout
77+
uses: actions/checkout@v4
78+
with:
79+
ref: ${{ github.ref_name }}
80+
- name: Prepare
81+
id: prepare
82+
run: |
83+
DOCKER_IMAGE=dataease/sqlbot-python-pg
84+
DOCKER_PLATFORMS=${{ github.event.inputs.architecture }}
85+
TAG_NAME=${{ github.event.inputs.dockerImageTag }}
86+
TAG_NAME_WITH_LATEST=${{ github.event.inputs.dockerImageTagWithLatest }}
87+
if [[ ${TAG_NAME_WITH_LATEST} == 'true' ]]; then
88+
DOCKER_IMAGE_TAGS="--tag ${DOCKER_IMAGE}:${TAG_NAME} --tag ${DOCKER_IMAGE}:${TAG_NAME%%.*} --tag ${DOCKER_IMAGE}:latest"
89+
else
90+
DOCKER_IMAGE_TAGS="--tag ${DOCKER_IMAGE}:${TAG_NAME}"
91+
fi
92+
echo ::set-output name=buildx_args::--platform ${DOCKER_PLATFORMS} --memory-swap -1 \
93+
--build-arg DOCKER_IMAGE_TAG=${{ github.event.inputs.dockerImageTag }} --build-arg BUILD_AT=$(TZ=Asia/Shanghai date +'%Y-%m-%dT%H:%M') --build-arg GITHUB_COMMIT=`git rev-parse --short HEAD` --no-cache \
94+
${DOCKER_IMAGE_TAGS} .
95+
- name: Set up Docker Buildx
96+
uses: crazy-max/ghaction-docker-buildx@v3
97+
- name: Login to Docker Hub
98+
uses: docker/login-action@v3
99+
with:
100+
username: ${{ secrets.DOCKERHUB_USERNAME }}
101+
password: ${{ secrets.DOCKERHUB_TOKEN }}
102+
- name: Docker Buildx (build-and-push)
103+
run: |
104+
docker buildx build -f Dockerfile-base --output "type=image,push=true" ${{ steps.prepare.outputs.buildx_args }}

Dockerfile-base

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
FROM python:3.11-slim-bookworm AS python-builder
2+
FROM registry.cn-qingdao.aliyuncs.com/dataease/postgres:17.6
3+
4+
# python environment
5+
COPY --from=python-builder /usr/local /usr/local
6+
7+
RUN python --version && pip --version
8+
9+
# Install uv tool
10+
COPY --from=ghcr.io/astral-sh/uv:0.7.8 /uv /uvx /bin/
11+
12+
ARG DEPENDENCIES=" \
13+
wait-for-it \
14+
build-essential \
15+
curl \
16+
gnupg \
17+
gcc \
18+
g++ \
19+
libcairo2-dev \
20+
libpango1.0-dev \
21+
libjpeg-dev \
22+
libgif-dev \
23+
librsvg2-dev"
24+
25+
RUN apt-get update && apt-get install -y --no-install-recommends $DEPENDENCIES \
26+
&& curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \
27+
&& apt-get install -y nodejs \
28+
&& curl -L --connect-timeout 60 -m 1800 https://fit2cloud-support.oss-cn-beijing.aliyuncs.com/xpack-license/get-validator-linux | sh \
29+
&& rm -rf /var/lib/apt/lists/* \
30+
&& chmod g-xr /usr/local/bin/* /usr/bin/* /bin/* /usr/sbin/* /sbin/* /usr/lib/postgresql/17/bin/* \
31+
&& chmod g+xr /usr/bin/ld.so \
32+
&& chmod g+x /usr/local/bin/python*

0 commit comments

Comments
 (0)