diff --git a/.dockerignore b/.dockerignore index e35c6f0..030d2da 100644 --- a/.dockerignore +++ b/.dockerignore @@ -7,4 +7,5 @@ demo.py *.pt *.md *.sh -*.yaml \ No newline at end of file +*.yaml +.git \ No newline at end of file diff --git a/.github/workflows/build-publish-latest.yaml b/.github/workflows/build-publish-latest.yaml index e3b6a6b..2af9eed 100644 --- a/.github/workflows/build-publish-latest.yaml +++ b/.github/workflows/build-publish-latest.yaml @@ -18,21 +18,6 @@ jobs: steps: - name: checkout uses: actions/checkout@v4 - - - name: Set up python - uses: actions/setup-python@v6 - with: - python-version: '3.13' - - - name: Install and configure Poetry - uses: snok/install-poetry@v1 - with: - version: '2.2.1' - plugins: poetry-plugin-export - - - name: Export requirements - run: | - poetry export -o requirements.txt --without-hashes - name: Login to Docker Hub uses: docker/login-action@v3 diff --git a/.github/workflows/create-release.yaml b/.github/workflows/create-release.yaml index f10513c..aaed4e8 100644 --- a/.github/workflows/create-release.yaml +++ b/.github/workflows/create-release.yaml @@ -99,21 +99,6 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Set up python - uses: actions/setup-python@v6 - with: - python-version: '3.13' - - - name: Install and configure Poetry - uses: snok/install-poetry@v1 - with: - version: '2.2.1' - plugins: poetry-plugin-export - - - name: Export requirements - run: | - poetry export -o requirements.txt --without-hashes - - name: Login to Docker Hub uses: docker/login-action@v3 with: diff --git a/.github/workflows/pr_build.yaml b/.github/workflows/pr_build.yaml index 46ad8ed..504bc1f 100644 --- a/.github/workflows/pr_build.yaml +++ b/.github/workflows/pr_build.yaml @@ -13,7 +13,7 @@ jobs: name: PR Build with Poetry runs-on: [self-hosted, linux, X64] container: - image: starwitorg/base-python-image:3.13.0 + image: starwitorg/base-python-image:3.13.2-py3.13-ptr2.3.4 volumes: - /home/githubrunner/.cache/pypoetry:/root/.cache/pypoetry steps: diff --git a/Dockerfile b/Dockerfile index 7efd03f..ad6dc52 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,13 @@ -# You must run `poetry export` before building this -FROM python:3.13-slim AS build +FROM starwitorg/base-python-image:3.13.2-py3.13-ptr2.3.4 AS build -RUN apt update && apt install --no-install-recommends -y \ - build-essential \ - git - -# This needs to be generated with poetry export -COPY requirements.txt ./ +# Copy only files that are necessary to install dependencies +COPY poetry.lock poetry.toml pyproject.toml /code/ -RUN pip wheel --no-cache-dir --no-deps -r requirements.txt -w /wheels +WORKDIR /code +RUN poetry install + +# Copy the rest of the project +COPY . /code/ FROM python:3.13-slim @@ -20,17 +19,10 @@ RUN apt update && apt install --no-install-recommends -y \ RUN addgroup --system appgroup && adduser --system --ingroup appgroup appuser -WORKDIR /code - -# This needs to be generated with poetry export (same file as above) -COPY requirements.txt ./ +COPY --from=build --chown=appuser:appgroup /code /code -# This should be fine if and only if the wheels are generated based on the poetry exported requirements.txt (see above) -RUN --mount=type=bind,from=build,source=/wheels,target=/wheels \ - pip install /wheels/* - -COPY --chown=appuser:appgroup main.py ./ -COPY --chown=appuser:appgroup ./objecttracker ./objecttracker +WORKDIR /code USER appuser +ENV PATH="/code/.venv/bin:$PATH" CMD [ "python", "main.py" ] \ No newline at end of file diff --git a/docker_build.sh b/docker_build.sh index c8bcaec..4f1069f 100755 --- a/docker_build.sh +++ b/docker_build.sh @@ -1,7 +1,5 @@ #!/bin/bash -poetry export -o requirements.txt --without-hashes - docker build -t starwitorg/sae-object-tracker:local . # Run with other components from the SAE compose project (set redis host to `redis`):