From 14fd7642f3b515f4ac7afae25b2c9f51c612873a Mon Sep 17 00:00:00 2001 From: Dean Lofts Date: Sat, 13 Jul 2024 22:03:12 +1000 Subject: [PATCH] fix prod dockerfile --- Dockerfile | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2ea767b..ccff3e0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,9 +16,11 @@ ENV RAILS_ENV="production" \ # Throw-away build stage to reduce size of final image FROM base AS build -# Install packages needed to build gems +# Install packages needed to build gems and Node.js RUN apt-get update -qq && \ - apt-get install --no-install-recommends -y build-essential git libpq-dev libvips pkg-config + apt-get install --no-install-recommends -y build-essential git libpq-dev libvips pkg-config curl && \ + curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \ + apt-get install --no-install-recommends -y nodejs # Install application gems COPY Gemfile Gemfile.lock ./ @@ -32,9 +34,16 @@ RUN --mount=type=bind,target=. \ rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git && \ bundle exec bootsnap precompile --gemfile +# Install Node.js packages +COPY package.json package-lock.json ./ +RUN npm install + # Copy application code COPY . . +# Run Vite build +RUN npx vite build + # Precompile bootsnap code for faster boot times RUN bundle exec bootsnap precompile app/ lib/