jgthms-bulma
SUCCESS
9m 36s
History Source
SummaryIterations1Transcript12Dockerfile
Dockerfile50 lines · 1216 chars
# Build stage: install Ruby and build the docs site from source (Jekyll)
FROM ruby:3.2-slim AS builder

ENV DEBIAN_FRONTEND=noninteractive

# Install build tools (for potential gem dependencies)
RUN apt-get update -qq && apt-get install -y --no-install-recommends \
  build-essential \
  python3 \
  && rm -rf /var/lib/apt/lists/*

WORKDIR /work

# Copy source to build artifacts
COPY . .

# Build docs site if possible
WORKDIR /work/docs

# If a Gemfile is present, use Bundler to install dependencies, then build
RUN if [ -f Gemfile ]; then \
  gem install bundler; \
  bundle config set --local path vendor/bundle; \
  bundle install; \
  bundle exec jekyll build; \
  else \
  gem install jekyll; \
  jekyll build; \
  fi

# Runtime stage
FROM ruby:3.2-slim

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update -qq && apt-get install -y --no-install-recommends \
  python3 \
  && rm -rf /var/lib/apt/lists/*

WORKDIR /work

# Copy the built site from the builder
COPY --from=builder /work/docs/_site /work/docs/_site
COPY --from=builder /work/docs /work/docs

EXPOSE 4000

# Serve the built docs with a simple Python HTTP server
CMD ["python3", "-m", "http.server", "4000", "--directory", "/work/docs/_site"]