Update the Postgres client binaries (psql et al) to version 14.0. This is so they match the server version, and so that pg_amcheck is available, which was introduced in 14.0. This requires updating the base image to Ubuntu 21.04 at the same time because the Postgres repo doesn't support version 14.0 on Ubuntu 20.10.
71 lines
1.6 KiB
Docker
71 lines
1.6 KiB
Docker
FROM ubuntu:21.04 AS base
|
|
|
|
WORKDIR /danbooru
|
|
ENV PATH="/root/.asdf/bin:/root/.asdf/shims:$PATH:/usr/lib/postgresql/14/bin"
|
|
|
|
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=14.15.5
|
|
|
|
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
|
|
ENTRYPOINT ["tini", "--"]
|
|
CMD ["bin/rails", "server"]
|
|
|
|
# https://github.com/opencontainers/image-spec/blob/main/annotations.md
|
|
LABEL org.opencontainers.image.source https://github.com/danbooru/danbooru
|