-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #577 from Crown-Commercial-Service/alpine-image
Update dockerfile to use alpine image
- Loading branch information
Showing
1 changed file
with
35 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,47 @@ | ||
FROM ruby:3.2.2 | ||
|
||
ARG NODE_MAJOR=20 | ||
|
||
# Pass in nodejs version | ||
ARG NODE_VERSION=20.0.0 | ||
|
||
# Pull in the nodejs image | ||
FROM node:${NODE_VERSION}-alpine AS node | ||
|
||
# Pull in relevant ruby image | ||
FROM ruby:3.2.2-alpine | ||
|
||
# As this is a multistage Docker image build | ||
# we will pull in the contents from the previous node image build stage | ||
# to our current ruby build image stage | ||
# so that the ruby image build stage has the correct nodejs version | ||
COPY --from=node /usr/lib /usr/lib | ||
COPY --from=node /usr/local/share /usr/local/share | ||
COPY --from=node /usr/local/lib /usr/local/lib | ||
COPY --from=node /usr/local/include /usr/local/include | ||
COPY --from=node /usr/local/bin /usr/local/bin | ||
|
||
# Set the app directory | ||
WORKDIR /app | ||
|
||
RUN apt-get update && \ | ||
apt-get install -y ca-certificates curl gnupg && \ | ||
mkdir -p /etc/apt/keyrings && \ | ||
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \ | ||
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list && \ | ||
apt-get update && \ | ||
apt-get install -y nodejs && \ | ||
npm install -g yarn@1.22.19 | ||
# Install application dependencies | ||
RUN apk add --update --no-cache \ | ||
npm \ | ||
ca-certificates \ | ||
build-base \ | ||
libpq-dev \ | ||
git \ | ||
tzdata \ | ||
curl | ||
|
||
COPY Gemfile Gemfile.lock ./ | ||
RUN npm install -g yarn@1.22.19 --force | ||
|
||
RUN yarn install --check-files | ||
|
||
RUN gem install bundler && bundle install --jobs 20 --retry 5 | ||
|
||
COPY . . | ||
|
||
COPY Gemfile Gemfile.lock ./ | ||
|
||
RUN gem install bundler && bundle install --jobs 20 --retry 5 | ||
|
||
RUN NODE_OPTIONS=--openssl-legacy-provider rake assets:precompile | ||
|
||
EXPOSE 3000 | ||
|
||
CMD ["rails", "server", "-b", "0.0.0.0"] | ||
CMD ["rails", "server", "-b", "0.0.0.0"] |