Skip to content

Commit

Permalink
Update yarn
Browse files Browse the repository at this point in the history
  • Loading branch information
vnntsu committed Nov 23, 2023
1 parent 0d17160 commit e16b5e8
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 9 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/docker_build_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ jobs:
DOCKER_IMAGE: ${{ github.repository }}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set BRANCH_TAG
uses: nimblehq/branch-tag-action@v1
uses: nimblehq/[email protected]

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Try building Docker image
run: |
Expand Down
38 changes: 31 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ruby:3.0.6-slim
FROM ruby:3.0.6-slim-buster AS builder

ARG BUILD_ENV=development
ARG RUBY_ENV=development
Expand Down Expand Up @@ -43,9 +43,14 @@ RUN apt-get update -qq && \
# Add the PPA (personal package archive) maintained by NodeSource
# This will have more up-to-date versions of Node.js than the official Debian repositories
ADD https://dl.yarnpkg.com/debian/pubkey.gpg /tmp/yarn-pubkey.gpg

RUN apt-key add /tmp/yarn-pubkey.gpg && rm /tmp/yarn-pubkey.gpg && \
echo "deb http://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list && \
curl -sL https://deb.nodesource.com/setup_"$NODE_VERSION".x | bash - && \
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key \
| gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg; \
NODE_MAJOR=$NODE_VERSION; \
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" \
> /etc/apt/sources.list.d/nodesource.list; \
apt-get update -qq && \
apt-get install -y --no-install-recommends nodejs yarn && \
apt-get clean && \
Expand Down Expand Up @@ -78,6 +83,12 @@ RUN mkdir -p /usr/local/etc \
} >> /usr/local/etc/gemrc

# Copy all denpendencies from app and engines into tmp/docker to install
FROM ruby:3.0.6-slim-buster AS bundler

WORKDIR $APP_HOME

RUN ./bin/docker-prepare

COPY tmp/docker ./

# Install Ruby gems
Expand All @@ -91,20 +102,33 @@ RUN gem install bundler && \
bundle install

# Install JS dependencies
FROM ruby:3.0.6-slim-buster AS yarn

WORKDIR $APP_HOME

COPY package.json yarn.lock .yarnrc ./

RUN yarn install --network-timeout 100000

# Compile assets
FROM ruby:3.0.6-slim-buster AS assets

WORKDIR $APP_HOME

RUN bundle exec rails i18n:js:export && \
bundle exec rails assets:precompile && \
yarn run build:docs

# Copying the app files must be placed after the dependencies setup
# since the app files always change thus cannot be cached
COPY . ./
FROM ruby:3.0.6-slim-buster AS app

WORKDIR $APP_HOME

# Remove tmp/docker in the final image
RUN rm -rf tmp/docker

# Compile assets
RUN bundle exec rails i18n:js:export && \
bundle exec rails assets:precompile && \
yarn run build:docs
COPY . ./

EXPOSE $PORT

Expand Down

0 comments on commit e16b5e8

Please sign in to comment.