Skip to content
This repository has been archived by the owner on Apr 19, 2024. It is now read-only.

Dockerfile / ECS Integration #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Make sure it matches the Ruby version in .ruby-version and Gemfile
ARG RUBY_VERSION=3.2.2
FROM ruby:$RUBY_VERSION-slim

# Install libvips for Active Storage preview support
RUN apt-get update -qq && \
apt-get install -y build-essential libvips libpq-dev gnupg2 curl git && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /usr/share/doc /usr/share/man

# Ensure node.js 18 is available for apt-get
ARG NODE_MAJOR=16
RUN curl -sL https://deb.nodesource.com/setup_$NODE_MAJOR.x | bash -

# Install node and yarn
RUN apt-get update -qq && apt-get install -y nodejs && apt-get install -y npm && npm install -g yarn

# Rails app lives here
WORKDIR /rails

# Set production environment
ENV RAILS_LOG_TO_STDOUT="1" \
RAILS_SERVE_STATIC_FILES="true" \
RAILS_ENV="production" \
BUNDLE_WITHOUT="development" \
NODE_ENV="production" \
NODE_OPTIONS="--openssl-legacy-provider"

# Install application gems
COPY Gemfile Gemfile.lock ./
RUN bundle install

# Copy application code
COPY . .

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

# Precompiling assets for production without requiring secret RAILS_MASTER_KEY
RUN SECRET_KEY_BASE_DUMMY=1 bundle exec rails assets:precompile

# # 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"]

#### BUILD AND DEPLOY COMMAND SEQUENCE
#$>
#$> docker build --platform=linux/arm64 -t judoscale-sample-ruby-app .
#$>
#$> docker tag judoscale-sample-ruby-app:latest 171135638599.dkr.ecr.us-east-2.amazonaws.com/judoscale-sample-ruby-app:latest
#$>
#$> aws ecr get-login-password --region us-east-2 | docker login --username AWS --password-stdin 171135638599.dkr.ecr.us-east-2.amazonaws.com
#$>
#$> docker push 171135638599.dkr.ecr.us-east-2.amazonaws.com/judoscale-sample-ruby-app:latest
13 changes: 3 additions & 10 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby "3.0.1"
ruby "3.2.2"

gem "rails", "~> 6.0.3", ">= 6.0.3.2"
gem "pg", ">= 0.18", "< 2.0"
gem "rails"
gem "pg"
gem "puma", "~> 4.1"
gem "webpacker", "~> 5.0"
gem "turbolinks", "~> 5"
Expand All @@ -14,15 +14,8 @@ gem "judoscale-ruby", github: "judoscale/judoscale-ruby", branch: "main", glob:
gem "judoscale-rails", github: "judoscale/judoscale-ruby", branch: "main", glob: "judoscale-rails/*.gemspec"
gem "judoscale-sidekiq", github: "judoscale/judoscale-ruby", branch: "main", glob: "judoscale-sidekiq/*.gemspec"

group :development, :test do
gem "byebug", platforms: [:mri, :mingw, :x64_mingw]
end

group :development do
gem "web-console", ">= 3.3.0"
gem "listen", "~> 3.2"
gem "spring"
gem "spring-watcher-listen", "~> 2.0.0"
gem "standardrb"
end

Expand Down
Loading