Skip to content

Commit e2cb627

Browse files
SNOW-582912 adding scripts for Jenkins builds (#298)
1 parent a183e90 commit e2cb627

File tree

5 files changed

+104
-0
lines changed

5 files changed

+104
-0
lines changed

ci/build.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash -e
2+
#
3+
# Build snowflake-sqlalchemy
4+
set -o pipefail
5+
6+
PYTHON="python3.7"
7+
THIS_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8+
SQLALCHEMY_DIR="$(dirname "${THIS_DIR}")"
9+
DIST_DIR="${SQLALCHEMY_DIR}/dist"
10+
11+
cd "$SQLALCHEMY_DIR"
12+
# Clean up previously built DIST_DIR
13+
if [ -d "${DIST_DIR}" ]; then
14+
echo "[WARN] ${DIST_DIR} already existing, deleting it..."
15+
rm -rf "${DIST_DIR}"
16+
fi
17+
18+
# Constants and setup
19+
20+
echo "[Info] Building snowflake-sqlalchemy with $PYTHON"
21+
# Clean up possible build artifacts
22+
rm -rf build generated_version.py
23+
${PYTHON} -m pip install --upgrade pip setuptools wheel build
24+
${PYTHON} -m build --outdir ${DIST_DIR} .

ci/build_docker.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash -e
2+
#
3+
# Build snowflake-sqlalchemy universal wheel in Docker
4+
set -o pipefail
5+
6+
THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
7+
source $THIS_DIR/set_base_image.sh
8+
SQLALCHEMY_DIR="$( dirname "${THIS_DIR}")"
9+
10+
mkdir -p $SQLALCHEMY_DIR/dist
11+
cd $THIS_DIR/docker/sqlalchemy_build
12+
13+
arch=$(uname -p)
14+
15+
BASE_IMAGE=$BASE_IMAGE_MANYLINUX2014
16+
17+
if [[ "$arch" == "aarch64" ]]; then
18+
GOSU_URL=https://github.com/tianon/gosu/releases/download/1.11/gosu-arm64
19+
else
20+
GOSU_URL=https://github.com/tianon/gosu/releases/download/1.11/gosu-amd64
21+
fi
22+
23+
echo "[Info] Building snowflake-sqlalchemy"
24+
docker run \
25+
--rm \
26+
-e TERM=vt102 \
27+
-e PIP_DISABLE_PIP_VERSION_CHECK=1 \
28+
-e LOCAL_USER_ID=$(id -u ${USER}) \
29+
--mount type=bind,source="${SQLALCHEMY_DIR}",target=/home/user/snowflake-sqlalchemy \
30+
$(docker build --pull --build-arg BASE_IMAGE=$BASE_IMAGE --build-arg GOSU_URL="$GOSU_URL" -q .) \
31+
/home/user/snowflake-sqlalchemy/ci/build.sh $1

ci/docker/sqlalchemy_build/Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# We use manylinux1 base image because pyarrow_manylinux2010 has a bug and wheel failed to be audited
2+
ARG BASE_IMAGE=quay.io/pypa/manylinux2014_x86_64
3+
FROM $BASE_IMAGE
4+
5+
# This is to solve permission issue, read https://denibertovic.com/posts/handling-permissions-with-docker-volumes/
6+
ARG GOSU_URL=https://github.com/tianon/gosu/releases/download/1.14/gosu-amd64
7+
ENV GOSU_PATH $GOSU_URL
8+
RUN curl -o /usr/local/bin/gosu -SL $GOSU_PATH \
9+
&& chmod +x /usr/local/bin/gosu
10+
11+
COPY scripts/entrypoint.sh /usr/local/bin/entrypoint.sh
12+
RUN chmod +x /usr/local/bin/entrypoint.sh
13+
14+
WORKDIR /home/user
15+
RUN chmod 777 /home/user
16+
17+
ENV PATH="${PATH}:/opt/python/cp37-cp37m/bin:/opt/python/cp38-cp38/bin:/opt/python/cp39-cp39/bin:/opt/python/cp310-cp310/bin"
18+
19+
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
# Add local user
4+
# Either use the LOCAL_USER_ID if passed in at runtime or
5+
# fallback
6+
7+
USER_ID=${LOCAL_USER_ID:-9001}
8+
9+
echo "Starting with UID : $USER_ID"
10+
useradd --shell /bin/bash -u $USER_ID -o -c "" -m user
11+
export HOME=/home/user
12+
13+
/usr/local/bin/gosu user "$@"

ci/set_base_image.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash -e
2+
#
3+
# Use the internal docker registry if running on Jenkins
4+
#
5+
set -o pipefail
6+
INTERNAL_REPO=nexus.int.snowflakecomputing.com:8086
7+
if [[ -n "$NEXUS_PASSWORD" ]]; then
8+
echo "[INFO] Pull docker images from $INTERNAL_REPO"
9+
NEXUS_USER=${USERNAME:-jenkins}
10+
docker login --username "$NEXUS_USER" --password "$NEXUS_PASSWORD" $INTERNAL_REPO
11+
export BASE_IMAGE_MANYLINUX2010=${INTERNAL_REPO}/docker/manylinux2010_x86_64
12+
export BASE_IMAGE_MANYLINUX2014=${INTERNAL_REPO}/docker/manylinux2014_x86_64
13+
else
14+
echo "[INFO] Pull docker images from public registry"
15+
export BASE_IMAGE_MANYLINUX2010=quay.io/pypa/manylinux2010_x86_64
16+
export BASE_IMAGE_MANYLINUX2014=quay.io/pypa/manylinux2014_x86_64
17+
fi

0 commit comments

Comments
 (0)