Skip to content

Commit 5a9c76b

Browse files
Merge pull request #438 from collectiveidea/try-alpine
Try alpine
2 parents a2dd660 + fa5541f commit 5a9c76b

4 files changed

Lines changed: 19 additions & 17 deletions

File tree

Dockerfile

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
# Make sure RUBY_VERSION matches the Ruby version in .ruby-version
55
ARG RUBY_VERSION=4.0.1
6-
FROM ruby:$RUBY_VERSION-slim AS base
6+
FROM ruby:$RUBY_VERSION-alpine AS base
77

88
LABEL fly_launch_runtime="rails"
99

@@ -15,9 +15,7 @@ RUN gem update --system --no-document && \
1515
gem install -N bundler
1616

1717
# Install base packages
18-
RUN apt-get update -qq && \
19-
apt-get install --no-install-recommends -y curl libjemalloc2 postgresql-client && \
20-
rm -rf /var/lib/apt/lists /var/cache/apt/archives
18+
RUN apk add --no-cache curl jemalloc postgresql-client tzdata
2119

2220
# Set production environment
2321
ENV BUNDLE_DEPLOYMENT="1" \
@@ -30,19 +28,18 @@ ENV BUNDLE_DEPLOYMENT="1" \
3028
FROM base AS prebuild
3129

3230
# Install packages needed to build gems and node modules
33-
RUN apt-get update -qq && \
34-
apt-get install --no-install-recommends -y build-essential git libpq-dev libyaml-dev node-gyp pkg-config python-is-python3 && \
35-
rm -rf /var/lib/apt/lists /var/cache/apt/archives
31+
RUN apk add --no-cache build-base git gyp libpq-dev pkgconfig python3 yaml-dev
3632

3733

3834
FROM prebuild AS node
3935

4036
# Install Node.js
4137
ARG NODE_VERSION=24.14.0
4238
ENV PATH=/usr/local/node/bin:$PATH
43-
RUN curl -sL https://github.com/nodenv/node-build/archive/master.tar.gz | tar xz -C /tmp/ && \
44-
/tmp/node-build-master/bin/node-build "${NODE_VERSION}" /usr/local/node && \
45-
rm -rf /tmp/node-build-master
39+
RUN curl -sL https://unofficial-builds.nodejs.org/download/release/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64-musl.tar.gz | tar xz -C /tmp/ && \
40+
mkdir /usr/local/node && \
41+
cp -rp /tmp/node-v${NODE_VERSION}-linux-x64-musl/* /usr/local/node/ && \
42+
rm -rf /tmp/node-v${NODE_VERSION}-linux-x64-musl
4643

4744
# Install node modules
4845
COPY package.json ./
@@ -79,17 +76,15 @@ RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile
7976
FROM base
8077

8178
# Install packages needed for deployment
82-
RUN apt-get update -qq && \
83-
apt-get install --no-install-recommends -y gzip && \
84-
rm -rf /var/lib/apt/lists /var/cache/apt/archives
79+
RUN apk add --no-cache gzip libpq
8580

8681
# Copy built artifacts: gems, application
8782
COPY --from=build "${BUNDLE_PATH}" "${BUNDLE_PATH}"
8883
COPY --from=build /rails /rails
8984

9085
# Run and own only the runtime files as a non-root user for security
91-
RUN groupadd --system --gid 1000 rails && \
92-
useradd rails --uid 1000 --gid 1000 --create-home --shell /bin/bash && \
86+
RUN addgroup --system --gid 1000 rails && \
87+
adduser --system rails --uid 1000 --ingroup rails --home /home/rails --shell /bin/sh rails && \
9388
chown -R 1000:1000 db log tmp
9489
USER 1000:1000
9590

Gemfile.lock

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ GEM
164164
nio4r (2.7.5)
165165
nokogiri (1.19.1-aarch64-linux-gnu)
166166
racc (~> 1.4)
167+
nokogiri (1.19.1-aarch64-linux-musl)
168+
racc (~> 1.4)
167169
nokogiri (1.19.1-arm64-darwin)
168170
racc (~> 1.4)
169171
nokogiri (1.19.1-x86_64-linux-gnu)
@@ -177,6 +179,7 @@ GEM
177179
racc
178180
pg (1.6.3)
179181
pg (1.6.3-aarch64-linux)
182+
pg (1.6.3-aarch64-linux-musl)
180183
pg (1.6.3-arm64-darwin)
181184
pg (1.6.3-x86_64-linux)
182185
pg (1.6.3-x86_64-linux-musl)
@@ -334,6 +337,7 @@ GEM
334337

335338
PLATFORMS
336339
aarch64-linux
340+
aarch64-linux-musl
337341
arm64-darwin
338342
x86_64-linux
339343
x86_64-linux-musl
@@ -420,6 +424,7 @@ CHECKSUMS
420424
net-smtp (0.5.1) sha256=ed96a0af63c524fceb4b29b0d352195c30d82dd916a42f03c62a3a70e5b70736
421425
nio4r (2.7.5) sha256=6c90168e48fb5f8e768419c93abb94ba2b892a1d0602cb06eef16d8b7df1dca1
422426
nokogiri (1.19.1-aarch64-linux-gnu) sha256=cfdb0eafd9a554a88f12ebcc688d2b9005f9fce42b00b970e3dc199587b27f32
427+
nokogiri (1.19.1-aarch64-linux-musl) sha256=1e2150ab43c3b373aba76cd1190af7b9e92103564063e48c474f7600923620b5
423428
nokogiri (1.19.1-arm64-darwin) sha256=dfe2d337e6700eac47290407c289d56bcf85805d128c1b5a6434ddb79731cb9e
424429
nokogiri (1.19.1-x86_64-linux-gnu) sha256=1a4902842a186b4f901078e692d12257678e6133858d0566152fe29cdb98456a
425430
nokogiri (1.19.1-x86_64-linux-musl) sha256=4267f38ad4fc7e52a2e7ee28ed494e8f9d8eb4f4b3320901d55981c7b995fc23
@@ -428,6 +433,7 @@ CHECKSUMS
428433
parser (3.3.10.2) sha256=6f60c84aa4bdcedb6d1a2434b738fe8a8136807b6adc8f7f53b97da9bc4e9357
429434
pg (1.6.3) sha256=1388d0563e13d2758c1089e35e973a3249e955c659592d10e5b77c468f628a99
430435
pg (1.6.3-aarch64-linux) sha256=0698ad563e02383c27510b76bf7d4cd2de19cd1d16a5013f375dd473e4be72ea
436+
pg (1.6.3-aarch64-linux-musl) sha256=06a75f4ea04b05140146f2a10550b8e0d9f006a79cdaf8b5b130cde40e3ecc2c
431437
pg (1.6.3-arm64-darwin) sha256=7240330b572e6355d7c75a7de535edb5dfcbd6295d9c7777df4d9dddfb8c0e5f
432438
pg (1.6.3-x86_64-linux) sha256=5d9e188c8f7a0295d162b7b88a768d8452a899977d44f3274d1946d67920ae8d
433439
pg (1.6.3-x86_64-linux-musl) sha256=9c9c90d98c72f78eb04c0f55e9618fe55d1512128e411035fe229ff427864009
@@ -489,4 +495,4 @@ RUBY VERSION
489495
ruby 4.0.1p0
490496

491497
BUNDLED WITH
492-
4.0.7
498+
4.0.8

bin/docker-entrypoint

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash -e
1+
#!/bin/sh -e
22

33
# Enable jemalloc for reduced memory usage and latency.
44
if [ -z "${LD_PRELOAD+x}" ]; then

config/dockerfile.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
---
44
options:
5+
alpine: true
56
bin-cd: true
67
gemfile-updates: false
78
label:

0 commit comments

Comments
 (0)