ci: remove armv7 architectures for ARM builds
Now only builds aarch64 on the remote server without Docker
This commit is contained in:
@@ -1,57 +1,63 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# This script builds PostgREST in a remote ARM server. It uses Docker to
|
# This script builds PostgREST in a remote ARM server
|
||||||
# build for multiple platforms (aarch64 and armv7 on ubuntu).
|
|
||||||
# The Dockerfile is located in ./docker-env
|
|
||||||
|
|
||||||
[ -z "$1" ] && { echo "Missing 1st argument: PostgREST github commit SHA"; exit 1; }
|
[ -z "$1" ] && { echo "Missing 1st argument: PostgREST github commit SHA"; exit 1; }
|
||||||
[ -z "$2" ] && { echo "Missing 2nd argument: Docker repo"; exit 1; }
|
[ -z "$2" ] && { echo "Missing 2nd argument: Build environment directory name"; exit 1; }
|
||||||
[ -z "$3" ] && { echo "Missing 3rd argument: Docker username"; exit 1; }
|
|
||||||
[ -z "$4" ] && { echo "Missing 4th argument: Docker password"; exit 1; }
|
|
||||||
[ -z "$5" ] && { echo "Missing 5th argument: Build environment directory name"; exit 1; }
|
|
||||||
|
|
||||||
PGRST_GITHUB_COMMIT="$1"
|
PGRST_GITHUB_COMMIT="$1"
|
||||||
DOCKER_REPO="$2"
|
SCRIPT_DIR="$2"
|
||||||
DOCKER_USER="$3"
|
|
||||||
DOCKER_PASS="$4"
|
|
||||||
SCRIPT_PATH="$5"
|
|
||||||
|
|
||||||
DOCKER_BUILD_PATH="$SCRIPT_PATH/docker-env"
|
DOCKER_BUILD_DIR="$SCRIPT_DIR/docker-env"
|
||||||
|
|
||||||
clean_env()
|
install_packages() {
|
||||||
{
|
sudo apt-get update -y
|
||||||
sudo docker logout
|
sudo apt-get upgrade -y
|
||||||
|
sudo apt-get install -y git build-essential curl libffi-dev libffi7 libgmp-dev libgmp10 libncurses-dev libncurses5 libtinfo5 llvm libnuma-dev zlib1g-dev libpq-dev jq gcc
|
||||||
|
sudo apt-get clean
|
||||||
}
|
}
|
||||||
|
|
||||||
# Login to Docker
|
install_ghcup() {
|
||||||
sudo docker logout
|
export BOOTSTRAP_HASKELL_NONINTERACTIVE=1
|
||||||
{ echo $DOCKER_PASS | sudo docker login -u $DOCKER_USER --password-stdin; } || { echo "Couldn't login to docker"; exit 1; }
|
export BOOTSTRAP_HASKELL_MINIMAL=1
|
||||||
|
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh
|
||||||
|
source ~/.ghcup/env
|
||||||
|
}
|
||||||
|
|
||||||
trap clean_env sigint sigterm exit
|
install_cabal() {
|
||||||
|
ghcup upgrade
|
||||||
|
ghcup install cabal 3.6.0.0
|
||||||
|
ghcup set cabal 3.6.0.0
|
||||||
|
}
|
||||||
|
|
||||||
# Move to the docker build environment
|
install_ghc() {
|
||||||
cd ~/$DOCKER_BUILD_PATH
|
ghcup install ghc 8.10.7
|
||||||
|
ghcup set ghc 8.10.7
|
||||||
|
}
|
||||||
|
|
||||||
# Build ARM versions
|
install_packages
|
||||||
sudo docker buildx build --build-arg PGRST_GITHUB_COMMIT=$PGRST_GITHUB_COMMIT \
|
|
||||||
--build-arg BUILDKIT_INLINE_CACHE=1 \
|
|
||||||
--platform linux/arm/v7,linux/arm64 \
|
|
||||||
--cache-from $DOCKER_REPO/postgrest-build-arm \
|
|
||||||
--target=postgrest-build \
|
|
||||||
-t $DOCKER_REPO/postgrest-build-arm \
|
|
||||||
--push .
|
|
||||||
|
|
||||||
sudo docker logout
|
# Add ghcup to the PATH for this session
|
||||||
|
[ -f ~/.ghcup/env ] && source ~/.ghcup/env
|
||||||
|
|
||||||
# Generate and copy binaries to the local filesystem
|
ghcup --version || install_ghcup
|
||||||
sudo docker buildx build --build-arg PGRST_GITHUB_COMMIT=$PGRST_GITHUB_COMMIT \
|
cabal --version || install_cabal
|
||||||
--cache-from $DOCKER_REPO/postgrest-build-arm \
|
ghc --version || install_ghc
|
||||||
--platform linux/arm/v7,linux/arm64 \
|
|
||||||
--target=postgrest-bin \
|
|
||||||
-o result .
|
|
||||||
|
|
||||||
# Compress binaries
|
cd ~/$SCRIPT_DIR
|
||||||
sudo chown -R ubuntu:ubuntu ~/$DOCKER_BUILD_PATH/result
|
|
||||||
mv ~/$DOCKER_BUILD_PATH/result ~/$SCRIPT_PATH/result
|
# Clone the repository and build the project
|
||||||
cd ~/$SCRIPT_PATH
|
git clone https://github.com/PostgREST/postgrest.git
|
||||||
|
cd postgrest
|
||||||
|
git checkout $PGRST_GITHUB_COMMIT
|
||||||
|
cabal v2-update && cabal v2-build
|
||||||
|
|
||||||
|
# Copy the built binary to the Dockerfile directory
|
||||||
|
PGRST_BIN=$(cabal exec which postgrest | tail -1)
|
||||||
|
cp $PGRST_BIN ~/$DOCKER_BUILD_DIR
|
||||||
|
|
||||||
|
# Move and compress the built binary
|
||||||
|
mkdir -p ~/$SCRIPT_DIR/result
|
||||||
|
mv $PGRST_BIN ~/$SCRIPT_DIR/result
|
||||||
|
cd ~/$SCRIPT_DIR
|
||||||
tar -cJf result.tar.xz result
|
tar -cJf result.tar.xz result
|
||||||
|
|||||||
@@ -1,70 +1,13 @@
|
|||||||
# Build PostgREST for ARM architectures
|
|
||||||
|
|
||||||
FROM ubuntu:focal as postgrest-build
|
|
||||||
|
|
||||||
RUN apt-get update -y \
|
|
||||||
&& apt-get upgrade -y \
|
|
||||||
&& apt-get install -y git build-essential curl libffi-dev libffi7 libgmp-dev libgmp10 libncurses-dev libncurses5 libtinfo5 llvm libnuma-dev zlib1g-dev libpq-dev jq gcc \
|
|
||||||
&& apt-get clean
|
|
||||||
|
|
||||||
# Install ghcup
|
|
||||||
ENV BOOTSTRAP_HASKELL_NONINTERACTIVE=1
|
|
||||||
RUN bash -c "curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh"
|
|
||||||
|
|
||||||
# Add ghcup to PATH
|
|
||||||
ENV PATH=${PATH}:/root/.local/bin
|
|
||||||
ENV PATH=${PATH}:/root/.ghcup/bin
|
|
||||||
|
|
||||||
# Install cabal
|
|
||||||
RUN bash -c "ghcup upgrade"
|
|
||||||
RUN bash -c "ghcup install cabal 3.4.0.0"
|
|
||||||
RUN bash -c "ghcup set cabal 3.4.0.0"
|
|
||||||
|
|
||||||
# Install GHC
|
|
||||||
RUN bash -c "ghcup install ghc 8.10.7"
|
|
||||||
RUN bash -c "ghcup set ghc 8.10.7"
|
|
||||||
|
|
||||||
# Update Path to include Cabal and GHC exports
|
|
||||||
RUN bash -c "echo PATH="$HOME/.local/bin:$PATH" >> $HOME/.bashrc"
|
|
||||||
RUN bash -c "echo export LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH" >> $HOME/.bashrc"
|
|
||||||
RUN bash -c "source $HOME/.bashrc"
|
|
||||||
|
|
||||||
# Clone the repository
|
|
||||||
RUN git clone https://github.com/PostgREST/postgrest.git /postgrest
|
|
||||||
WORKDIR /postgrest
|
|
||||||
RUN cabal v2-update && cabal v2-build
|
|
||||||
|
|
||||||
# Arguments are declared here to save the above installation in cache
|
|
||||||
ARG PGRST_GITHUB_COMMIT
|
|
||||||
|
|
||||||
RUN git pull origin main \
|
|
||||||
&& git checkout $PGRST_GITHUB_COMMIT
|
|
||||||
|
|
||||||
# Build PostgREST
|
|
||||||
RUN mkdir -p /build-export
|
|
||||||
RUN cabal v2-update && cabal v2-build
|
|
||||||
RUN PGRST_BIN=$(cabal exec which postgrest | tail -1) \
|
|
||||||
&& mv $PGRST_BIN /build-export
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Simple image to generate the PostgREST binaries
|
|
||||||
|
|
||||||
FROM scratch as postgrest-bin
|
|
||||||
|
|
||||||
COPY --from=postgrest-build /build-export /
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# PostgREST docker hub image
|
# PostgREST docker hub image
|
||||||
|
|
||||||
FROM ubuntu:focal AS postgrest
|
FROM ubuntu:focal AS postgrest
|
||||||
|
|
||||||
RUN apt-get update -y
|
RUN apt-get update -y \
|
||||||
RUN apt install libpq-dev zlib1g-dev jq gcc libnuma-dev -y
|
&& apt install -y --no-install-recommends libpq-dev zlib1g-dev jq gcc libnuma-dev \
|
||||||
RUN apt-get clean
|
&& apt-get clean \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
COPY --from=postgrest-bin postgrest /usr/bin/postgrest
|
COPY postgrest /usr/bin/postgrest
|
||||||
|
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
|
|
||||||
|
|||||||
@@ -13,11 +13,11 @@ PGRST_GITHUB_COMMIT="$1"
|
|||||||
DOCKER_REPO="$2"
|
DOCKER_REPO="$2"
|
||||||
DOCKER_USER="$3"
|
DOCKER_USER="$3"
|
||||||
DOCKER_PASS="$4"
|
DOCKER_PASS="$4"
|
||||||
SCRIPT_PATH="$5"
|
SCRIPT_DIR="$5"
|
||||||
PGRST_VERSION="v$6"
|
PGRST_VERSION="v$6"
|
||||||
IS_PRERELEASE="$7"
|
IS_PRERELEASE="$7"
|
||||||
|
|
||||||
DOCKER_BUILD_PATH="$SCRIPT_PATH/docker-env"
|
DOCKER_BUILD_DIR="$SCRIPT_DIR/docker-env"
|
||||||
|
|
||||||
clean_env()
|
clean_env()
|
||||||
{
|
{
|
||||||
@@ -31,15 +31,13 @@ sudo docker logout
|
|||||||
trap clean_env sigint sigterm exit
|
trap clean_env sigint sigterm exit
|
||||||
|
|
||||||
# Move to the docker build environment
|
# Move to the docker build environment
|
||||||
cd ~/$DOCKER_BUILD_PATH
|
cd ~/$DOCKER_BUILD_DIR
|
||||||
|
|
||||||
# Push final images to Docker hub
|
# Push final images to Docker hub
|
||||||
# NOTE: This command publishes a separate ARM image because the builds cannot
|
# NOTE: This command publishes a separate ARM image because the builds cannot
|
||||||
# be added to the manifest if they are not in the registry beforehand.
|
# be added to the manifest if they are not in the registry beforehand.
|
||||||
# This image must be manually deleted from Docker Hub at the end of the process.
|
# This image must be manually deleted from Docker Hub at the end of the process.
|
||||||
sudo docker buildx build --build-arg PGRST_GITHUB_COMMIT=$PGRST_GITHUB_COMMIT \
|
sudo docker buildx build --build-arg PGRST_GITHUB_COMMIT=$PGRST_GITHUB_COMMIT \
|
||||||
--platform linux/arm/v7,linux/arm64 \
|
|
||||||
--cache-from $DOCKER_REPO/postgrest-build-arm \
|
|
||||||
-t $DOCKER_REPO/postgrest:$PGRST_VERSION-arm \
|
-t $DOCKER_REPO/postgrest:$PGRST_VERSION-arm \
|
||||||
--push .
|
--push .
|
||||||
|
|
||||||
|
|||||||
@@ -222,16 +222,13 @@ jobs:
|
|||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
|
|
||||||
Build-Cabal-Arm:
|
Build-Cabal-Arm:
|
||||||
name: Build armv7/aarch64 (Cabal)
|
name: Build aarch64 (Cabal)
|
||||||
if: ${{ github.ref == 'refs/heads/main' }}
|
if: ${{ github.ref == 'refs/heads/main' }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
remotepath: ${{ steps.Remote-Dir.outputs.remotepath }}
|
remotepath: ${{ steps.Remote-Dir.outputs.remotepath }}
|
||||||
env:
|
env:
|
||||||
GITHUB_COMMIT: ${{ github.sha }}
|
GITHUB_COMMIT: ${{ github.sha }}
|
||||||
DOCKER_REPO: "postgrest"
|
|
||||||
DOCKER_USER: "stevechavez"
|
|
||||||
DOCKER_PASS: ${{ secrets.DOCKER_PASS }}
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2.4.0
|
- uses: actions/checkout@v2.4.0
|
||||||
- id: Remote-Dir
|
- id: Remote-Dir
|
||||||
@@ -258,8 +255,8 @@ jobs:
|
|||||||
fingerprint: ${{ secrets.SSH_ARM_FINGERPRINT }}
|
fingerprint: ${{ secrets.SSH_ARM_FINGERPRINT }}
|
||||||
command_timeout: 120m
|
command_timeout: 120m
|
||||||
script_stop: true
|
script_stop: true
|
||||||
envs: GITHUB_COMMIT,DOCKER_REPO,DOCKER_USER,DOCKER_PASS,REMOTE_DIR
|
envs: GITHUB_COMMIT,REMOTE_DIR
|
||||||
script: bash ~/$REMOTE_DIR/build.sh "$GITHUB_COMMIT" "$DOCKER_REPO" "$DOCKER_USER" "$DOCKER_PASS" "$REMOTE_DIR"
|
script: bash ~/$REMOTE_DIR/build.sh "$GITHUB_COMMIT" "$REMOTE_DIR"
|
||||||
- name: Download binaries from remote server
|
- name: Download binaries from remote server
|
||||||
uses: nicklasfrahm/scp-action@main
|
uses: nicklasfrahm/scp-action@main
|
||||||
with:
|
with:
|
||||||
@@ -276,13 +273,7 @@ jobs:
|
|||||||
uses: actions/upload-artifact@v2.3.1
|
uses: actions/upload-artifact@v2.3.1
|
||||||
with:
|
with:
|
||||||
name: postgrest-ubuntu-aarch64
|
name: postgrest-ubuntu-aarch64
|
||||||
path: result/linux_arm64/postgrest
|
path: result/postgrest
|
||||||
if-no-files-found: error
|
|
||||||
- name: Save armv7 executable as artifact
|
|
||||||
uses: actions/upload-artifact@v2.3.1
|
|
||||||
with:
|
|
||||||
name: postgrest-ubuntu-armv7
|
|
||||||
path: result/linux_arm_v7/postgrest
|
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
|
|
||||||
|
|
||||||
@@ -385,9 +376,6 @@ jobs:
|
|||||||
tar cJvf "release-bundle/postgrest-v$VERSION-ubuntu-aarch64.tar.xz" \
|
tar cJvf "release-bundle/postgrest-v$VERSION-ubuntu-aarch64.tar.xz" \
|
||||||
-C artifacts/postgrest-ubuntu-aarch64 postgrest
|
-C artifacts/postgrest-ubuntu-aarch64 postgrest
|
||||||
|
|
||||||
tar cJvf "release-bundle/postgrest-v$VERSION-ubuntu-armv7.tar.xz" \
|
|
||||||
-C artifacts/postgrest-ubuntu-armv7 postgrest
|
|
||||||
|
|
||||||
zip "release-bundle/postgrest-v$VERSION-windows-x64.zip" \
|
zip "release-bundle/postgrest-v$VERSION-windows-x64.zip" \
|
||||||
artifacts/postgrest-windows-x64/postgrest.exe
|
artifacts/postgrest-windows-x64/postgrest.exe
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user