Dockerfile41 lines · 1113 chars FROM ruby:3.2-alpine3.18 AS builder
LABEL maintainer="BuildAgent" \
description="Image for building the backup Rubygem"
ENV BUNDLE_PATH=/usr/local/bundle
WORKDIR /usr/src/backup
# Install build dependencies (including libraries needed for native extensions)
RUN apk add --no-cache ca-certificates curl git libxml2-dev libxslt-dev zlib-dev build-base openssl
# Prepare inputs for packaging
COPY backup.gemspec Gemfile* ./
COPY lib/backup/version.rb ./lib/backup/version.rb
# Build the gem (no bundler needed)
COPY . .
RUN gem build backup.gemspec
FROM ruby:3.2-alpine3.18
ENV BUNDLE_PATH=/usr/local/bundle \
APP_HOME=/usr/src/backup
WORKDIR $APP_HOME
# Runtime dependencies
RUN apk add --no-cache ca-certificates libxml2 libxslt openssl
# Copy the built gem from builder
COPY --from=builder /usr/local/bundle /usr/local/bundle
COPY --from=builder /usr/src/backup/backup-*.gem /tmp/
# Install the built gem
RUN gem install /tmp/backup-*.gem -N
# Ensure the gem binaries are available in PATH
ENV PATH="/usr/local/bundle/bin:${PATH}"
# Default command to show usage/help
CMD ["backup", "--help"]