Dockerfile 1.1 KB

123456789101112131415161718192021222324252627
  1. FROM alpine:latest as builder
  2. ARG TARGETPLATFORM
  3. RUN echo "I'm building for $TARGETPLATFORM"
  4. RUN apk add --no-cache gzip && \
  5. mkdir /mihomo-config && \
  6. wget -O /mihomo-config/geoip.metadb https://fastly.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@release/geoip.metadb && \
  7. wget -O /mihomo-config/geosite.dat https://fastly.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@release/geosite.dat && \
  8. wget -O /mihomo-config/geoip.dat https://fastly.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@release/geoip.dat
  9. COPY docker/file-name.sh /mihomo/file-name.sh
  10. WORKDIR /mihomo
  11. COPY bin/ bin/
  12. RUN FILE_NAME=`sh file-name.sh` && echo $FILE_NAME && \
  13. FILE_NAME=`ls bin/ | egrep "$FILE_NAME.gz"|awk NR==1` && echo $FILE_NAME && \
  14. mv bin/$FILE_NAME mihomo.gz && gzip -d mihomo.gz && echo "$FILE_NAME" > /mihomo-config/test
  15. FROM alpine:latest
  16. LABEL org.opencontainers.image.source="https://github.com/MetaCubeX/mihomo"
  17. RUN apk add --no-cache ca-certificates tzdata iptables
  18. VOLUME ["/root/.config/mihomo/"]
  19. COPY --from=builder /mihomo-config/ /root/.config/mihomo/
  20. COPY --from=builder /mihomo/mihomo /mihomo
  21. RUN chmod +x /mihomo
  22. ENTRYPOINT [ "/mihomo" ]