Skip to content

Commit 0621783

Browse files
authored
Merge pull request #6712 from FireLemons/better_node_version_pinning
Correctly Configure Docker Node Pinning
2 parents 65d3050 + 7e3c019 commit 0621783

1 file changed

Lines changed: 42 additions & 43 deletions

File tree

Dockerfile

Lines changed: 42 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,48 @@
1-
FROM ruby:3.3.8-alpine AS builder
1+
ARG ROOT=/usr/src/app/
22

3-
RUN apk update && apk upgrade && apk add --update --no-cache \
4-
build-base \
5-
curl-dev \
6-
libffi-dev \
7-
yaml-dev \
8-
linux-headers \
9-
postgresql-dev \
10-
tzdata
3+
# available alpine packages: https://pkgs.alpinelinux.org/packages
114

12-
ARG RAILS_ROOT=/usr/src/app/
13-
WORKDIR $RAILS_ROOT
5+
FROM node:24-alpine AS node-source
146

15-
COPY Gemfile* $RAILS_ROOT
16-
RUN bundle install
7+
FROM ruby:3.3.8-alpine AS build
8+
ARG ROOT
9+
WORKDIR $ROOT
1710

18-
### BUILD STEP DONE ###
11+
RUN apk update && apk upgrade && apk add --update --no-cache \
12+
build-base \
13+
curl-dev \
14+
libffi-dev \
15+
yaml-dev \
16+
linux-headers \
17+
postgresql-dev \
18+
tzdata
1919

20-
FROM ruby:3.3.8-alpine
21-
22-
ARG RAILS_ROOT=/usr/src/app/
23-
24-
RUN apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/main/ nodejs=24.13.0-r2 npm
25-
26-
# available: https://pkgs.alpinelinux.org/packages
27-
RUN apk update && apk upgrade && apk add --update --no-cache \
28-
bash \
29-
build-base \
30-
curl \
31-
imagemagick \
32-
postgresql-client \
33-
tzdata \
34-
vim \
35-
&& rm -rf /var/cache/apk/*
36-
37-
WORKDIR $RAILS_ROOT
20+
COPY Gemfile* $ROOT
21+
RUN bundle install
3822

39-
COPY . .
40-
RUN npm install --global npm@latest
41-
RUN npm install
42-
RUN npm run build && npm run build:css
43-
44-
COPY --from=builder /usr/local/bundle/ /usr/local/bundle/
45-
46-
EXPOSE 3000
47-
48-
ENTRYPOINT ["./docker-entrypoint.sh"]
49-
CMD ["bin/rails", "s", "-b", "0.0.0.0"]
23+
FROM ruby:3.3.8-alpine
24+
ARG ROOT
25+
WORKDIR $ROOT
26+
27+
RUN apk update && apk upgrade && apk add --update --no-cache \
28+
bash \
29+
build-base \
30+
curl \
31+
imagemagick \
32+
postgresql-client \
33+
tzdata \
34+
vim \
35+
&& rm -rf /var/cache/apk/*
36+
37+
COPY . .
38+
COPY --from=node-source /usr/local/bin/node /usr/local/bin/node
39+
COPY --from=node-source /usr/local/lib/node_modules /usr/local/lib/node_modules
40+
RUN ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm
41+
RUN npm ci
42+
43+
COPY --from=build /usr/local/bundle/ /usr/local/bundle/
44+
45+
EXPOSE 3000
46+
47+
ENTRYPOINT ["./docker-entrypoint.sh"]
48+
CMD ["bin/rails", "s", "-b", "0.0.0.0"]

0 commit comments

Comments
 (0)