2
0

Dockerfile 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. FROM ubuntu:latest AS smartdns-builder
  2. LABEL previous-stage=smartdns-builder
  3. # prepare builder
  4. ARG OPENSSL_VER=3.5.4
  5. ARG NODE_VERSION=20.x
  6. RUN apt update && \
  7. apt install -y binutils perl curl make gcc clang wget unzip ca-certificates && \
  8. update-ca-certificates && \
  9. curl -fsSL https://deb.nodesource.com/setup_${NODE_VERSION} | bash - && \
  10. apt install -y nodejs && \
  11. node --version && npm --version && \
  12. \
  13. curl https://sh.rustup.rs -sSf | sh -s -- -y && \
  14. export PATH="$HOME/.cargo/bin:$PATH" && \
  15. \
  16. mkdir -p /build/openssl && \
  17. cd /build/openssl && \
  18. curl -sSL https://www.github.com/openssl/openssl/releases/download/openssl-${OPENSSL_VER}/openssl-${OPENSSL_VER}.tar.gz | tar --strip-components=1 -zxv && \
  19. \
  20. OPENSSL_OPTIONS="no-argon2 no-aria no-async no-bf no-blake2 no-camellia no-cmp no-cms " \
  21. OPENSSL_OPTIONS="$OPENSSL_OPTIONS no-comp no-des no-dh no-dsa no-ec2m no-engine no-gost "\
  22. OPENSSL_OPTIONS="$OPENSSL_OPTIONS no-http no-idea no-legacy no-md4 no-mdc2 no-multiblock "\
  23. OPENSSL_OPTIONS="$OPENSSL_OPTIONS no-nextprotoneg no-ocb no-ocsp no-rc2 no-rc4 no-rmd160 "\
  24. OPENSSL_OPTIONS="$OPENSSL_OPTIONS no-scrypt no-seed no-siphash no-siv no-sm2 no-sm3 no-sm4 "\
  25. OPENSSL_OPTIONS="$OPENSSL_OPTIONS no-srp no-srtp no-ts no-whirlpool no-apps no-ssl-trace "\
  26. OPENSSL_OPTIONS="$OPENSSL_OPTIONS no-ssl no-ssl3 no-tests -Os" \
  27. cd /build/openssl && \
  28. if [ "$(uname -m)" = "aarch64" ]; then \
  29. ./config --prefix=/opt/build $OPENSSL_OPTIONS -mno-outline-atomics ; \
  30. else \
  31. ./config --prefix=/opt/build $OPENSSL_OPTIONS ; \
  32. fi && \
  33. mkdir -p /opt/build/lib /opt/build/lib64 && \
  34. make all -j8 && make install_sw && \
  35. cd / && rm -rf /build
  36. # do make
  37. COPY . /build/smartdns/
  38. RUN cd /build/smartdns && \
  39. export CFLAGS="-I /opt/build/include" && \
  40. export LDFLAGS="-L /opt/build/lib -L /opt/build/lib64" && \
  41. export PATH="$HOME/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" && \
  42. rm -fr /build/smartdns/package/*.tar.gz && \
  43. sh ./package/build-pkg.sh --platform linux --arch `dpkg --print-architecture` --with-ui --static && \
  44. \
  45. ( cd package && tar -xvf *.tar.gz && chmod a+x smartdns/etc/init.d/smartdns ) && \
  46. \
  47. mkdir -p /release/var/log /release/run /release/var/lib/smartdns && \
  48. cp package/smartdns/etc /release/ -a && \
  49. cp package/smartdns/usr /release/ -a && \
  50. rm -f /release/usr/local/smartdns/lib/libssl* && \
  51. rm -f /release/usr/local/smartdns/lib/libcrypto* && \
  52. cp /opt/build/lib/lib*.so* /release/usr/local/lib/smartdns/lib/ -a 2>/dev/null || true && \
  53. cp /opt/build/lib64/lib*.so* /release/usr/local/lib/smartdns/lib/ -a 2>/dev/null || true && \
  54. cd / && rm -rf /build
  55. FROM busybox:stable-musl
  56. COPY --from=smartdns-builder /release/ /
  57. EXPOSE 53/udp 6080/tcp
  58. VOLUME ["/etc/smartdns/", "/var/lib/smartdns/"]
  59. CMD ["/usr/sbin/smartdns", "-f", "-x"]