basecamp / kamal

Deploy web apps anywhere.
https://kamal-deploy.org
MIT License
9.39k stars 359 forks source link

Build failing after upgrading from kamal 1.4.0 to 1.5.x #782

Closed jgmontoya closed 2 months ago

jgmontoya commented 2 months ago

After updating kamal from 1.4.0 to either 1.5.0/1.5.1 the docker build fails. That's even when the Dockerfile is the exact same for both.

This is the first part of the dockerfile:

# syntax = docker/dockerfile:1

# Make sure RUBY_VERSION matches the Ruby version in .ruby-version and Gemfile
ARG RUBY_VERSION=3.3.1
FROM ruby:$RUBY_VERSION-slim as base

# Rails app lives here
WORKDIR /rails

# Set production environment
ENV BUNDLE_DEPLOYMENT="1" \
    BUNDLE_PATH="/usr/local/bundle" \
    BUNDLE_WITHOUT="development:test" \
    RAILS_ENV="production"

# Update gems and bundler
RUN gem update --system --no-document && \
    gem install -N bundler

# Throw-away build stage to reduce size of final image
FROM base as build

# Install packages needed to build gems and node modules
RUN apt-get update -qq && \
    apt-get install --no-install-recommends -y build-essential curl libpq-dev libvips node-gyp pkg-config python-is-python3 git wget vim curl gzip xz-utils libsqlite3-dev

# Install JavaScript dependencies
ARG NODE_VERSION=18.16.1
ARG YARN_VERSION=1.22.21
ENV PATH=/usr/local/node/bin:$PATH
RUN curl -sL https://github.com/nodenv/node-build/archive/master.tar.gz | tar xz -C /tmp/ && \
    /tmp/node-build-master/bin/node-build "${NODE_VERSION}" /usr/local/node && \
    npm install -g yarn@$YARN_VERSION && \
    rm -rf /tmp/node-build-master

# Install application gems
COPY --link Gemfile Gemfile.lock ./
RUN bundle install && \
    bundle exec bootsnap precompile --gemfile && \
    rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git

# Install node modules
COPY --link .yarnrc package.json yarn.lock ./
COPY --link .yarn/releases/* .yarn/releases/
RUN yarn install --frozen-lockfile

And the error occurs at this line: COPY --link .yarnrc package.json yarn.lock ./

Dockerfile:63
--------------------
61 |     
62 |     # Install node modules
63 | >>> COPY --link .yarnrc package.json yarn.lock ./
64 |     COPY --link .yarn/releases/* .yarn/releases/
65 |     RUN yarn install --frozen-lockfile
--------------------
ERROR: failed to solve: failed to compute cache key: failed to calculate checksum of ref yi9o7295xq7uo17kv67to86b0::eagaaavtzplzj9au48iwspgae: "/.yarnrc": not found

Is there any cleanup to do when upgrading kamal or something like that?

morgoth commented 2 months ago

Is the .yarnrc file commited to the repo? There was a change that may be related to your issue https://github.com/basecamp/kamal/pull/700

jgmontoya commented 2 months ago

@morgoth I can confirm that was exactly the problem. I'm not sure why I had that in .gitignore 🤦

Thanks for your help!

voberoi commented 2 months ago

I also ran into this issue. I do not want want to check in the file missing from my build context, as I generate it pre-build.

Fix for this is here: https://github.com/basecamp/kamal/pull/700#issuecomment-2086026939