2
0

Dockerfile 2.7 KB

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