So I have this Dockerfile that attempts to install ImageMagick the following way:
FROM ruby:2.4-alpine
...
RUN apk --update add imagemagick
...
The point is that the container doesn't recognizes the file
utility (for content-type detection).
Local environment (Mac OSX, installed imagemagick
with brew
):
> file --version
file-5.25
magic file from /usr/share/file/magic
> convert --version
Version: ImageMagick 6.9.9-5 Q16 x86_64 2017-08-03
http://www.imagemagick.org
Copyright: © 1999-2017 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC Modules
Delegates (built-in): bzlib freetype jng jpeg ltdl lzma png tiff xml zlib
Docker Alpine container (accessed to the shell using docker exec -it CONTAINER_ID
):
> file --version
sh: file: not found
> convert --version
Version: ImageMagick 6.9.5-9 Q16 x86_64 2016-10-21
http://www.imagemagick.org
Copyright: Copyright (C) 1999-2016 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher Modules
Delegates (built-in): fontconfig freetype gslib jng jpeg lcms ltdl png ps tiff webp zlib
Also tried installing imagemagick-dev
by itself, and both of them combined without any luck (shouldn't make a difference since the first one is a dependency of the latter, I guess).
The question is, how can I install this in the Alpine container? I think I'm missing something but can't figure it out.
By the way, I can't rely on another function other than file
for content-type detection since I'm using a framework that explicitly uses this.
The file
utility is not part of ImageMagick. It is a standard utility. You can read ore about it at wikipedia:
File (command)
On Alpine Linux, you can install it with apk add --no-cache file
:
/ # file /etc/group
/bin/sh: file: not found
/ # apk add --no-cache file
fetch http://dl-cdn.alpinelinux.org/alpine/v3.6/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.6/community/x86_64/APKINDEX.tar.gz
(1/2) Installing libmagic (5.32-r0)
(2/2) Installing file (5.32-r0)
Executing busybox-1.26.2-r5.trigger
OK: 9 MiB in 13 packages
/ # file /etc/group
/etc/group: ASCII text
/ #
With alpine:3.13
RUN apk --no-cache add php8-pecl-imagick
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With