diff --git a/.gitignore b/.gitignore index 5187478..67ba563 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ __pycache__/ /gf dist/ dbmate +*.whl diff --git a/build.sh b/build.sh index 8fd128e..810f0e3 100755 --- a/build.sh +++ b/build.sh @@ -2,17 +2,8 @@ set -e -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" - -PACKAGE=`basename $DIR` - -echo "Building package ${PACKAGE}" - -pipenv lock -r > requirements.txt - -INTROSPECTOR_DOCKER_REPO=${DOCKER_REPO:-goldfig} -IMAGE="${INTROSPECTOR_DOCKER_REPO}/${PACKAGE}" -DOCKER_BUILDKIT=1 docker build --platform linux/amd64 -t ${IMAGE} . +echo "Building images" +docker/build.sh echo "Building launcher" launcher/build.sh diff --git a/docker/BuildWheelDockerFile b/docker/BuildWheelDockerFile new file mode 100644 index 0000000..a52c5d6 --- /dev/null +++ b/docker/BuildWheelDockerFile @@ -0,0 +1,3 @@ +FROM python:3.9-buster + +RUN pip install psycopg2-binary \ No newline at end of file diff --git a/Dockerfile b/docker/Dockerfile-amd similarity index 100% rename from Dockerfile rename to docker/Dockerfile-amd diff --git a/docker/Dockerfile-arm b/docker/Dockerfile-arm new file mode 100644 index 0000000..90e40e4 --- /dev/null +++ b/docker/Dockerfile-arm @@ -0,0 +1,17 @@ +FROM python:3.9-slim + +ADD https://github.com/amacneil/dbmate/releases/download/v1.11.0/dbmate-linux-arm64 /app/dbmate +RUN chmod a+x /app/dbmate +RUN apt-get update && apt-get install -y libpq-dev +COPY requirements.txt /app/ +COPY migrations /app/migrations +WORKDIR /app/ +RUN pip install -r requirements.txt +COPY psycopg2_binary-2.8.6-cp39-cp39-linux_aarch64.whl /app/ +RUN pip install /app/psycopg2_binary-2.8.6-cp39-cp39-linux_aarch64.whl +EXPOSE 5000/tcp +COPY introspector.py /app/ +COPY introspector /app/introspector +LABEL introspector-cli=0.0.1 + +ENTRYPOINT ["/app/introspector.py", "serve"] \ No newline at end of file diff --git a/docker/build.sh b/docker/build.sh new file mode 100755 index 0000000..3f65b14 --- /dev/null +++ b/docker/build.sh @@ -0,0 +1,5 @@ +set -e + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +${DIR}/build_arm.sh introspector +${DIR}/build_amd.sh introspector \ No newline at end of file diff --git a/docker/build_amd.sh b/docker/build_amd.sh new file mode 100755 index 0000000..911c564 --- /dev/null +++ b/docker/build_amd.sh @@ -0,0 +1,11 @@ +set -e + +PACKAGE=$1 + +echo "Building package ${PACKAGE}" + +pipenv lock -r > requirements.txt + +INTROSPECTOR_DOCKER_REPO=${DOCKER_REPO:-goldfig} +IMAGE="${INTROSPECTOR_DOCKER_REPO}/${PACKAGE}:amd64-latest" +DOCKER_BUILDKIT=1 docker build --platform linux/amd64 -t ${IMAGE} -f docker/Dockerfile-amd . diff --git a/docker/build_arm.sh b/docker/build_arm.sh new file mode 100755 index 0000000..7abeb60 --- /dev/null +++ b/docker/build_arm.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +set -e + +PACKAGE=$1 + +export DOCKER_BUILDKIT=1 +WHEEL_TAG=goldfig/tempbuildwheel:latest +docker build --platform linux/arm64 -f docker/BuildWheelDockerFile -t $WHEEL_TAG . + +CONTAINER_ID=$(docker run -t -d --rm $WHEEL_TAG) +echo "Container ID $CONTAINER_ID" +WHEEL_FILE=$(docker exec $CONTAINER_ID /usr/local/bin/pip cache list --format abspath) +echo "Wheel file $WHEEL_FILE" +LOCAL_WHEEL=psycopg2_binary-2.8.6-cp39-cp39-linux_aarch64.whl +docker cp $CONTAINER_ID:$WHEEL_FILE $LOCAL_WHEEL +docker stop $CONTAINER_ID + +#PACKAGE=`basename $DIR` + +echo "Building package ${PACKAGE}" + +pipenv lock -r > requirements.tmp +sed '/psycopg2-binary.*/d' requirements.tmp > requirements.txt +rm requirements.tmp + +INTROSPECTOR_DOCKER_REPO=${DOCKER_REPO:-goldfig} +IMAGE="${INTROSPECTOR_DOCKER_REPO}/${PACKAGE}:arm64-latest" +DOCKER_BUILDKIT=1 docker build -f docker/Dockerfile-arm --platform linux/arm64 -t ${IMAGE} . + +echo "Built ${IMAGE}" \ No newline at end of file