Skip to content

Commit

Permalink
Merge pull request #42 from shopinvader/update-locomotive
Browse files Browse the repository at this point in the history
Update locomotive (WIP)
  • Loading branch information
sebastienbeau authored Oct 10, 2024
2 parents dd9e2fb + b01b345 commit 3f331ed
Show file tree
Hide file tree
Showing 29 changed files with 389 additions and 306 deletions.
35 changes: 0 additions & 35 deletions Dockerfile

This file was deleted.

68 changes: 68 additions & 0 deletions shopinvader/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# syntax = docker/dockerfile:1

# Make sure RUBY_VERSION matches the Ruby version in .ruby-version and Gemfile
ARG RUBY_VERSION=3.3.5
FROM registry.docker.com/library/ruby:$RUBY_VERSION-slim AS base

# Rails app lives here
WORKDIR /rails

# 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 --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 --no-install-recommends -y build-essential git libvips pkg-config

# Install application gems
COPY Gemfile Gemfile.lock ./
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

# Copy application code
COPY . .

# Precompile bootsnap code for faster boot times
RUN bundle exec bootsnap precompile app/ lib/

# Install packaged need to build JS libs
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
apt-get update && apt-get upgrade -y && \
apt-get install -y nodejs \
npm
RUN --mount=type=cache,target=/root/.npm npm install -g [email protected]

# 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

# Install packages needed for deployment
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y curl libsqlite3-0 libvips nodejs imagemagick && \
rm -rf /var/lib/apt/lists /var/cache/apt/archives

# Copy built artifacts: gems, application
COPY --from=build /usr/local/bundle /usr/local/bundle
COPY --from=build /rails /rails

# Run and own only the runtime files as a non-root user for security
RUN useradd rails --create-home --shell /bin/bash && \
chown -R rails:rails log tmp
USER rails:rails

# Start the server by default, this can be overwritten at runtime
EXPOSE 3000
CMD ["./bin/rails", "server"]
62 changes: 41 additions & 21 deletions shopinvader/Gemfile
Original file line number Diff line number Diff line change
@@ -1,74 +1,94 @@
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

gem 'mongoid'
ruby '3.3.5'

gem 'rails', '~> 7.1', '< 7.2'
gem 'rack-cors', require: 'rack/cors'
gem 'puma', '~> 6.4.0'
gem 'devise'
gem 'carrierwave-aws'
gem 'mimemagic', '~> 0.4.3'

# gem 'pry'
# gem 'custom_fields', path: '../../custom_fields' # for Developers
# gem 'locomotivecms_common', path: '../../common', require: false

# gem 'locomotivecms_steam', path: '../../steam', require: false
# gem 'locomotivecms', path: '../../engine'

# gem 'locomotivecms_search', path: '../../search'

gem 'locomotivecms', github: 'locomotivecms/engine', ref: 'e6fb512c'
gem 'locomotivecms_steam', github: 'locomotivecms/steam', ref: '42b94a0b', require: false
gem 'locomotivecms_common', github: 'locomotivecms/common', ref: 'c78da158', require: false
# gem 'locomotivecms_search', github: 'locomotivecms/search', ref: '35e5813'
gem 'custom_fields', github: 'locomotivecms/custom_fields', ref: '87bf1b', require: false


# Shopinvader specific
gem 'shop_invader', github: 'shopinvader/locomotive-shopinvader', branch: 'v4.0.x'
gem 'mongo_session_store', '~> 3.2.1'
gem 'puma_worker_killer'

# TODO FIXME needed to precompile asset in docker
#gem 'listen', '>= 3.0.5', '< 3.2'
#gem 'nokogiri', '>= 1.10.3'

gem 'aws-sdk-s3'
# Reduces boot times through caching; required in config/boot.rb
gem "bootsnap", require: false

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 7.1', '< 7.2'
# gem 'rails', '~> 7.0', '>= 7.0.4.2'
# Use Puma as the app server
gem 'puma', '~> 6.4.0'
gem 'puma_worker_killer'

# gem 'passenger-rails'
gem 'rack-cors', require: 'rack/cors'

# Use SCSS for stylesheets


# gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
# gem 'uglifier', '>= 4.1.20'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'mini_racer', platforms: :ruby

# Use CoffeeScript for .coffee assets and views
# gem 'coffee-rails', '~> 4.2'
# gem 'coffee-rails', '~> 5.0'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
# gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
# gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use Redis adapter to run Action Cable in production + Cache


# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

gem 'carrierwave-aws'


# gem 'sidekiq'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
gem "debug", ">= 1.0.0"
gem 'dotenv'
end

group :development do
# Access an interactive console on exception pages or by calling 'console' anywhere in the code.
gem 'web-console', '>= 3.3.0'
# gem 'web-console', '>= 3.3.0'
# gem 'listen', '>= 3.0.5', '< 3.2'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
# gem 'spring'
# gem 'spring-watcher-listen', '~> 2.0.0'
end

group :test do
# Adds support for Capybara system testing and selenium driver
gem 'capybara', '~> 2.15'
gem 'selenium-webdriver'
# gem 'capybara', '~> 2.15'
# gem 'selenium-webdriver'
# Easy installation and use of chromedriver to run system tests with Chrome
gem 'chromedriver-helper'
# gem 'chromedriver-helper'
end

group :production do
Expand Down
Loading

0 comments on commit 3f331ed

Please sign in to comment.