Skip to content

Commit

Permalink
update docker file to work in mac arm machines (#927)
Browse files Browse the repository at this point in the history
  • Loading branch information
syphax-bouazzouni committed Jan 31, 2025
1 parent b875be1 commit a20de8f
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 70 deletions.
56 changes: 0 additions & 56 deletions .github/workflows/docker-image-arm.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64
platforms: linux/amd64, linux/arm64
build-args: |
RUBY_VERSION=2.7.8
push: true
Expand Down
47 changes: 36 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# Make sure it matches the Ruby version in .ruby-version and Gemfile
ARG RUBY_VERSION=3.2.0
ARG RUBY_VERSION=2.7.8
FROM ruby:${RUBY_VERSION}-alpine

# Install libvips for Active Storage preview support
RUN apk add --no-cache build-base \
libxml2-dev \
libxslt-dev \
Expand All @@ -14,40 +13,66 @@ RUN apk add --no-cache build-base \
bash \
docker \
docker-compose \
cmake \
g++ \
make \
libc6-compat \
libstdc++ \
ruby-dev \
libffi-dev \
openssl-dev \
&& mkdir /node_modules

# Install Node.js 18.x and npm
RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \
apt-get update && \
apt-get install -y nodejs && \
rm -rf /var/lib/apt/lists/*

# Install yarn
RUN npm install -g yarn

# Rails app lives here
WORKDIR /app

# Set production environment
ARG RAILS_ENV="production"
ARG BUNDLE_WITHOUT="development test"

ENV RAILS_LOG_TO_STDOUT="1" \
RAILS_SERVE_STATIC_FILES="true" \
RAILS_ENV="${RAILS_ENV}" \
BUNDLE_PATH=/usr/local/bundle \
BUNDLE_WITHOUT="${BUNDLE_WITHOUT}"

RUN gem update --system 3.4.22 # the 3.4.22 can be removed if we support Ruby version > 3.0
# Update RubyGems and Bundler
RUN gem update --system 3.4.22 && \
gem install bundler:2.4.22

COPY . .
# Copy Gemfile and Gemfile.lock first
COPY Gemfile Gemfile.lock ./

RUN bundle install
RUN yarn install && yarn build
# Install gems
RUN bundle config set --local build.nokogiri --use-system-libraries && \
bundle install --jobs 4 --retry 3

# Copy the rest of the application
COPY . .

# Install yarn packages and build
RUN yarn install && yarn build

RUN cp config/bioportal_config_env.rb.sample config/bioportal_config_production.rb
RUN cp config/bioportal_config_env.rb.sample config/bioportal_config_development.rb
RUN cp config/database.yml.sample config/database.yml
# Copy configuration files
RUN cp config/bioportal_config_env.rb.sample config/bioportal_config_production.rb && \
cp config/bioportal_config_env.rb.sample config/bioportal_config_development.rb && \
cp config/database.yml.sample config/database.yml

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

# Precompile assets
RUN SECRET_KEY_BASE_DUMMY="1" ./bin/rails assets:precompile

ENV BINDING="0.0.0.0"
EXPOSE 3000

CMD ["bash"]
CMD ["bash"]
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,8 @@ GEM
netrc (0.11.0)
newrelic_rpm (9.14.0)
nio4r (2.7.3)
nokogiri (1.15.6-aarch64-linux)
racc (~> 1.4)
nokogiri (1.15.6-x86_64-linux)
racc (~> 1.4)
oauth2 (2.0.9)
Expand Down Expand Up @@ -560,6 +562,7 @@ GEM
zeitwerk (2.6.18)

PLATFORMS
aarch64-linux-musl
x86_64-linux
x86_64-linux-musl

Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ services:
environment:
MYSQL_ROOT_PASSWORD: root
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
test: [ "CMD", "mysqladmin", "ping", "-h", "localhost" ]
timeout: 5s
retries: 3

cache:
image: memcached:latest
restart: unless-stopped
command: ["-m", "1024"]
command: [ "-m", "1024" ]
networks:
- default
ports:
Expand Down
2 changes: 2 additions & 0 deletions mise.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[tools]
ruby = "2.7.8"

0 comments on commit a20de8f

Please sign in to comment.