diff --git a/.github/workflows/push-preview-image-to-vecr.yaml b/.github/workflows/push-preview-image-to-vecr.yaml new file mode 100644 index 00000000..fec65e14 --- /dev/null +++ b/.github/workflows/push-preview-image-to-vecr.yaml @@ -0,0 +1,67 @@ +# Copyright (c) 2025 Beijing Volcano Engine Technology Co., Ltd. and/or its affiliates. +# +# Licensed 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: Push Preview Image to Volcengine Container Registry + +permissions: + contents: read + +on: + push: + branches: + - main + workflow_dispatch: + +jobs: + build-and-push: + runs-on: ubuntu-latest + + # To avoid forked repo execute this workflow + if: github.repository == 'volcengine/veadk-python' + + # Set global environments + env: + CR_URL: veadk-cn-beijing.cr.volces.com + CR_NAMESPACE: veadk + CR_REPO: veadk-python + DOCKERFILE: docker/Dockerfile.preview + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Volcengine Container Registry + run: | + echo "${{ secrets.VE_CR_PASSWORD }}" | \ + docker login veadk-cn-beijing.cr.volces.com \ + -u "${{ secrets.VE_CR_USERNAME }}" \ + --password-stdin + + # Specify a platform, as VeFaaS required `linux/amd64` + - name: Build and push + run: | + IMAGE_TAG=$CR_URL/$CR_NAMESPACE/$CR_REPO:preview + docker buildx build \ + --file $DOCKERFILE \ + --tag $IMAGE_TAG \ + --platform linux/amd64 \ + --push \ + --cache-from=type=gha \ + --cache-to=type=gha,mode=max \ + . \ No newline at end of file diff --git a/.github/workflows/push-stable-image-to-vecr.yaml b/.github/workflows/push-stable-image-to-vecr.yaml new file mode 100644 index 00000000..a30e1b65 --- /dev/null +++ b/.github/workflows/push-stable-image-to-vecr.yaml @@ -0,0 +1,70 @@ +# Copyright (c) 2025 Beijing Volcano Engine Technology Co., Ltd. and/or its affiliates. +# +# Licensed 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: Push Stable Image to Volcengine Container Registry + +on: + push: + # Trigger only when creating tags + tags: + - '*' + workflow_dispatch: + +jobs: + build-and-push: + runs-on: ubuntu-latest + permissions: + contents: read + + # To avoid forked repo execute this workflow + if: github.repository == 'volcengine/veadk-python' + + # Set global environments + env: + CR_URL: veadk-cn-beijing.cr.volces.com + CR_NAMESPACE: veadk + CR_REPO: veadk-python + DOCKERFILE: docker/Dockerfile.stable + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Volcengine Container Registry + run: | + echo "${{ secrets.VE_CR_PASSWORD }}" | \ + docker login veadk-cn-beijing.cr.volces.com \ + -u "${{ secrets.VE_CR_USERNAME }}" \ + --password-stdin + + # Specify a platform, as VeFaaS required `linux/amd64` + # push 2 tags (x.x.x and latest) in one push + - name: Build and push + run: | + LATEST_TAG=$CR_URL/$CR_NAMESPACE/$CR_REPO:latest + VERSION_TAG=$CR_URL/$CR_NAMESPACE/$CR_REPO:$GITHUB_REF_NAME + docker buildx build \ + --file $DOCKERFILE \ + --tag $VERSION_TAG \ + --tag $LATEST_TAG \ + --platform linux/amd64 \ + --push \ + --cache-from=type=gha \ + --cache-to=type=gha,mode=max \ + . \ No newline at end of file diff --git a/docker/Dockerfile.preview b/docker/Dockerfile.preview new file mode 100644 index 00000000..e0ead7a1 --- /dev/null +++ b/docker/Dockerfile.preview @@ -0,0 +1,20 @@ +# Copyright (c) 2025 Beijing Volcano Engine Technology Co., Ltd. and/or its affiliates. +# +# Licensed 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. + +FROM python:3.12 + +# Install git and install veadk-python via git +RUN apt-get install -y git && \ + pip3 install --no-cache-dir git+https://github.com/volcengine/veadk-python.git && \ + apt-get clean && rm -rf /var/lib/apt/lists/* \ No newline at end of file diff --git a/docker/Dockerfile.stable b/docker/Dockerfile.stable new file mode 100644 index 00000000..0cb49951 --- /dev/null +++ b/docker/Dockerfile.stable @@ -0,0 +1,22 @@ +# Copyright (c) 2025 Beijing Volcano Engine Technology Co., Ltd. and/or its affiliates. +# +# Licensed 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. + +FROM python:3.12 + +# In order to avoid PyPI not update VeADK new package, +# we still use git code to build image here. +# TODO: use PyPI source +RUN apt-get install -y git && \ + pip3 install --no-cache-dir git+https://github.com/volcengine/veadk-python.git && \ + apt-get clean && rm -rf /var/lib/apt/lists/* \ No newline at end of file