Dockerfile 2.3 KB

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