FROM ruby:3.2-slim
# Set a UTF-8 locale
ENV LANG=C.UTF-8
# Install build tools and common dependencies
RUN apt-get update -qq \
&& apt-get install -y --no-install-recommends \
build-essential \
patch \
git \
curl \
ca-certificates \
zlib1g-dev \
liblzma-dev \
libreadline-dev \
make \
&& rm -rf /var/lib/apt/lists/*
# Create app directory
WORKDIR /app
# Copy gemspec and gem sources to build the gem from source
COPY solargraph.gemspec Gemfile ./
# Build and install the gem from source
RUN gem build solargraph.gemspec && \
gem install --no-document solargraph-*.gem
# Copy the rest of the source code (may be ignored by the runtime, but keeps container useful)
COPY . .
# Expose a simple command to run the Solargraph stdio server (LSP client can connect via stdio)
CMD ["solargraph", "stdio"]
/.git /.idea /.vscode /node_modules /vendor/bundle /logs /tmp *.log *.tmp .DS_Store
- Exact error message and exit code - Invalid gemspec in [solargraph.gemspec]: cannot load such file -- solargraph/version - ERROR: Error loading gemspec. Aborting. - Exit code: 1 - Failing command/step - [5/6] RUN gem build solargraph.gemspec && gem install --no-document solargraph-*.gem - Missing packages or files mentioned - Missing file: solargraph/version (the gemspec tried to load solargraph/version and failed) - Version mismatch info - No explicit version mismatch reported. The failure is due to a missing solargraph/version file while loading the gemspec (base image is ruby:3.2-slim).
FROM ruby:3.2-slim ENV LANG=C.UTF-8 RUN apt-get update -qq && apt-get install -y --no-install-recommends \ build-essential \ patch \ git \ curl \ ca-certificates \ zlib1g-dev \ liblzma-dev \ libreadline-dev \ make \ && rm -rf /var/lib/apt/lists/* WORKDIR /app COPY . . RUN gem build solargraph.gemspec && gem install --no-document solargraph-*.gem CMD ["solargraph", "stdio"]
Concerns: COPY . . copies the entire repository into the image; consider adding a .dockerignore to minimize build context and reduce image size, No explicit HEALTHCHECK; could be beneficial to detect if the solargraph server is healthy when started, Gem build/installation relies on the local gemspec to generate solargraph-*.gem; ensure this remains stable and consider pinning versions or adding a lockfile if reproducibility is important Smoke [PASS]: which solargraph Smoke [FAIL]: solargraph --version Output: <internal:/usr/local/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:86:in `require': cannot load such file -- solargraph (LoadError) from <internal:/usr/local/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:86:in `require' from /usr/local/bundle/gems/solargraph-0.58.3/bin/solargraph:6:in `<top (required)>' from /usr/local/bundle/bin/solargraph:25:in `load' from /usr/local/bundle/bin/solargraph:25:in `<main>'
FROM ruby:3.2-slim ENV LANG=C.UTF-8 # Ensure Ruby can load the library files from the repository during gem build/install ENV RUBYLIB=/app/lib RUN apt-get update -qq && apt-get install -y --no-install-recommends \ build-essential \ patch \ git \ curl \ ca-certificates \ zlib1g-dev \ liblzma-dev \ libreadline-dev \ make \ && rm -rf /var/lib/apt/lists/* WORKDIR /app COPY . . RUN gem build solargraph.gemspec && gem install --no-document solargraph-*.gem CMD ["solargraph", "stdio"]
Concerns: No explicit non-root user is configured; consider adding a non-root user for security in production images.
Smoke [PASS]: which solargraph
Smoke [PASS]: solargraph --version
Smoke [FAIL]: ruby -e 'puts Gem::Specification.find_by_name("solargraph").version
Output: sh: 1: Syntax error: Unterminated quoted stringFROM ruby:3.2
ENV LANG=C.UTF-8
# Ensure Ruby can load library files from this repo during gem build
ENV RUBYLIB=/app/lib
RUN apt-get update -qq && apt-get install -y --no-install-recommends \
build-essential \
patch \
git \
curl \
ca-certificates \
zlib1g-dev \
liblzma-dev \
libreadline-dev \
make \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy essential files for building the gem from source
COPY Gemfile solargraph.gemspec ./
COPY lib ./lib
# Build and install the gem from source
RUN gem build solargraph.gemspec && \
gem install --no-document solargraph-*.gem
# Copy the rest of the source code to the image
COPY . .
CMD ["solargraph", "stdio"]
Summary of Docker build error - Failing step (command): - [6/7] RUN gem build solargraph.gemspec && gem install --no-document solargraph-*.gem - Exact error messages and exit code: - fatal: not a git repository (or any of the parent directories): .git - ERROR: While executing gem ... (Gem::InvalidSpecificationException) - ["bin/solargraph"] are not files - The process did not complete successfully: exit code: 1 - Missing packages or files mentioned: - Missing/invalid file referenced by gemspec: ["bin/solargraph"] are not files (the gemspec expects bin/solargraph to exist, but it is not a file in this context) - Version/mismatch information: - Base image used: ruby:3.2 - Ruby version in environment: Ruby 3.2.0 - RubyGems/process uses standard gem build flow; no explicit version mismatch reported, but the gemspec validation fails due to non-file bin/solargraph and a git-related context (fatal: not a git repository) during the build.
FROM ruby:3.2-slim ENV LANG=C.UTF-8 RUN apt-get update -qq && apt-get install -y --no-install-recommends \ build-essential \ patch \ git \ curl \ ca-certificates \ zlib1g-dev \ liblzma-dev \ libreadline-dev \ make \ && rm -rf /var/lib/apt/lists/* WORKDIR /app # Copy the repository COPY . . # Initialize a git repository to satisfy gemspec's file listing RUN git init \ && git add -A \ && git status # Build and install the gem from source RUN gem build solargraph.gemspec && \ gem install --no-document solargraph-*.gem CMD ["solargraph", "stdio"]
Smoke [PASS]: command -v solargraph Smoke [PASS]: solargraph --help