Dockerfile 3.0 KB

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