From cc02115e1c0e34b1299a302d2c71e22d1c097520 Mon Sep 17 00:00:00 2001 From: Florian Bezannier Date: Thu, 7 Apr 2022 10:00:36 +0200 Subject: [PATCH] ci: change dockerfile build --- .github/workflows/release.yml | 11 +++++++++++ Dockerfile | 13 +++++-------- docker_files/init.sh | 2 +- pyproject.toml | 4 ++-- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f135719..acccb92 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -23,7 +23,12 @@ jobs: run: | poetry version $(git describe --tags --abbrev=0) poetry publish --build --username __token__ --password ${{ secrets.PYPI_TOKEN }} + - uses: actions/upload-artifact@master + with: + name: wheel-package + path: dist/psa_car_controller-$(git describe --tags --abbrev=0)-py3-none-any.whl push_to_registry: + needs: create_release name: Push Docker image to Docker Hub runs-on: ubuntu-latest steps: @@ -41,6 +46,11 @@ jobs: TAGS="${DOCKER_IMAGE}:${VERSION}" fi echo ::set-output name=tags::${TAGS} + echo "PSACC_VERSION=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV + - uses: actions/download-artifact@master + with: + name: wheel-package + path: dist/psa_car_controller-$(git describe --tags --abbrev=0)-py3-none-any.whl - name: Set up QEMU uses: docker/setup-qemu-action@master with: @@ -64,6 +74,7 @@ jobs: push: true tags: ${{ steps.prep.outputs.tags }} platforms: linux/amd64,linux/arm64,linux/arm/v7 + build-args: PSACC_VERSION=${{ env.PSACC_VERSION }} - name: Image digest run: echo ${{ steps.docker_build.outputs.digest }} diff --git a/Dockerfile b/Dockerfile index 4dc4abb..582aa54 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,13 @@ ARG PYTHON_DEP='python3 python3-wheel python3-typing-extensions python3-pandas python3-six python3-dateutil python3-brotli python3-pycryptodome libatlas3-base python3-cryptography python3-scipy androguard python3-flask python3-paho-mqtt python3-ruamel.yaml ca-certificates python3-numpy' ARG DEBIAN_FRONTEND=noninteractive - FROM debian:bullseye-slim AS builder +ARG PSACC_VERSION="0.0.0" ARG PYTHON_DEP RUN BUILD_DEP='python3-pip python3-setuptools python3-dev libblas-dev liblapack-dev gfortran libffi-dev libxml2-dev libxslt1-dev make automake gcc g++ subversion' ; \ apt-get update && apt-get install -y --no-install-recommends $BUILD_DEP $PYTHON_DEP; -RUN pip3 install --upgrade pip -RUN pip3 install poetry -COPY poetry.lock pyproject.toml ./ -RUN poetry build -RUN pip3 install --no-deps --no-cache-dir --ignore-installed dist/psa_car_controller-0.0.0-py3-none-any.whl +RUN pip3 install --upgrade pip && mkdir psa-car-controller && pip3 install poetry +COPY ./dist/psa_car_controller-${PSACC_VERSION}-py3-none-any.whl . +RUN pip3 install --no-cache-dir psa_car_controller-${PSACC_VERSION}-py3-none-any.whl EXPOSE 5000 FROM debian:bullseye-slim @@ -19,10 +17,9 @@ ENV PSACC_BASE_PATH=/ PSACC_PORT=5000 PSACC_OPTIONS="-c -r --web-conf" PSACC_CON COPY --from=builder /var/lib/apt /var/lib/apt COPY --from=builder /var/cache/apt/ /var/cache/apt/ COPY --from=builder /usr/local/lib /usr/local/lib +COPY --from=builder /usr/local/bin/ /usr/local/bin/ RUN apt-get install -y --no-install-recommends $PYTHON_DEP && \ apt-get clean ; \ rm -rf /var/lib/apt/lists/* -RUN mkdir app -COPY psa_car_controller /app/psa_car_controller COPY /docker_files/init.sh /init.sh CMD /init.sh \ No newline at end of file diff --git a/docker_files/init.sh b/docker_files/init.sh index 8e577a5..39229e5 100755 --- a/docker_files/init.sh +++ b/docker_files/init.sh @@ -2,4 +2,4 @@ echo "Containerised psa_car_controller loading..." cd "$PSACC_CONFIG_DIR" ARGS="-p $PSACC_PORT -l 0.0.0.0 -b $PSACC_BASE_PATH $PSACC_OPTIONS" -python3 -u -m psa_car_controller $ARGS +psa-car-controller $ARGS diff --git a/pyproject.toml b/pyproject.toml index dcbe0f3..4c53810 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,12 +24,12 @@ ConfigUpdater = ">=3.0" pandas = ">=0.23" oauth2-client = "^1.2.1" requests = "^2.27.1" -pytz = "^2021.3" +pytz = "^2021.0" argparse = "^1.4.0" geojson = "^2.5.0" reverse-geocode = "^1.4.1" androguard = "^3.3.5" -pycryptodomex = "^3.14.1" +pycryptodomex = "^3.9.0" pydantic = "^1.9.0" "ruamel.yaml" = ">=0.15.0" certifi = ">=14.05.14"