2024-04-28 05:46:36 -04:00
|
|
|
FROM ruby:3.3.1-alpine3.19 as ruby-builder
|
2022-12-13 09:50:37 -05:00
|
|
|
|
2024-11-10 23:07:41 -05:00
|
|
|
RUN apk --no-cache add build-base cmake git glib-dev postgresql15-dev gcompat
|
2022-12-13 09:50:37 -05:00
|
|
|
|
|
|
|
COPY Gemfile Gemfile.lock ./
|
2023-05-30 10:07:49 -04:00
|
|
|
RUN gem i foreman && BUNDLE_IGNORE_CONFIG=true bundle install -j$(nproc) \
|
2022-12-13 09:50:37 -05:00
|
|
|
&& rm -rf /usr/local/bundle/cache/*.gem \
|
|
|
|
&& find /usr/local/bundle/gems/ -name "*.c" -delete \
|
|
|
|
&& find /usr/local/bundle/gems/ -name "*.o" -delete
|
|
|
|
|
2024-01-25 16:06:27 -05:00
|
|
|
FROM node:20-alpine3.19 as node-builder
|
2022-12-13 09:50:37 -05:00
|
|
|
RUN apk --no-cache add git
|
|
|
|
WORKDIR /app
|
|
|
|
COPY package.json yarn.lock ./
|
|
|
|
RUN corepack enable && corepack prepare --activate && yarn install
|
|
|
|
|
2024-04-28 05:46:36 -04:00
|
|
|
FROM ruby:3.3.1-alpine3.19
|
2021-11-13 21:31:26 -05:00
|
|
|
|
2022-12-13 09:50:37 -05:00
|
|
|
RUN apk --no-cache add ffmpeg vips \
|
2023-03-01 14:31:49 -05:00
|
|
|
postgresql15-client \
|
2024-01-14 11:30:49 -05:00
|
|
|
git jemalloc tzdata \
|
2024-11-10 23:07:41 -05:00
|
|
|
sudo gcompat
|
2022-04-21 14:22:15 -04:00
|
|
|
|
2022-12-07 03:07:39 -05:00
|
|
|
WORKDIR /app
|
|
|
|
|
2022-12-01 09:57:24 -05:00
|
|
|
ENV LD_PRELOAD=/usr/lib/libjemalloc.so.2
|
2023-09-17 08:37:16 -04:00
|
|
|
ENV RUBY_YJIT_ENABLE=1
|
2021-11-13 21:31:26 -05:00
|
|
|
|
2022-12-13 09:50:37 -05:00
|
|
|
# Setup node and yarn
|
|
|
|
COPY --from=node-builder /usr/lib /usr/lib
|
|
|
|
COPY --from=node-builder /usr/local/share /usr/local/share
|
|
|
|
COPY --from=node-builder /usr/local/lib /usr/local/lib
|
|
|
|
COPY --from=node-builder /usr/local/include /usr/local/include
|
|
|
|
COPY --from=node-builder /usr/local/bin /usr/local/bin
|
2024-01-15 03:59:56 -05:00
|
|
|
# Copy yarn to both root and the user created below to support running as both
|
|
|
|
COPY --from=node-builder /root/.cache/node /root/.cache/node
|
2024-01-14 11:30:49 -05:00
|
|
|
COPY --from=node-builder /root/.cache/node /home/e621ng/.cache/node
|
2021-11-13 21:31:26 -05:00
|
|
|
|
2022-12-13 09:50:37 -05:00
|
|
|
# Copy gems and js packages
|
|
|
|
COPY --from=node-builder /app/node_modules node_modules
|
|
|
|
COPY --from=ruby-builder /usr/local/bundle /usr/local/bundle
|
2022-10-18 17:35:18 -04:00
|
|
|
|
2024-01-14 11:30:49 -05:00
|
|
|
# Create a user with (potentially) the same id as on the host
|
2024-01-14 15:13:08 -05:00
|
|
|
ARG HOST_UID=1000
|
|
|
|
ARG HOST_GID=1000
|
2024-01-14 11:30:49 -05:00
|
|
|
RUN addgroup --gid ${HOST_GID} e621ng && \
|
|
|
|
adduser -S --shell /bin/sh --uid ${HOST_UID} e621ng && \
|
|
|
|
addgroup e621ng wheel && \
|
|
|
|
echo "e621ng ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
|
|
|
|
|
2024-01-15 03:59:56 -05:00
|
|
|
# Ignore warnings from git about .git permission differences when running as root
|
2024-01-14 11:30:49 -05:00
|
|
|
RUN git config --global --add safe.directory $(pwd)
|
|
|
|
|
2022-12-13 09:50:37 -05:00
|
|
|
CMD ["foreman", "start"]
|