From c2b9d898abf11dcc823664489edc55ced5f4e3af Mon Sep 17 00:00:00 2001 From: David Zuckerman Date: Tue, 13 Jan 2026 12:49:06 -0800 Subject: [PATCH] using ruby3.3-slim for image, updated README, using app name for service instead of bfs now took out some unnecessary installs in Dockerfile, updated README using multi-target for images set working directory for production docker build Adding entrypoint to production build moved some common dev and production settings to base in Dockerfile, fixed some annotation warning --- .ruby-version | 2 +- Dockerfile | 46 +++++++++++++++++++++++++++++++++++++++++----- Gemfile | 2 -- README.md | 14 +++++++------- docker-compose.yml | 4 +++- 5 files changed, 52 insertions(+), 16 deletions(-) diff --git a/.ruby-version b/.ruby-version index 23887f6..0ddaf4d 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.1.7 +~> 3.3 diff --git a/Dockerfile b/Dockerfile index 98ca861..f165e2f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,22 +1,58 @@ -FROM registry.access.redhat.com/ubi8/ruby-31 +FROM ruby:3.3-slim AS base USER root # Configure users and groups RUN groupadd -g 40054 alma && \ useradd -r -s /sbin/nologin -M -u 40054 -g alma alma && \ + useradd -u 40061 bfs && \ groupadd -g 40061 bfs && \ usermod -u 40061 -g bfs -G alma -l bfs default && \ find / -user 1001 -exec chown -h bfs {} \; || true && \ mkdir -p /opt/app && \ chown -R bfs:bfs /opt/app +# Get list of available packages +RUN apt-get -y update -qq + +COPY --chown=bfs . /opt/app + +ENTRYPOINT ["/opt/app/bin/bfs"] +CMD ["help"] + +# =============================================== +# Target: development +# =============================================== + +FROM base AS development + +USER root + +RUN apt-get -y --no-install-recommends install \ + build-essential \ + make + +USER bfs + +# Base image ships with an older version of bundler +RUN gem install bundler --version 2.5.22 + WORKDIR /opt/app COPY --chown=bfs Gemfile* .ruby-version ./ RUN bundle config set force_ruby_platform true RUN bundle config set system 'true' RUN bundle install -COPY --chown=bfs . . -USER bfs -ENTRYPOINT ["/opt/app/bin/bfs"] -CMD ["help"] +# COPY --chown=bfs:bfs . . + +# ================================= +# Target: production +# ================================= +FROM base AS production + +# Copy the built codebase from the dev stage +# COPY --from=development --chown=bfs /opt/app /opt/app +COPY --from=development --chown=bfs /usr/local/bundle /usr/local/bundle + +WORKDIR /opt/app +RUN bundle config set frozen 'true' +RUN bundle install --local diff --git a/Gemfile b/Gemfile index b80f69d..133ba11 100644 --- a/Gemfile +++ b/Gemfile @@ -13,5 +13,3 @@ gem 'net-ssh', '~> 7.1.0' gem 'nokogiri', '~> 1.15.0' gem 'rspec' gem 'thor', '~> 1.1' - - diff --git a/README.md b/README.md index fbe1c6b..95fda93 100644 --- a/README.md +++ b/README.md @@ -13,13 +13,13 @@ docker compose build View the CLI tool help/description: ```sh -docker compose run --rm bfs help +docker compose run --rm app help ``` Adds test data to the default watch directory: ```sh -docker compose run --rm bfs seed +docker compose run --rm app seed ``` Run the app in the background. It will continue running, monitoring for .xml files to process every 10s. @@ -32,19 +32,19 @@ docker compose logs -f # view processing logs in real time Watch a non-standard directory: ```sh -docker compose run --rm bfs watch /path/in/container # absolute path -docker compose run --rm bfs watch data/somedir # path relative to /opt/app-root/src +docker compose run --rm app watch /path/in/container # absolute path +docker compose run --rm app watch data/somedir # path relative to /opt/app ``` Process a specific file: ```sh -docker compose run --rm bfs process /abs/path/to/myfile.xml # absolute path -docker compose run --rm bfs process data/invoicing/pay/somefile.xml # relative path +docker compose run --rm app process /abs/path/to/myfile.xml # absolute path +docker compose run --rm app process data/invoicing/pay/somefile.xml # relative path ``` Delete previously processed files and error logs: ```sh -docker compose run --rm bfs clear +docker compose run --rm app clear ``` diff --git a/docker-compose.yml b/docker-compose.yml index 6677b7f..13f8c03 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,8 @@ services: app: - build: . + build: + context: . + target: development command: watch --interval 10 init: true environment: