From e43e5be1f02e41e47079647d1efe32536c96b5cf Mon Sep 17 00:00:00 2001 From: Yatish Mehta Date: Sat, 11 May 2024 00:00:57 -0700 Subject: [PATCH] Added support for base Dockerfile (#9) --- Dockerfile | 77 +++++++++++++++++++++++++++++++++++++++++++++++++ Gemfile.lock | 17 +++++------ bin/shims/vite | 5 ++++ bun.lockb | Bin 66555 -> 66587 bytes package.json | 5 ++-- 5 files changed, 93 insertions(+), 11 deletions(-) create mode 100644 Dockerfile create mode 100755 bin/shims/vite diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f97ef7f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,77 @@ +# syntax = docker/dockerfile:1 + +# Note: This Dockerfile is optimized for production deployment and isn't a good base +# for development enviroments. + +# Make sure RUBY_VERSION matches the Ruby version in .ruby-version +ARG RUBY_VERSION=3.3.1 +FROM registry.docker.com/library/ruby:$RUBY_VERSION-slim as base + +# Rails app lives here +WORKDIR /rails + +# Install base packages +RUN apt-get update -qq && \ + apt-get install --no-install-recommends -y curl libjemalloc2 libvips postgresql-client + +# Set production environment +ENV RAILS_ENV="production" \ + BUNDLE_DEPLOYMENT="1" \ + BUNDLE_PATH="/usr/local/bundle" \ + BUNDLE_WITHOUT="development" + +# Throw-away build stage to reduce size of final image +FROM base as build + +# Install packages needed to build gems +RUN apt-get install --no-install-recommends -y build-essential git libpq-dev pkg-config unzip + +ENV BUN_INSTALL=/usr/local/bun +ENV PATH=/usr/local/bun/bin:$PATH +ARG BUN_VERSION=1.1.8 +RUN curl -fsSL https://bun.sh/install | bash -s -- "bun-v${BUN_VERSION}" + +# Install application gems +COPY Gemfile Gemfile.lock ./ +RUN 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 bun.lockb ./ +RUN bun install --frozen-lockfile + +# Copy application code +COPY . . + +# Precompile bootsnap code for faster boot times +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 + + + + +# Final stage for app image +FROM base + +# Clean up installation packages to reduce image size +RUN rm -rf /var/lib/apt/lists /var/cache/apt/archives + +# Copy built artifacts: gems, application +COPY --from=build "${BUNDLE_PATH}" "${BUNDLE_PATH}" +COPY --from=build /rails /rails + +# Run and own only the runtime files as a non-root user for security +RUN groupadd --system --gid 1000 rails && \ + useradd rails --uid 1000 --gid 1000 --create-home --shell /bin/bash && \ + chown -R rails:rails db log storage tmp +USER 1000:1000 + +# Entrypoint prepares the database. +ENTRYPOINT ["/rails/bin/docker-entrypoint"] + +# Start the server by default, this can be overwritten at runtime +EXPOSE 3000 +CMD ["./bin/rails", "server"] diff --git a/Gemfile.lock b/Gemfile.lock index d50212d..9749af6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -86,7 +86,7 @@ GEM erubi (~> 1.4) parser (>= 2.4) smart_properties - bigdecimal (3.1.7) + bigdecimal (3.1.8) bindex (0.8.1) bootsnap (1.18.3) msgpack (~> 1.2) @@ -104,7 +104,7 @@ GEM debug (1.9.2) irb (~> 1.10) reline (>= 0.3.8) - dotenv (3.1.1) + dotenv (3.1.2) drb (2.2.1) dry-cli (1.0.0) erb_lint (0.5.0) @@ -128,7 +128,7 @@ GEM raabro (~> 1.4) globalid (1.2.1) activesupport (>= 6.1) - i18n (1.14.4) + i18n (1.14.5) concurrent-ruby (~> 1.0) io-console (0.7.2) irb (1.13.1) @@ -157,7 +157,7 @@ GEM minitest (5.22.3) msgpack (1.7.2) mutex_m (0.2.0) - net-imap (0.4.10) + net-imap (0.4.11) date net-protocol net-pop (0.1.2) @@ -166,7 +166,7 @@ GEM timeout net-smtp (0.5.0) net-protocol - nio4r (2.7.1) + nio4r (2.7.3) nokogiri (1.16.4-aarch64-linux) racc (~> 1.4) nokogiri (1.16.4-arm-linux) @@ -191,7 +191,7 @@ GEM nio4r (~> 2.0) raabro (1.4.0) racc (1.7.3) - rack (3.0.10) + rack (3.0.11) rack-proxy (0.7.7) rack rack-session (2.0.0) @@ -235,10 +235,10 @@ GEM rdoc (6.6.3.1) psych (>= 4.0.0) regexp_parser (2.9.0) - reline (0.5.5) + reline (0.5.6) io-console (~> 0.5) rexml (3.2.6) - rubocop (1.63.4) + rubocop (1.63.5) json (~> 2.3) language_server-protocol (>= 3.17.0) parallel (~> 1.10) @@ -311,7 +311,6 @@ PLATFORMS aarch64-linux arm-linux arm64-darwin - arm64-linux x86-linux x86_64-darwin x86_64-linux diff --git a/bin/shims/vite b/bin/shims/vite new file mode 100755 index 0000000..4d5e216 --- /dev/null +++ b/bin/shims/vite @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +set -eo pipefail + +bunx vite "$@" \ No newline at end of file diff --git a/bun.lockb b/bun.lockb index 972935620ac57e6708925940d6a9974fd0f80bd1..68fce3d1e50abc33c047ba2ce4b827b6ebd59a55 100755 GIT binary patch delta 6326 zcmeI0dsI}%9mnszvdW^XAP9F^2uVy*l(>NfA&M-b7)(Hk4_u*91M+a=0|V*_iOQzY zXrji)FKq&fl}N-l)#WX|8jXT@qNcVfYSg^7DJL~GHPzI9fA`_iQ`^&=p0K+VXT zp!YzpNP_SHv=w?UbO)6E%c1?D`Oy2JDbO%zxTZc(j{BXc`rm_cKebScAe6eQVVK~U zTUb1AdU3IE&8X(Tfcn5cCwoqz6PKG;oHO4!D_3ahB?x`t-vafAu7d_ZU7CNEme176 zQ#60H<`0DiBHpOvO9j`po`Mhr$9X6hv_iSzIw&{18Oj~5*77A#j?0H~+&E}IXo6P$ zBdy$D%ZpI1--0Q}m|Rt;!~?quHI~B2DaxLnS1btG=#2}ip}nEsLb<~1yrP0Un;?{- z0@`vpiw70VD$Ef+L9ZPD3jDs%{Osa+&!Ur}y!pk>{1U;5t3;7&AV!D5x)wnDKufgv z+`OFm_5xIxU5tN76M!EAd~oAss2zD8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K;1USiorTFcY%} zl*mOqH13)&g@>CAYQQeg3vly1^cvN6@Z=)BOm=4^Ih-fGMnsPgG`-#!$I}}mgkx*( zZ6ja$?%OC?niCT}5?m|iTkBpBtW9%{|H|j@e$8IyKy1J5U&i&{K&<^H&R-DgY z@~3~v9!~|8H5!cCLEh*uo|)b+V8c0&{|x=1(I92rD2wPkuAZ6QG?eW?nwJeZ$x5!abfXl+$D|YA2BqPfwSwufE{$_&ceh z$spaJeN8d)j6U=+y3tMzBQLyJbZ+rGk112H%&d0&cKPzr>V4+JW4t6xIsSxLO;ODT zqjp@EZaEuiiU{20@$aPEW`op9&mc-W>>DwzYHpKHf6SKF$|rQ7*$}544jvO-lkUGM zCwu(b@nK=h*xj){OK*5Q1O4d7W__G?-ne7W+C^Qy_nr3yXeW~UCKl!tCH-cb$1~fH z(pvOJ_Zg;eJPiUDrqr{(#|~dLciDb9~Atp$FH4=e)j5$ueK+B+vf2c zqth)0qjri)37-#LR902$@!uq=)gav>W2?cWox%DBS|XdJEvGzDL;UH{Rz3M0j-|2f z;U?v*lOHGb5D>Q~HaaF6n?-jp)zq8gw4=t2`CAUPyFR#r0Ng#kOWLXB(Fb35CCt>P zs&^I-6^Xf@08L+CuDHiRBKte1y|(%?3|Njn?$$}(r3_St&^wML=6k=QvyDYMON z(hf!YR9|(i?|m&s=@3sV-cEYj(UvABgwPjl`Z(=ObVKjqZ%lpjon1=zBcrij+&(28 zGhhpv=2d8B!??&L-q@?RruzV1iypKkCf uTABA$<#oMt>8V$OltMo^e)zPKPG4J0<4+Bz8E1`7`N~Nz=jQ912L2BS%r(XU diff --git a/package.json b/package.json index 4644c92..f5aee21 100644 --- a/package.json +++ b/package.json @@ -8,8 +8,9 @@ "postcss": "^8.4.38", "rollup": "^4.2.0", "stimulus-vite-helpers": "^3.1.0", - "vite": "^5.0.0", - "vite-plugin-rails": "^0.5.0" + "vite": "^5.2.11", + "vite-plugin-rails": "^0.5.0", + "vite-plugin-ruby": "^5.0.0" }, "devDependencies": { "tailwindcss": "^3.4.3"