Skip to content

Commit

Permalink
chore: build multiarch docker images
Browse files Browse the repository at this point in the history
Signed-off-by: Keming <[email protected]>
  • Loading branch information
kemingy committed Nov 22, 2024
1 parent c4ac1c0 commit d0f84fc
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 53 deletions.
103 changes: 53 additions & 50 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,57 +32,57 @@ jobs:
}
core.setOutput('SEMVER', tag);
build:
runs-on: ubuntu-latest
needs: ["semver"]
strategy:
matrix:
version: ["14", "15", "16", "17"]
arch: ["x86_64", "aarch64"]
env:
PGRX_IMAGE: "ghcr.io/tensorchord/vectorchord-pgrx:0.12.8"
SEMVER: ${{ needs.semver.outputs.SEMVER }}
# build:
# runs-on: ubuntu-latest
# needs: ["semver"]
# strategy:
# matrix:
# version: ["14", "15", "16", "17"]
# arch: ["x86_64", "aarch64"]
# env:
# PGRX_IMAGE: "ghcr.io/tensorchord/vectorchord-pgrx:0.12.8"
# SEMVER: ${{ needs.semver.outputs.SEMVER }}

steps:
- uses: actions/checkout@v4
- name: Configure sccache
uses: actions/github-script@v7
with:
script: |
const url = process.env.ACTIONS_CACHE_URL || '';
const token = process.env.ACTIONS_RUNTIME_TOKEN || '';
core.exportVariable(
'CACHE_ENVS',
`-e CARGO_INCREMENTAL=0 -e SCCACHE_GHA_ENABLED=true -e RUSTC_WRAPPER=sccache -e ACTIONS_CACHE_URL=${url} -e ACTIONS_RUNTIME_TOKEN=${token}`,
);
- name: Set up pgrx docker images and permissions
run: |
docker pull $PGRX_IMAGE
echo "Default user: $(id -u):$(id -g)"
sudo chmod -R 777 .
# steps:
# - uses: actions/checkout@v4
# - name: Configure sccache
# uses: actions/github-script@v7
# with:
# script: |
# const url = process.env.ACTIONS_CACHE_URL || '';
# const token = process.env.ACTIONS_RUNTIME_TOKEN || '';
# core.exportVariable(
# 'CACHE_ENVS',
# `-e CARGO_INCREMENTAL=0 -e SCCACHE_GHA_ENABLED=true -e RUSTC_WRAPPER=sccache -e ACTIONS_CACHE_URL=${url} -e ACTIONS_RUNTIME_TOKEN=${token}`,
# );
# - name: Set up pgrx docker images and permissions
# run: |
# docker pull $PGRX_IMAGE
# echo "Default user: $(id -u):$(id -g)"
# sudo chmod -R 777 .

- name: Build
env:
VERSION: ${{ matrix.version }}
ARCH: ${{ matrix.arch }}
PLATFORM: ${{ matrix.arch == 'x86_64' && 'amd64' || 'arm64' }}
PROFILE: "release"
GH_TOKEN: ${{ github.token }}
run: |
docker run --rm -v .:/workspace $CACHE_ENVS $PGRX_IMAGE build --lib --features pg${{ matrix.version }} --target ${{ matrix.arch }}-unknown-linux-gnu --profile $PROFILE
docker run --rm -v .:/workspace $CACHE_ENVS --entrypoint bash -e SEMVER=${SEMVER} $PGRX_IMAGE ./tools/schema.sh --features pg${{ matrix.version }} --target ${{ matrix.arch }}-unknown-linux-gnu --profile $PROFILE
./tools/package.sh
ls ./build
gh release upload --clobber $SEMVER ./build/vchord-pg${VERSION}_${SEMVER}_${PLATFORM}.deb
gh release upload --clobber $SEMVER ./build/vchord-pg${VERSION}_${ARCH}-unknown-linux-gnu_${SEMVER}.zip
# - name: Build
# env:
# VERSION: ${{ matrix.version }}
# ARCH: ${{ matrix.arch }}
# PLATFORM: ${{ matrix.arch == 'x86_64' && 'amd64' || 'arm64' }}
# PROFILE: "release"
# GH_TOKEN: ${{ github.token }}
# run: |
# docker run --rm -v .:/workspace $CACHE_ENVS $PGRX_IMAGE build --lib --features pg${{ matrix.version }} --target ${{ matrix.arch }}-unknown-linux-gnu --profile $PROFILE
# docker run --rm -v .:/workspace $CACHE_ENVS --entrypoint bash -e SEMVER=${SEMVER} $PGRX_IMAGE ./tools/schema.sh --features pg${{ matrix.version }} --target ${{ matrix.arch }}-unknown-linux-gnu --profile $PROFILE
# ./tools/package.sh
# ls ./build
# gh release upload --clobber $SEMVER ./build/vchord-pg${VERSION}_${SEMVER}_${PLATFORM}.deb
# gh release upload --clobber $SEMVER ./build/vchord-pg${VERSION}_${ARCH}-unknown-linux-gnu_${SEMVER}.zip

docker:
runs-on: ubuntu-latest
needs: ["semver", "build"]
# needs: ["semver", "build"]
needs: ["semver"]
strategy:
matrix:
version: ["14", "15", "16", "17"]
platform: ["amd64", "arm64"]
env:
SEMVER: ${{ needs.semver.outputs.SEMVER }}
steps:
Expand All @@ -92,9 +92,10 @@ jobs:
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release download $SEMVER --pattern "vchord-pg${{ matrix.version }}_${SEMVER}_${{ matrix.platform }}.deb" --output vchord-binary-release.deb
mkdir -p build
cp vchord-binary-release.deb ./build/vchord-pg${{ matrix.version }}_${SEMVER}_${{ matrix.platform }}.deb
for arch in amd64 arm64; do
gh release download $SEMVER --pattern "vchord-pg${{ matrix.version }}_${SEMVER}_${arch}.deb" --output ./build/vchord-pg${{ matrix.version }}_${SEMVER}_${arch}.deb
done
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
Expand All @@ -109,19 +110,21 @@ jobs:
with:
context: .
push: true
platforms: "linux/${{ matrix.platform }}"
platforms: "linux/amd64,linux/arm64"
file: ./docker/binary.Dockerfile
tags: tensorchord/vchord-binary:pg${{ matrix.version }}-v${{ env.SEMVER }}-${{ matrix.platform }}
tags: tensorchord/vchord-binary:pg${{ matrix.version }}-v${{ env.SEMVER }}
build-args: |
PG_VERSION=${{ matrix.version }}
SEMVER=${{ env.SEMVER }}
- name: Push PostgreSQL release to Docker Registry
uses: docker/build-push-action@v6
with:
context: .
push: true
platforms: "linux/${{ matrix.platform }}"
platforms: "linux/amd64,linux/arm64"
file: ./docker/Dockerfile
tags: tensorchord/vchord-postgres:pg${{ matrix.version }}-v${{ env.SEMVER }}-${{ matrix.platform }}
tags: tensorchord/vchord-postgres:pg${{ matrix.version }}-v${{ env.SEMVER }}
build-args: |
PG_VERSION=${{ matrix.version }}
SEMVER=${{ env.SEMVER }}
PGVECTOR=0.8.0
PLATFORM=${{ matrix.platform }}
3 changes: 1 addition & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ FROM pgvector/pgvector:${PGVECTOR}-pg${PG_VERSION}

ARG PG_VERSION
ARG SEMVER=0.0.0
ARG PLATFORM=amd64

RUN echo ${PG_VERSION}
COPY ./build/vchord-pg${PG_VERSION}_${SEMVER}_${PLATFORM}.deb /tmp/vchord.deb
COPY ./build/vchord-pg${PG_VERSION}_${SEMVER}_${TARGETARCH}.deb /tmp/vchord.deb
RUN apt-get install -y /tmp/vchord.deb && rm -f /tmp/vchord.deb

CMD ["postgres", "-c" ,"shared_preload_libraries=vchord.so"]
5 changes: 4 additions & 1 deletion docker/binary.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
FROM scratch

ARG SEMVER
ARG PG_VERSION

WORKDIR /workspace
COPY ./vchord-binary-release.deb /workspace/
COPY ./build/vchord-pg${PG_VERSION}_${SEMVER}_${TARGETARCH}.deb /workspace/

0 comments on commit d0f84fc

Please sign in to comment.