Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Update Dockerfile and Gem dependencies to latest #19

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
12 changes: 12 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
.git

cdk/
copilot/
kubernetes/
buildspec*

docker-compose*
Dockerfile*

ecs-params*

README.md
59 changes: 41 additions & 18 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,49 @@
# FROM ruby:2.5-slim
FROM public.ecr.aws/bitnami/ruby:2.5
FROM public.ecr.aws/docker/library/ruby:3.3-bookworm AS base

COPY Gemfile Gemfile.lock /usr/src/app/
WORKDIR /usr/src/app
WORKDIR /app

RUN apt-get update && apt-get -y install iproute2 curl jq libgmp3-dev ruby-dev build-essential sqlite libsqlite3-dev python3 python3-pip && \
gem install bundler:1.17.3 && \
bundle install && \
pip3 install awscli netaddr && \
apt-get autoremove -y --purge && \
apt-get remove -y --auto-remove --purge ruby-dev libgmp3-dev build-essential libsqlite3-dev && \
apt-get clean && \
rm -rvf /root/* /root/.gem* /var/cache/*
COPY Gemfile Gemfile.lock ./
RUN bundle install --jobs=10

COPY . /usr/src/app
RUN chmod +x /usr/src/app/startup-cdk.sh
COPY . .

# helpful when trying to update gems -> bundle update, remove the Gemfile.lock, start ruby
# RUN bundle update
# RUN rm -vf /usr/src/app/Gemfile.lock
##########################################################################

FROM public.ecr.aws/docker/library/ruby:3.3-slim-bookworm

COPY --from=base /usr/local/bundle /usr/local/bundle
COPY --from=base /app /app

RUN echo 'APT::Install-Suggests "0";' >> /etc/apt/apt.conf.d/00-docker \
&& echo 'APT::Install-Recommends "0";' >> /etc/apt/apt.conf.d/00-docker \
&& apt update \
&& apt upgrade -y \
&& apt install -y \
iproute2 \
curl \
jq \
unzip \
&& curl https://bun.sh/install | bash \
&& cd /tmp \
&& curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" \
&& unzip awscliv2.zip \
&& ./aws/install \
&& rm -rf /tmp/* \
&& apt purge --autoremove -y \
unzip \
&& apt clean \
&& rm -rf /var/lib/apt/lists/*

ENV BUN_INSTALL="/root/.bun"
ENV PATH="$BUN_INSTALL/bin:$PATH"

WORKDIR /app

ENV RAILS_ENV=production
RUN rails credentials:edit \
&& rake assets:precompile

HEALTHCHECK --interval=10s --timeout=3s \
CMD curl -f -s http://localhost:3000/health/ || exit 1
EXPOSE 3000
ENTRYPOINT ["bash","/usr/src/app/startup-cdk.sh"]
ENTRYPOINT ["bash","/app/startup-cdk.sh"]
52 changes: 36 additions & 16 deletions Dockerfile.cdk
Original file line number Diff line number Diff line change
@@ -1,24 +1,44 @@
FROM ruby:2.5-slim
FROM public.ecr.aws/docker/library/ruby:3.3-bookworm AS base

COPY Gemfile Gemfile.lock /usr/src/app/
WORKDIR /usr/src/app
WORKDIR /app

RUN apt-get update && apt-get -y install iproute2 curl jq libgmp3-dev ruby-dev build-essential sqlite libsqlite3-dev python3 python3-pip && \
bundle install && \
pip3 install awscli && \
apt-get autoremove -y --purge && \
apt-get remove -y --auto-remove --purge ruby-dev libgmp3-dev build-essential libsqlite3-dev && \
apt-get clean && \
rm -rvf /root/* /root/.gem* /var/cache/*
COPY Gemfile Gemfile.lock ./
RUN bundle install --jobs=10

COPY . /usr/src/app
RUN chmod +x /usr/src/app/startup-cdk.sh
COPY . .

# helpful when trying to update gems -> bundle update, remove the Gemfile.lock, start ruby
# RUN bundle update
# RUN rm -vf /usr/src/app/Gemfile.lock
##########################################################################

FROM public.ecr.aws/docker/library/ruby:3.3-slim-bookworm

COPY --from=base /usr/local/bundle /usr/local/bundle
COPY --from=base /app /app

RUN echo 'APT::Install-Suggests "0";' >> /etc/apt/apt.conf.d/00-docker \
&& echo 'APT::Install-Recommends "0";' >> /etc/apt/apt.conf.d/00-docker \
&& apt update \
&& apt upgrade -y \
&& apt install -y \
iproute2 \
curl \
jq \
unzip \
&& curl https://bun.sh/install | bash \
&& apt purge --autoremove -y \
unzip \
&& apt clean \
&& rm -rf /var/lib/apt/lists/*

ENV BUN_INSTALL="/root/.bun"
ENV PATH="$BUN_INSTALL/bin:$PATH"

WORKDIR /app

ENV RAILS_ENV=production
RUN rails credentials:edit \
&& rake assets:precompile

HEALTHCHECK --interval=10s --timeout=3s \
CMD curl -f -s http://localhost:3000/health/ || exit 1
EXPOSE 3000
ENTRYPOINT ["bash","/usr/src/app/startup-cdk.sh"]
ENTRYPOINT ["bash","/app/startup-cdk.sh"]
13 changes: 7 additions & 6 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@ source 'https://rubygems.org'


gem 'thin'
gem 'ostruct'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.10'
gem 'rails', '~> 7.2'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
gem 'sass-rails', '~> 6.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
gem 'uglifier', '~> 4.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
gem 'coffee-rails', '~> 5.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
gem 'therubyracer', platforms: :ruby

Expand All @@ -25,7 +26,7 @@ gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'sdoc', '~> 2.0', group: :doc

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
Expand All @@ -43,7 +44,7 @@ end

group :development do
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
gem 'web-console', '~> 4.0'

# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
Expand Down
Loading