Just for reference
Script
#!/bin/sh
echo "Converting all the files within the /fonts folder from TTF to WOFF2..."
FONTS=/fonts/*.ttf
# Force directory change to /fonts
cd /fonts
for f in $FONTS
do
if [ -f $f ]
then
echo "Found $f file. Trying to convert to WOFF2 file"
woff2_compress $f
fi
done
Dockerfile
FROM alpine:latest
RUN mkdir /scripts
WORKDIR /scripts
COPY --chown=root:root --chmod=0700 ttf2woff2.sh /scripts
RUN mkdir /fonts
WORKDIR /fonts
RUN apk update && apk add woff2
CMD ["/scripts/ttf2woff2.sh"]
Hi,
I had posted about the subject last year.
As for the image I proposed it wasn’t updated in years and the commands do not seem to work.
But an image could be createdwith the woff2 tools so that it enables convertion.
Cheers
EDIT:
I did play around for I did not use it much and could not find man pages for that.
it is very simple to use but cannot take wildcards so a script should be written to deal with numerous files to convert.
EDIT 2:
OK I kept it simple but it should work
I shall clean the fonts folder and create an image to test it from scratch.
The idea would be to start the image with a mapped volume. Put ttf files to convert in there and then just run the script.
EDIT 3 :
I got crazy why my files were not copied while paths were correct.
There are 2 things to check.
Build context : which I didn’t really knew but was correct.
The fact that when you map a folder, the original content is unavailable. The script was indeed copied successfully at build but when I mapped the volume where it is located the script disappears.
I had to move the script to a separate folder and it worked.
I shall edit the docker hub page to provide instructions.
docker pull uchitesting/woff2:240509
Voilà !