trying cache mounts
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
615cf748b3
commit
2d8838f703
1 changed files with 13 additions and 9 deletions
22
Dockerfile
22
Dockerfile
|
|
@ -19,9 +19,10 @@ FROM docker.io/library/ruby:$RUBY_VERSION-slim AS base
|
|||
WORKDIR /rails
|
||||
|
||||
# Install base packages
|
||||
RUN apt-get update -qq && \
|
||||
apt-get install --no-install-recommends -y curl libjemalloc2 libvips libpq-dev nodejs telnet imagemagick && \
|
||||
rm -rf /var/lib/apt/lists /var/cache/apt/archives
|
||||
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
|
||||
--mount=type=cache,target=/var/lib/apt,sharing=locked \
|
||||
apt update -qq && apt-get --no-install-recommends install -y curl libjemalloc2 libvips libpq-dev nodejs telnet imagemagick && \
|
||||
rm -rf /var/lib/apt/lists /var/cache/apt/archives
|
||||
|
||||
# Set production environment
|
||||
ENV RAILS_ENV="production" \
|
||||
|
|
@ -33,9 +34,10 @@ ENV RAILS_ENV="production" \
|
|||
FROM base AS build
|
||||
|
||||
# Install packages needed to build gems and node modules
|
||||
RUN apt-get update -qq && \
|
||||
apt-get install --no-install-recommends -y build-essential git libyaml-dev node-gyp pkg-config python-is-python3 && \
|
||||
rm -rf /var/lib/apt/lists /var/cache/apt/archives
|
||||
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
|
||||
--mount=type=cache,target=/var/lib/apt,sharing=locked \
|
||||
apt update -qq && apt-get --no-install-recommends install -y build-essential git libyaml-dev node-gyp pkg-config python-is-python3 && \
|
||||
rm -rf /var/lib/apt/lists /var/cache/apt/archives
|
||||
|
||||
# Install JavaScript dependencies
|
||||
ARG NODE_VERSION=22.16.0
|
||||
|
|
@ -48,13 +50,16 @@ RUN curl -sL https://github.com/nodenv/node-build/archive/master.tar.gz | tar xz
|
|||
|
||||
# Install application gems
|
||||
COPY Gemfile Gemfile.lock ./
|
||||
RUN bundle install && \
|
||||
RUN --mount=type=cache,target=/root/.gem \
|
||||
bundle install && \
|
||||
rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git && \
|
||||
bundle exec bootsnap precompile --gemfile
|
||||
|
||||
# Install node modules
|
||||
COPY package.json yarn.lock ./
|
||||
RUN yarn install --immutable
|
||||
ENV YARN_CACHE_FOLDER=/root/.yarn-cache
|
||||
RUN --mount=type=cache,target=/root/.yarn-cache \
|
||||
yarn install --immutable
|
||||
|
||||
# Copy application code
|
||||
COPY . .
|
||||
|
|
@ -65,7 +70,6 @@ RUN bundle exec bootsnap precompile app/ lib/
|
|||
# Precompiling assets for production without requiring secret RAILS_MASTER_KEY
|
||||
RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile
|
||||
|
||||
|
||||
RUN rm -rf node_modules
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue