From 768cedfc565e684575b197074eb52f2251de27e3 Mon Sep 17 00:00:00 2001 From: winkidney Date: Wed, 4 May 2022 20:15:41 +0800 Subject: [PATCH] feature: try to adapt poetry build on arm platform --- Dockerfile.autobuild | 10 ++++++++-- docker/build_docker_multiple_platform.sh | 1 - docker/fix_docker_buildx.sh | 6 ++++++ 3 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 docker/fix_docker_buildx.sh diff --git a/Dockerfile.autobuild b/Dockerfile.autobuild index cd8f8a5..e624f41 100644 --- a/Dockerfile.autobuild +++ b/Dockerfile.autobuild @@ -23,6 +23,7 @@ RUN yarn build # Required for other database options FROM python:3.9.12-slim-buster as base ARG DEBIAN_FRONTEND=noninteractive +ENV CRYPTOGRAPHY_DONT_BUILD_RUST=1 WORKDIR pinry RUN apt-get update \ @@ -31,7 +32,9 @@ RUN apt-get update \ # Install Poetry requirements COPY pyproject.toml ./ COPY poetry.lock ./ -RUN pip install poetry \ +RUN apt-get update && apt-get install libffi-dev cargo -y +RUN pip install --upgrade pip \ + && pip install poetry \ && poetry run pip install mysqlclient cx-Oracle \ && poetry run pip install "rcssmin==1.0.6" --install-option="--without-c-extensions" \ && poetry install @@ -40,6 +43,7 @@ RUN pip install poetry \ # Final image FROM python:3.9.12-slim-buster ARG DEBIAN_FRONTEND=noninteractive +ENV CRYPTOGRAPHY_DONT_BUILD_RUST=1 WORKDIR pinry RUN mkdir /data && chown -R www-data:www-data /data @@ -53,6 +57,8 @@ RUN groupadd -g 2300 tmpgroup \ && groupdel tmpgroup RUN apt-get update \ + # install libffi to build poetry + && apt-get install libffi-dev cargo -y \ # Install nginx && apt-get -y install nginx pwgen \ # Install Pillow dependencies @@ -62,7 +68,7 @@ RUN apt-get update \ && rm -rf /var/lib/apt/lists/* \ && apt-get autoclean -RUN pip install --no-cache-dir poetry +RUN pip install --upgrade pip && pip install --no-cache-dir poetry # Copy from previous stages COPY --from=yarn-build pinry-spa/dist /pinry/pinry-spa/dist diff --git a/docker/build_docker_multiple_platform.sh b/docker/build_docker_multiple_platform.sh index 334560b..8305257 100755 --- a/docker/build_docker_multiple_platform.sh +++ b/docker/build_docker_multiple_platform.sh @@ -6,7 +6,6 @@ IMAGE_LATEST_TAG="latest" IMAGE_VERSION_TAG=`git tag -l --sort=-creatordate | head -n 1 | sed "s/v//g"` sudo docker buildx build \ - --no-cache \ --push \ --platform linux/arm/v7,linux/arm64/v8,linux/amd64 \ -t getpinry/pinry:${IMAGE_LATEST_TAG} \ diff --git a/docker/fix_docker_buildx.sh b/docker/fix_docker_buildx.sh new file mode 100644 index 0000000..9ad9084 --- /dev/null +++ b/docker/fix_docker_buildx.sh @@ -0,0 +1,6 @@ +#!/bin/bash +# from here: https://stackoverflow.com/questions/60080264/docker-cannot-build-multi-platform-images-with-docker-buildx +sudo docker run --rm --privileged multiarch/qemu-user-static --reset -p yes +sudo docker buildx rm builder +sudo docker buildx create --name builder --driver docker-container --use +sudo docker buildx inspect --bootstrap