1
0

Dockerfile 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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. librsvg-dev \
  23. libexif-dev \
  24. lcms2-dev \
  25. libheif-dev \
  26. tiff-dev \
  27. && apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/main \
  28. giflib-dev \
  29. && apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing \
  30. libimagequant-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-fontconfig \
  50. --without-jbig \
  51. --without-jpeg \
  52. --without-lcms \
  53. --without-lzma \
  54. --without-png \
  55. --without-tiff \
  56. --without-wmf \
  57. --without-xml \
  58. --without-webp \
  59. --without-heic \
  60. --without-pango \
  61. && make install-strip
  62. # Build libvips
  63. RUN cd /root \
  64. && export VIPS_VERSION=$(curl -s "https://api.github.com/repos/libvips/libvips/releases/latest" | grep '"tag_name":' | sed -E 's/.*"v([^"]+)".*/\1/') \
  65. && echo "Vips version: $VIPS_VERSION" \
  66. && curl -Ls https://github.com/libvips/libvips/releases/download/v$VIPS_VERSION/vips-$VIPS_VERSION.tar.gz | tar -xz \
  67. && cd vips-$VIPS_VERSION \
  68. && ./configure \
  69. --without-python \
  70. --without-OpenEXR \
  71. --enable-debug=no \
  72. --disable-static \
  73. --enable-silent-rules \
  74. && make install-strip
  75. ADD . /app
  76. WORKDIR /app
  77. # Build imgproxy
  78. RUN cd /app \
  79. && CGO_LDFLAGS_ALLOW="-s|-w" go build -v -o /usr/local/bin/imgproxy
  80. # Copy compiled libs here to copy them to the final image
  81. RUN cd /root \
  82. && mkdir libs \
  83. && ldd /usr/local/bin/imgproxy | grep /usr/local/lib/ | awk '{print $3}' | xargs -I '{}' cp '{}' libs/
  84. # ==================================================================================================
  85. # Final image
  86. FROM alpine:3.10
  87. LABEL maintainer="Sergey Alexandrovich <darthsim@gmail.com>"
  88. RUN apk --no-cache upgrade \
  89. && apk add --no-cache \
  90. bash \
  91. ca-certificates \
  92. fftw \
  93. glib \
  94. libltdl \
  95. expat \
  96. libjpeg-turbo \
  97. libpng \
  98. libwebp \
  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/main \
  106. giflib \
  107. && apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing \
  108. libimagequant \
  109. && rm -rf /var/cache/apk*
  110. COPY --from=0 /usr/local/bin/imgproxy /usr/local/bin/
  111. COPY --from=0 /root/libs/* /usr/local/lib/
  112. ENV VIPS_WARNING=0
  113. ENV MALLOC_ARENA_MAX=4
  114. CMD ["imgproxy"]
  115. EXPOSE 8080