Skip to content

Commit

Permalink
Dockerfile updates for traject
Browse files Browse the repository at this point in the history
* remove wait-for & use health checks
* use production stage
  • Loading branch information
aelkiss committed Oct 29, 2024
1 parent d761182 commit b8ea52e
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 22 deletions.
27 changes: 18 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,30 @@
FROM jruby:9.4-jdk17
FROM jruby:9.4-jdk17 AS base
ARG UNAME=app
ARG UID=1000
ARG GID=1000

RUN apt-get update -yqq && apt-get install -yqq --no-install-recommends \
build-essential \
netbase \
netcat
netbase

RUN groupadd -g ${GID} -o ${UNAME}
RUN useradd -m -d /app -u ${UID} -g ${GID} -o -s /bin/bash ${UNAME}
RUN mkdir -p /gems && chown ${UID}:${GID} /gems

# COPY --chown=${UID}:${GID} Gemfile* /app/
WORKDIR /app
RUN wget -O /usr/local/bin/wait-for https://github.com/eficode/wait-for/releases/download/v2.2.3/wait-for && chmod +x /usr/local/bin/wait-for

# USER $UNAME
ENV BUNDLE_PATH /gems
RUN gem install bundler

FROM base AS development

FROM base AS production

RUN groupadd -g $GID -o $UNAME
RUN useradd -m -d /app -u $UID -g $GID -o -s /bin/bash $UNAME
RUN mkdir -p /gems && chown $UID:$GID /gems
USER $UNAME
COPY --chown=$UID:$GID Gemfile* /app
WORKDIR /app
ENV BUNDLE_PATH /gems
RUN bundle install
COPY --chown=$UID:$GID . /app

LABEL org.opencontainers.image.source="https://github.com/hathitrust/hathitrust_catalog_indexer"
32 changes: 27 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,60 @@
---

x-condition-healthy: &healthy
condition: service_healthy

x-healthcheck-defaults: &healthcheck-defaults
interval: 5s
timeout: 10s
start_period: 10s
retries: 5

services:
traject:
build: .
build:
context: .
target: development
volumes:
- .:/app
- gem_cache:/gems
environment:
- SOLR_URL=http://solr-sdr-catalog:9033/solr/catalog
- redirect_file=/dev/null
- NO_DB=1
network_mode: host
command: sleep infinity

test:
build: .
build:
context: .
target: development
volumes:
- .:/app
- gem_cache:/gems
command: bash -c "wait-for solr-sdr-catalog:9033 mariadb:3306 && JRUBY_OPTS='--debug' bundle exec rspec"
command: bundle exec rspec
environment:
- JRUBY_OPTS=--debug
- SOLR_URL=http://solr-sdr-catalog:9033/solr/catalog
- redirect_file=/dev/null
depends_on:
- solr-sdr-catalog
- mariadb
solr-sdr-catalog: *healthy
mariadb: *healthy

solr-sdr-catalog:
build: solr
ports:
- "9033:9033"
healthcheck:
<<: *healthcheck-defaults
test: [ "CMD", "curl","-s","-f","http://localhost:9033/solr/catalog/admin/ping" ]

mariadb:
image: ghcr.io/hathitrust/db-image:latest
ports:
- "3306:3306"
healthcheck:
<<: *healthcheck-defaults
test: [ "CMD", "healthcheck.sh", "--su-mysql", "--connect", "--innodb_initialized" ]

volumes:
gem_cache:
11 changes: 3 additions & 8 deletions lib/translation_maps/ht/collection_code_to_original_from.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@ aubru: The University of Queensland
aztes: Arizona State University
chi: University of Chicago
coo: Cornell University
cou: University of Colorado Boulder
ctu: University of Connecticut
deu: University of Delaware
fmu: University of Miami
geu: Emory University
gri: Getty Research Institute
gu: University System of Georgia
gwla: Technical Report Archive &amp; Image Library
hvd: Harvard University
iagg: Grinnell College
iau: University of Iowa
ibc: Boston College
iduke: Duke University
Expand All @@ -30,8 +27,8 @@ iucla: University of California
iufl: State University System of Florida
iuiuc: University of Illinois at Urbana-Champaign
iunc: University of North Carolina at Chapel Hill
keio: 'Keio University 慶應義塾大学 '
lebau: American University of Beirut - الجامعة الأميركيّة في بيروت
keio: 慶應義塾大学 (Keio University)
lebau: American University of Beirut
mdbj: Johns Hopkins University
mdl: Minnesota Digital Library
mdu: University of Maryland, College Park
Expand All @@ -45,8 +42,6 @@ nbb: Brooklyn Museum
nbuu: University At Buffalo, The State University of New York
ncwsw: Wake Forest University
njp: Princeton University
njpt: Princeton Theological Seminary
njr: Rutgers University
nnc: Columbia University
nnfr: The Frick Collection
nrlf: University of California
Expand All @@ -65,7 +60,7 @@ srlf: University of California
tu: University of Tennessee, Knoxville
txcm: Texas A&amp;M University
txsmtsu: Texas State University - San Marcos
txu: The University of Texas
txu: University of Texas at Austin
ucbk: University of California
ucd: University of California
uci: University of California
Expand Down

0 comments on commit b8ea52e

Please sign in to comment.