1
0

Dockerfile 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. FROM alpine:edge
  2. LABEL maintainer="Sergey Alexandrovich <darthsim@gmail.com>"
  3. ENV GOPATH /go
  4. ENV PATH /usr/local/go/bin:$PATH
  5. # Install dependencies
  6. RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \
  7. && apk --no-cache upgrade \
  8. && apk add --no-cache \
  9. curl \
  10. git \
  11. ca-certificates \
  12. go \
  13. gcc \
  14. g++ \
  15. make \
  16. musl-dev \
  17. fftw-dev \
  18. glib-dev \
  19. libtool \
  20. expat-dev \
  21. libjpeg-turbo-dev \
  22. libpng-dev \
  23. libwebp-dev \
  24. giflib-dev \
  25. librsvg-dev \
  26. libexif-dev \
  27. lcms2-dev \
  28. libimagequant-dev \
  29. libheif-dev \
  30. tiff-dev
  31. # Build ImageMagick
  32. RUN cd /root \
  33. && mkdir ImageMagick \
  34. && curl -Ls https://imagemagick.org/download/ImageMagick.tar.gz | tar -xz -C ImageMagick --strip-components 1 \
  35. && cd ImageMagick \
  36. && ./configure \
  37. --enable-silent-rules \
  38. --disable-static \
  39. --disable-openmp \
  40. --disable-deprecated \
  41. --disable-docs \
  42. --with-threads \
  43. --without-magick-plus-plus \
  44. --without-utilities \
  45. --without-perl \
  46. --without-bzlib \
  47. --without-dps \
  48. --without-freetype \
  49. --without-jbig \
  50. --without-jpeg \
  51. --without-lcms \
  52. --without-lzma \
  53. --without-png \
  54. --without-tiff \
  55. --without-wmf \
  56. --without-xml \
  57. --without-webp \
  58. && make install-strip
  59. # Build libvips
  60. RUN cd /root \
  61. && export VIPS_VERSION=$(curl -s "https://api.github.com/repos/libvips/libvips/releases/latest" | grep '"tag_name":' | sed -E 's/.*"v([^"]+)".*/\1/') \
  62. && echo "Vips version: $VIPS_VERSION" \
  63. && curl -Ls https://github.com/libvips/libvips/releases/download/v$VIPS_VERSION/vips-$VIPS_VERSION.tar.gz | tar -xz \
  64. && cd vips-$VIPS_VERSION \
  65. && ./configure \
  66. --without-python \
  67. --without-OpenEXR \
  68. --enable-debug=no \
  69. --disable-static \
  70. --enable-silent-rules \
  71. && make install-strip
  72. ADD . /app
  73. WORKDIR /app
  74. # Build imgproxy
  75. RUN cd /app \
  76. && CGO_LDFLAGS_ALLOW="-s|-w" go build -v -o /usr/local/bin/imgproxy
  77. # Copy compiled libs here to copy them to the final image
  78. RUN cd /root \
  79. && mkdir libs \
  80. && ldd /usr/local/bin/imgproxy | grep /usr/local/lib/ | awk '{print $3}' | xargs -I '{}' cp '{}' libs/
  81. # ==================================================================================================
  82. # Final image
  83. FROM alpine:edge
  84. LABEL maintainer="Sergey Alexandrovich <darthsim@gmail.com>"
  85. RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \
  86. && apk --no-cache upgrade \
  87. && apk add --no-cache \
  88. bash \
  89. ca-certificates \
  90. fftw \
  91. glib \
  92. libltdl \
  93. expat \
  94. libjpeg-turbo \
  95. libpng \
  96. libwebp \
  97. giflib \
  98. librsvg \
  99. libgsf \
  100. libexif \
  101. lcms2 \
  102. libimagequant \
  103. libheif \
  104. tiff \
  105. && rm -rf /var/cache/apk*
  106. COPY --from=0 /usr/local/bin/imgproxy /usr/local/bin/
  107. COPY --from=0 /root/libs/* /usr/local/lib/
  108. ENV VIPS_WARNING=0
  109. ENV MALLOC_ARENA_MAX=4
  110. CMD ["imgproxy"]
  111. EXPOSE 8080