Skip to content

Commit c2b9d89

Browse files
author
David Zuckerman
committed
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
1 parent 3f0ec07 commit c2b9d89

File tree

5 files changed

+52
-16
lines changed

5 files changed

+52
-16
lines changed

.ruby-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.1.7
1+
~> 3.3

Dockerfile

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,58 @@
1-
FROM registry.access.redhat.com/ubi8/ruby-31
1+
FROM ruby:3.3-slim AS base
22
USER root
33

44
# Configure users and groups
55
RUN groupadd -g 40054 alma && \
66
useradd -r -s /sbin/nologin -M -u 40054 -g alma alma && \
7+
useradd -u 40061 bfs && \
78
groupadd -g 40061 bfs && \
89
usermod -u 40061 -g bfs -G alma -l bfs default && \
910
find / -user 1001 -exec chown -h bfs {} \; || true && \
1011
mkdir -p /opt/app && \
1112
chown -R bfs:bfs /opt/app
1213

14+
# Get list of available packages
15+
RUN apt-get -y update -qq
16+
17+
COPY --chown=bfs . /opt/app
18+
19+
ENTRYPOINT ["/opt/app/bin/bfs"]
20+
CMD ["help"]
21+
22+
# ===============================================
23+
# Target: development
24+
# ===============================================
25+
26+
FROM base AS development
27+
28+
USER root
29+
30+
RUN apt-get -y --no-install-recommends install \
31+
build-essential \
32+
make
33+
34+
USER bfs
35+
36+
# Base image ships with an older version of bundler
37+
RUN gem install bundler --version 2.5.22
38+
1339
WORKDIR /opt/app
1440
COPY --chown=bfs Gemfile* .ruby-version ./
1541
RUN bundle config set force_ruby_platform true
1642
RUN bundle config set system 'true'
1743
RUN bundle install
18-
COPY --chown=bfs . .
1944

20-
USER bfs
21-
ENTRYPOINT ["/opt/app/bin/bfs"]
22-
CMD ["help"]
45+
# COPY --chown=bfs:bfs . .
46+
47+
# =================================
48+
# Target: production
49+
# =================================
50+
FROM base AS production
51+
52+
# Copy the built codebase from the dev stage
53+
# COPY --from=development --chown=bfs /opt/app /opt/app
54+
COPY --from=development --chown=bfs /usr/local/bundle /usr/local/bundle
55+
56+
WORKDIR /opt/app
57+
RUN bundle config set frozen 'true'
58+
RUN bundle install --local

Gemfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,3 @@ gem 'net-ssh', '~> 7.1.0'
1313
gem 'nokogiri', '~> 1.15.0'
1414
gem 'rspec'
1515
gem 'thor', '~> 1.1'
16-
17-

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ docker compose build
1313
View the CLI tool help/description:
1414

1515
```sh
16-
docker compose run --rm bfs help
16+
docker compose run --rm app help
1717
```
1818

1919
Adds test data to the default watch directory:
2020

2121
```sh
22-
docker compose run --rm bfs seed
22+
docker compose run --rm app seed
2323
```
2424

2525
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
3232
Watch a non-standard directory:
3333

3434
```sh
35-
docker compose run --rm bfs watch /path/in/container # absolute path
36-
docker compose run --rm bfs watch data/somedir # path relative to /opt/app-root/src
35+
docker compose run --rm app watch /path/in/container # absolute path
36+
docker compose run --rm app watch data/somedir # path relative to /opt/app
3737
```
3838

3939
Process a specific file:
4040

4141
```sh
42-
docker compose run --rm bfs process /abs/path/to/myfile.xml # absolute path
43-
docker compose run --rm bfs process data/invoicing/pay/somefile.xml # relative path
42+
docker compose run --rm app process /abs/path/to/myfile.xml # absolute path
43+
docker compose run --rm app process data/invoicing/pay/somefile.xml # relative path
4444
```
4545

4646
Delete previously processed files and error logs:
4747

4848
```sh
49-
docker compose run --rm bfs clear
49+
docker compose run --rm app clear
5050
```

docker-compose.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
services:
22
app:
3-
build: .
3+
build:
4+
context: .
5+
target: development
46
command: watch --interval 10
57
init: true
68
environment:

0 commit comments

Comments
 (0)