Add a model for storing image and video metadata for uploaded files. Metadata is extracted using ExifTool. You will need to install ExifTool after this commit. ExifTool 12.22 is the minimum required version because we use the `--binary` option, which was added in this release. The MediaMetadata model is separate from the MediaAsset model because some files contain tons of metadata, and most of it is non-essential. The MediaAsset model represents an uploaded file and contains essential metadata, like the file's size and type, while the MediaMetadata model represents all the other non-essential metadata associated with a file. Metadata is stored as a JSON column in the database. ExifTool returns all the file's metadata, not just the EXIF metadata. EXIF is one of several types of image metadata, hence why we call it MediaMetadata instead of EXIFMetadata.
78 lines
1.7 KiB
Docker
78 lines
1.7 KiB
Docker
ARG RUBY_VERSION=2.7.1
|
|
ARG NODE_VERSION=14.15.5
|
|
ARG VIPS_VERSION=8.10.6
|
|
ARG FFMPEG_VERSION=4.3.2
|
|
ARG EXIFTOOL_VERSION=12.30
|
|
|
|
|
|
|
|
FROM ubuntu:20.10 AS base
|
|
|
|
WORKDIR /danbooru
|
|
ENV PATH="/root/.asdf/bin:/root/.asdf/shims:$PATH"
|
|
|
|
COPY config/docker/build-base-image.sh .
|
|
|
|
RUN \
|
|
./build-base-image.sh && \
|
|
chmod go+rx /root && \
|
|
useradd --home-dir /root --user-group danbooru && \
|
|
rm build-base-image.sh
|
|
|
|
|
|
|
|
FROM base AS development
|
|
ARG NODE_VERSION
|
|
|
|
RUN \
|
|
apt-get update && \
|
|
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
|
|
build-essential libpq-dev libvips-dev zlib1g-dev \
|
|
curl ca-certificates dirmngr git gpg && \
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
RUN \
|
|
asdf plugin add nodejs && \
|
|
asdf install nodejs "$NODE_VERSION" && \
|
|
asdf global nodejs "$NODE_VERSION" && \
|
|
npm install --unsafe-perm=true -g yarn
|
|
|
|
COPY Gemfile Gemfile.lock ./
|
|
RUN \
|
|
bundle install --jobs "$(nproc)" && \
|
|
rm -rf "$(gem environment gemdir)/cache" && \
|
|
find "$(gem environment gemdir)" -name "*.o" -delete
|
|
|
|
COPY .yarn package.json yarn.lock ./
|
|
RUN yarn install
|
|
|
|
COPY . .
|
|
|
|
ARG SOURCE_COMMIT
|
|
RUN echo "$SOURCE_COMMIT" > REVISION
|
|
|
|
|
|
|
|
FROM development AS assets
|
|
|
|
RUN \
|
|
bin/rails assets:precompile && \
|
|
rm -rf \
|
|
node_modules .yarn/cache tmp /usr/local/share/.cache/yarn \
|
|
/root/.yarn/berry/cache /root/.bundle/cache /root/.npm && \
|
|
asdf uninstall nodejs && \
|
|
ln -s /tmp tmp
|
|
|
|
|
|
|
|
FROM base as production
|
|
|
|
COPY --from=development /root /root
|
|
COPY --from=assets /danbooru /danbooru
|
|
|
|
USER danbooru
|
|
CMD ["bin/rails", "server"]
|
|
|
|
# https://github.com/opencontainers/image-spec/blob/main/annotations.md
|
|
LABEL org.opencontainers.image.source https://github.com/danbooru/danbooru
|