Dockerfile 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # https://alpinelinux.org/releases/
  2. # https://hub.docker.com/_/alpine/tags
  3. ARG HOST_VERSION=3.20
  4. # prebuilt image to speed up to speed up: ghcr.io/newfuture/nuitka-buider:master
  5. ARG BUILDER=base-builder
  6. ARG PYTHON_VERSION=3.8
  7. ARG NUITKA_VERSION=main # 新增此行,定义构建参数并提供默认值
  8. # https://hub.docker.com/_/python/tags?name=3.8-alpine3.20
  9. FROM python:${PYTHON_VERSION}-alpine${HOST_VERSION} AS base-builder
  10. # RUN apk add --no-cache python3-dev py3-pip py3-cffi py3-zstandard py3-ordered-set patchelf clang ccache
  11. RUN apk add --no-cache patchelf gcc ccache libffi-dev build-base zstd-libs\
  12. && rm -rf /var/lib/apt/lists/* /var/cache/* /tmp/* /var/log/*
  13. ARG NUITKA_VERSION
  14. RUN python3 -m pip install --no-cache-dir --prefer-binary \
  15. "https://github.com/Nuitka/Nuitka/archive/${NUITKA_VERSION}.zip" \
  16. --disable-pip-version-check \
  17. --break-system-packages \
  18. && rm -rf /var/cache/* /tmp/* /var/log/* /root/.cache
  19. WORKDIR /app
  20. FROM alpine:${HOST_VERSION} AS base
  21. RUN find /lib /usr/lib /usr/local/lib -name '*.so*' | sed 's|.*/||' | awk '{print "--noinclude-dlls="$0}' > nuitka_exclude_so.txt
  22. FROM ${BUILDER} AS builder
  23. COPY run.py .
  24. COPY ddns ddns
  25. COPY --from=base /nuitka_exclude_so.txt nuitka_exclude_so.txt
  26. RUN python3 -O -m nuitka run.py \
  27. --remove-output \
  28. --lto=yes \
  29. $(cat nuitka_exclude_so.txt)
  30. RUN mkdir /output && cp dist/ddns /output/
  31. COPY docker/entrypoint.sh /output/
  32. FROM alpine:${HOST_VERSION}
  33. COPY --from=builder /output/* /bin/
  34. WORKDIR /ddns
  35. ENTRYPOINT [ "/bin/entrypoint.sh" ]