diff --git a/Dockerfile b/Dockerfile index 7ac5311..d59e1d8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,21 +1,11 @@ -FROM python:3.11-slim-bookworm +FROM python:3.12-slim-bookworm AS builder -RUN apt-get update && apt-get install -y curl procps iputils-ping netcat-traditional && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* +RUN apt-get update && apt-get install -y curl && \ + apt-get clean && rm -rf /var/lib/apt/lists/* ARG BUILD_TYPE COPY requirements.txt / -ADD /ex_app/cs[s] /ex_app/css -ADD /ex_app/im[g] /ex_app/img -ADD /ex_app/j[s] /ex_app/js -ADD /ex_app/l10[n] /ex_app/l10n -ADD /ex_app/li[b] /ex_app/lib - -COPY --chmod=775 healthcheck.sh / -COPY --chmod=775 start.sh / - # Download and install FRP client RUN set -ex; \ ARCH=$(uname -m); \ @@ -33,20 +23,37 @@ RUN set -ex; \ rm -rf /tmp/frp /tmp/frp.tar.gz # Installing PyTorch based on BUILD_TYPE -RUN ARCH=$(uname -m) && \ +RUN --mount=type=cache,target=/root/.cache/pip \ + ARCH=$(uname -m) && \ if [ "$ARCH" = "aarch64" ]; then \ echo "Installing PyTorch for ARM64"; \ - python3 -m pip install torch==2.4.1 torchvision torchaudio; \ + python3 -m pip install --root-user-action=ignore torch==2.4.1 torchvision torchaudio; \ elif [ "$BUILD_TYPE" = "rocm" ]; then \ - python3 -m pip install torch==2.4.1 torchvision torchaudio --index-url https://download.pytorch.org/whl/rocm6.1; \ + python3 -m pip install --root-user-action=ignore torch==2.4.1 torchvision torchaudio --index-url https://download.pytorch.org/whl/rocm6.1; \ elif [ "$BUILD_TYPE" = "cpu" ]; then \ - python3 -m pip install torch==2.4.1 torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu; \ + python3 -m pip install --root-user-action=ignore torch==2.4.1 torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu; \ else \ - python3 -m pip install torch==2.4.1 torchvision torchaudio; \ + python3 -m pip install --root-user-action=ignore torch==2.4.1 torchvision torchaudio; \ fi -RUN \ - python3 -m pip install -r requirements.txt && rm -rf ~/.cache && rm requirements.txt +RUN --mount=type=cache,target=/root/.cache/pip \ + python3 -m pip install --root-user-action=ignore -r requirements.txt && rm requirements.txt + +FROM python:3.12-slim-bookworm + +COPY --from=builder /usr/local/ /usr/local/ + +RUN apt-get update && apt-get install -y curl procps iputils-ping netcat-traditional && \ + apt-get clean && rm -rf /var/lib/apt/lists/* + +ADD /ex_app/cs[s] /ex_app/css +ADD /ex_app/im[g] /ex_app/img +ADD /ex_app/j[s] /ex_app/js +ADD /ex_app/l10[n] /ex_app/l10n +ADD /ex_app/li[b] /ex_app/lib + +COPY --chmod=775 healthcheck.sh / +COPY --chmod=775 start.sh / WORKDIR /ex_app/lib ENTRYPOINT ["/start.sh"] diff --git a/Makefile b/Makefile index 4019ce3..9387147 100644 --- a/Makefile +++ b/Makefile @@ -26,16 +26,16 @@ help: .PHONY: build-push build-push: docker login ghcr.io - docker buildx build --push --platform linux/arm64/v8,linux/amd64 --tag ghcr.io/nextcloud/$(APP_ID):release --build-arg BUILD_TYPE=cpu . - docker buildx build --push --platform linux/amd64 --tag ghcr.io/nextcloud/$(APP_ID):release-cuda --build-arg BUILD_TYPE=cuda . - docker buildx build --push --platform linux/amd64 --tag ghcr.io/nextcloud/$(APP_ID):release-rocm --build-arg BUILD_TYPE=rocm . + DOCKER_BUILDKIT=1 docker buildx build --progress=plain --push --platform linux/arm64/v8,linux/amd64 --tag ghcr.io/nextcloud/$(APP_ID):release --build-arg BUILD_TYPE=cpu . + DOCKER_BUILDKIT=1 docker buildx build --progress=plain --push --platform linux/amd64 --tag ghcr.io/nextcloud/$(APP_ID):release-cuda --build-arg BUILD_TYPE=cuda . + DOCKER_BUILDKIT=1 docker buildx build --progress=plain --push --platform linux/amd64 --tag ghcr.io/nextcloud/$(APP_ID):release-rocm --build-arg BUILD_TYPE=rocm . .PHONY: build-push-latest build-push-latest: docker login ghcr.io - docker buildx build --push --platform linux/arm64/v8,linux/amd64 --tag ghcr.io/nextcloud/$(APP_ID):latest --build-arg BUILD_TYPE=cpu . - docker buildx build --push --platform linux/amd64 --tag ghcr.io/nextcloud/$(APP_ID):latest-cuda --build-arg BUILD_TYPE=cuda . - docker buildx build --push --platform linux/amd64 --tag ghcr.io/nextcloud/$(APP_ID):latest-rocm --build-arg BUILD_TYPE=rocm . + DOCKER_BUILDKIT=1 docker buildx build --progress=plain --push --platform linux/arm64/v8,linux/amd64 --tag ghcr.io/nextcloud/$(APP_ID):latest --build-arg BUILD_TYPE=cpu . + DOCKER_BUILDKIT=1 docker buildx build --progress=plain --push --platform linux/amd64 --tag ghcr.io/nextcloud/$(APP_ID):latest-cuda --build-arg BUILD_TYPE=cuda . + DOCKER_BUILDKIT=1 docker buildx build --progress=plain --push --platform linux/amd64 --tag ghcr.io/nextcloud/$(APP_ID):latest-rocm --build-arg BUILD_TYPE=rocm . .PHONY: run30 run30: diff --git a/requirements.txt b/requirements.txt index caac5a9..ccef928 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1 @@ -nc_py_api[app]>=0.19.1 +nc_py_api[app]>=0.19.2