[Docker] Use mutlistage build for iqdb

This also pulls in ruby 3 as the repos dependencies got updated
This commit is contained in:
Earlopain 2023-03-09 16:52:23 +01:00
parent 84de15b27d
commit a0a8d7c1ce
No known key found for this signature in database
GPG Key ID: 6CFB948E15246897

View File

@ -1,12 +1,11 @@
FROM ruby:2.7.3-alpine
FROM alpine:3.17 as builder
ADD https://api.github.com/repos/e621ng/iqdbs/git/refs/heads/master /tmp/iqdbs_version.json
COPY iqdb.patch /tmp/iqdb.patch
ENV IQDB_VERSION=20161008
ENV IQDB_CHECKSUM=daa4812b35f84bc7e2f07661fd9abf73a06738c76beb92252666a86ebaea3c64
ARG BUILD_DEPS="build-base libjpeg-turbo-dev gd-dev"
RUN apk --no-cache add build-base git libjpeg-turbo-dev gd-dev bash \
# iqdb
RUN apk --no-cache add $BUILD_DEPS \
&& cd /tmp \
&& wget -q https://iqdb.org/code/iqdb-$IQDB_VERSION.tar.bz2 \
&& echo "$IQDB_CHECKSUM iqdb-$IQDB_VERSION.tar.bz2" | sha256sum -c - \
@ -14,19 +13,19 @@ RUN apk --no-cache add build-base git libjpeg-turbo-dev gd-dev bash \
&& cd iqdb \
&& patch -N -i /tmp/iqdb.patch \
&& make EXTRADEFS="-include stdint.h" -j$(nproc) \
&& cp iqdb /usr/bin \
# iqdbs
&& git clone https://github.com/e621ng/iqdbs /iqdbs \
&& bundler install --gemfile /iqdbs/Gemfile \
# cleanup
&& rm /tmp/iqdb-$IQDB_VERSION.tar.bz2 \
&& rm -rf /tmp/iqdb \
&& apk del build-base git
&& apk del $BUILD_DEPS
# shoreman
RUN wget -O /usr/bin/shoreman https://github.com/chrismytton/shoreman/raw/master/shoreman.sh \
&& chmod +x /usr/bin/shoreman
FROM ruby:3.1.3-alpine3.17
RUN apk --no-cache add git libjpeg-turbo gd tzdata
ADD https://api.github.com/repos/e621ng/iqdbs/git/refs/heads/master /tmp/iqdbs_version.json
RUN git clone https://github.com/e621ng/iqdbs /iqdbs \
&& bundler install --gemfile /iqdbs/Gemfile \
&& gem i foreman
COPY --from=builder /tmp/iqdb/iqdb /usr/bin/
WORKDIR /iqdbs
CMD [ "shoreman" ]
CMD ["foreman", "start"]