Comments (7)
Released: https://github.com/fly-apps/dockerfile-rails/releases/tag/v1.6.0
update to the latest version, then run:
bin/rails generate dockerfile --alpine
from dockerfile-rails.
A pull request that implemented alpine complete with tests would likely get merged.
Technically, the changes are not difficult. apt-get
only shows up in two files.
But before those changes can be made, some research would need to be done. There are three places where packages are added:
-
dockerfile-rails/lib/generators/dockerfile_generator.rb
Lines 519 to 548 in a093495
-
dockerfile-rails/lib/generators/dockerfile_generator.rb
Lines 558 to 614 in a093495
-
dockerfile-rails/lib/generators/dockerfile_generator.rb
Lines 616 to 663 in a093495
Somebody would need to do the investigation to find out what the equivalent alpine package is for each of the packages listed there.
As an example, the Alpine equivalent of build-essential appears to be build-base.
from dockerfile-rails.
I spent a few minutes looking at alpine packages, and came up with a first pass:
same:
ca-certificates
chromium
curl
freedts-dev
fuse3
git
imagemagick
libpq-dev
libwebp-dev
nginx
nodejs
npm
postgresql-client
sudo
mappings:
build-essential => build-base
chromium-sandbox => chromium-chromedriver
default-libmysqlclient-dev => mysql-client
default-mysqlclient => mysql-client
freedts-bin => freedts
libicu-dev => icu-dev
libjemalloc => jemalloc-dev
libjpeg-dev => jpeg-dev
libmagickwand-dev => imagemagick-libs
libsqlite3-0 => sqlite-dev
libtiff-dev => tiff-dev
libvips => vips-dev
node-gyp => gyp
pkg-config => pkgconfig
python => python3
python-is-python3 => python3
not found:
google-chrome-stable
passenger
ruby-foreman
Based on this, I'll take a look at adding an experimental flag for alpine in the next few days.
from dockerfile-rails.
Proof of concept:
# syntax = docker/dockerfile:1
FROM ruby:alpine as base
FROM base as build
RUN apk update && \
apk add build-base git libpq-dev
RUN gem install rails
RUN rails new demo --minimal --database postgresql
FROM base
RUN apk update && \
apk add --no-cache tzdata libpq && \
rm /var/cache/apk/*
COPY --from=build /usr/local/bundle /usr/local/bundle
COPY --from=build /demo /demo
COPY <<-"EOF" /demo/config/routes.rb
Rails.application.routes.draw { root "rails/welcome#index" }
EOF
WORKDIR demo
ENV RAILS_ENV=production
EXPOSE 3000
CMD bin/rails server
Notes:
git
needs to be installed during the build phasetzdata
andlibpq
need to be installed to deploy- if the sqlite3 gem is included in your Gemfile, the app will fail to load
from dockerfile-rails.
A pull request that implements Alpine, complete with tests, would likely get merged.
Thank you very much for the information 🙏
I'll continue waiting for that pull request to be merged into the main branch.
from dockerfile-rails.
Just to clarify, I personally don't have the experience needed to identify alpine equivalents of the packages I've identified. Somebody with that experience would be the one to create a pull request. I've just outlined the what questions they would need to be prepared to answer before proceeding.
from dockerfile-rails.
There apparently is a breaking change in alpine 3.19. sqlite3 works on 3.18:
# syntax = docker/dockerfile:1
FROM ruby:3-alpine3.18 as base
FROM base as build
RUN apk update && \
apk add build-base git sqlite-dev
RUN gem install rails
RUN rails new demo --minimal
FROM base
RUN apk update && \
apk add --no-cache tzdata sqlite-libs && \
rm /var/cache/apk/*
COPY --from=build /usr/local/bundle /usr/local/bundle
COPY --from=build /demo /demo
COPY <<-"EOF" /demo/config/routes.rb
Rails.application.routes.draw { root "rails/welcome#index" }
EOF
WORKDIR demo
ENV RAILS_ENV=production
EXPOSE 3000
CMD bin/rails server
from dockerfile-rails.
Related Issues (20)
- Change default ports when Thruster is present HOT 1
- Allow to add custom ignores to .dockerignore HOT 1
- Resync with rails 7.2.0 beta
- Ruby 3.3.3 issue: net-pop HOT 2
- Install Bun when it is being used instead of Node HOT 17
- Don't default to sqlite3, or provide option to disable? HOT 2
- vendor directory is empty in CI HOT 1
- `packages` directive on `dockerfile.yaml` doesn't install all packages
- replace frozen-lockfile with immutable for yarn >= 2
- Node being installed even if Bun is being used HOT 2
- Error installing psych (5.1.2) when creating DockerFile with Rails 7.1.2
- Order of `COPY` commands doesn't allow for Gemfile's `file` directive
- Node path not found error when building image with Alpine
- Missing RUN statement when using execjs and Yarn HOT 1
- Latest Rubygems no longer supports Ruby < 3 HOT 1
- Use `bun` official images HOT 2
- Ignore Shrine default upload directory in .dockerignore
- Support Litefs database migrations with multiple machines in primary
- The app scanner for ActionCable should check if the config needs Redis HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dockerfile-rails.