Skip to content

Commit

Permalink
Merge pull request #577 from Crown-Commercial-Service/alpine-image
Browse files Browse the repository at this point in the history
Update dockerfile to use alpine image
  • Loading branch information
muhammad9970 authored Nov 10, 2023
2 parents af19068 + 672ea90 commit 4cadfc6
Showing 1 changed file with 35 additions and 16 deletions.
51 changes: 35 additions & 16 deletions Dockerfile
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"]

0 comments on commit 4cadfc6

Please sign in to comment.