2023-04-25 20:49:04 +08:00
|
|
|
# Building stage
|
2023-06-21 20:13:20 +08:00
|
|
|
FROM ruby:3.2.2-bookworm AS builder
|
2023-04-25 20:49:04 +08:00
|
|
|
|
|
|
|
RUN rm -f /etc/apt/apt.conf.d/docker-clean; echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache
|
|
|
|
RUN \
|
|
|
|
--mount=type=cache,target=/var/cache/apt,sharing=locked \
|
|
|
|
--mount=type=cache,target=/var/lib/apt,sharing=locked \
|
|
|
|
apt-get update -qq && \
|
|
|
|
apt-get install -y --no-install-recommends \
|
|
|
|
libssl-dev \
|
|
|
|
nodejs \
|
|
|
|
npm \
|
|
|
|
postgresql-client && \
|
|
|
|
npm install -g yarn
|
|
|
|
|
|
|
|
ENV APP_HOME /usr/src/app
|
|
|
|
ENV RAILS_ENV=production
|
2023-07-03 21:53:17 +08:00
|
|
|
ENV GEM_HOME=$APP_HOME/vendor/bundle/ruby/3.2.0
|
2023-04-25 20:49:04 +08:00
|
|
|
ENV PATH=$GEM_HOME/bin:$PATH
|
|
|
|
ENV BUNDLE_APP_CONFIG=.bundle
|
|
|
|
ENV BUNDLE_BUILD__SASSC=--disable-march-tune-native
|
|
|
|
|
|
|
|
COPY . $APP_HOME
|
|
|
|
RUN rm -f $APP_HOME/config/application.yml $APP_HOME/production.env
|
|
|
|
WORKDIR $APP_HOME
|
|
|
|
RUN \
|
|
|
|
--mount=target=$APP_HOME/tmp/bundle,type=cache \
|
|
|
|
bundle config set without 'development test' && \
|
|
|
|
bundle config set path '/usr/src/app/tmp/bundle' && \
|
|
|
|
bundle install --jobs `nproc` && \
|
|
|
|
cp -r tmp/bundle/ vendor && \
|
2023-07-03 21:53:17 +08:00
|
|
|
rm -rf vendor/bundle/ruby/3.2.0/cache && \
|
2023-04-25 20:49:04 +08:00
|
|
|
find vendor/bundle/ruby -type d -name '.git' -exec rm -rf {} + && \
|
|
|
|
bundle config --local path vendor/bundle
|
|
|
|
|
|
|
|
RUN \
|
|
|
|
--mount=type=cache,target=/usr/local/share/.cache/yarn/v6,sharing=locked \
|
|
|
|
--mount=type=cache,target=$APP_HOME/node_modules,sharing=locked \
|
|
|
|
DATABASE_URL=postgresql://postgres@db/scinote_production \
|
|
|
|
SECRET_KEY_BASE=dummy \
|
|
|
|
DEFACE_ENABLED=true \
|
|
|
|
bash -c "rake assets:precompile && rake deface:precompile"
|
|
|
|
|
|
|
|
# Final stage
|
2023-06-21 20:13:20 +08:00
|
|
|
FROM ruby:3.2.2-bookworm AS runner
|
2023-03-09 21:25:12 +08:00
|
|
|
MAINTAINER SciNote <info@scinote.net>
|
2017-03-17 17:48:20 +08:00
|
|
|
|
2023-06-21 20:13:20 +08:00
|
|
|
ARG WKHTMLTOPDF_PACKAGE_URL=https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-3/wkhtmltox_0.12.6.1-3.bookworm_amd64.deb
|
2019-10-17 19:30:14 +08:00
|
|
|
|
2023-04-25 20:49:04 +08:00
|
|
|
RUN rm -f /etc/apt/apt.conf.d/docker-clean; echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache
|
|
|
|
RUN \
|
|
|
|
--mount=type=cache,target=/var/cache/apt,sharing=locked \
|
|
|
|
--mount=type=cache,target=/var/lib/apt,sharing=locked \
|
|
|
|
wget -q -O /tmp/wkhtmltox_amd64.deb $WKHTMLTOPDF_PACKAGE_URL && \
|
|
|
|
DEBIAN_FRONTEND=noninteractive \
|
|
|
|
apt-get update -qq && \
|
|
|
|
apt-get install -y --no-install-recommends \
|
|
|
|
fonts-droid-fallback \
|
|
|
|
fonts-noto-mono \
|
|
|
|
fonts-wqy-microhei \
|
|
|
|
fonts-wqy-zenhei \
|
|
|
|
/tmp/wkhtmltox_amd64.deb && \
|
|
|
|
rm /tmp/wkhtmltox_amd64.deb
|
|
|
|
|
|
|
|
RUN \
|
|
|
|
--mount=type=cache,target=/var/cache/apt,sharing=locked \
|
|
|
|
--mount=type=cache,target=/var/lib/apt,sharing=locked \
|
|
|
|
DEBIAN_FRONTEND=noninteractive \
|
|
|
|
apt-get update -qq && \
|
|
|
|
apt-get install -y --no-install-recommends \
|
2023-07-03 19:06:15 +08:00
|
|
|
default-jre-headless \
|
|
|
|
ca-certificates-java && \
|
|
|
|
apt-get install -y --no-install-recommends \
|
2019-07-26 00:00:24 +08:00
|
|
|
libjemalloc2 \
|
2018-12-11 23:26:24 +08:00
|
|
|
groff-base \
|
2017-03-17 17:48:20 +08:00
|
|
|
postgresql-client \
|
2023-04-25 20:49:04 +08:00
|
|
|
npm \
|
2023-07-04 20:28:40 +08:00
|
|
|
awscli \
|
2023-06-21 20:13:20 +08:00
|
|
|
netcat-openbsd \
|
2019-07-10 20:37:23 +08:00
|
|
|
poppler-utils \
|
2019-09-12 23:21:48 +08:00
|
|
|
librsvg2-2 \
|
|
|
|
libvips42 \
|
2023-04-25 20:49:04 +08:00
|
|
|
graphviz \
|
2017-04-21 15:45:30 +08:00
|
|
|
libfile-mimeinfo-perl && \
|
2023-07-04 20:28:40 +08:00
|
|
|
apt-get install -y libreoffice && \
|
2023-04-25 20:49:04 +08:00
|
|
|
ln -s /usr/lib/x86_64-linux-gnu/libvips.so.42 /usr/lib/x86_64-linux-gnu/libvips.so
|
|
|
|
|
|
|
|
ARG BUILD_TIMESTAMP=1
|
|
|
|
RUN \
|
|
|
|
--mount=type=cache,target=/var/cache/apt,sharing=locked \
|
|
|
|
--mount=type=cache,target=/var/lib/apt,sharing=locked \
|
|
|
|
touch /etc/build-${BUILD_TIMESTAMP} && \
|
|
|
|
DEBIAN_FRONTEND=noninteractive \
|
|
|
|
apt-get update -qq && \
|
|
|
|
apt-get upgrade -y && \
|
2017-03-17 17:48:20 +08:00
|
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
|
2023-04-25 20:49:04 +08:00
|
|
|
ENV APP_HOME /usr/src/app
|
|
|
|
ENV RAILS_ENV=production
|
2023-07-03 21:53:17 +08:00
|
|
|
ENV GEM_HOME=$APP_HOME/vendor/bundle/ruby/3.2.0
|
2023-04-25 20:49:04 +08:00
|
|
|
ENV PATH=$GEM_HOME/bin:$PATH
|
|
|
|
ENV BUNDLE_APP_CONFIG=.bundle
|
2017-04-21 21:13:20 +08:00
|
|
|
|
2023-04-25 20:49:04 +08:00
|
|
|
COPY --from=builder $APP_HOME $APP_HOME
|
2017-03-28 03:04:47 +08:00
|
|
|
|
2017-03-17 17:48:20 +08:00
|
|
|
WORKDIR $APP_HOME
|
|
|
|
|
|
|
|
CMD rails s -b 0.0.0.0
|