Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker modernization #186

Merged
merged 2 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ jobs:
submodules: true

- name: Build docker image
run: docker compose --file docker-compose.test.yml build
run: docker compose build

- name: Run tests
run: docker compose --file docker-compose.test.yml run sut
run: docker compose run test scripts/test_and_cover.sh
env:
GITHUB_TOKEN: ${{ secrets.github_token }}
3 changes: 0 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,6 @@ RUN cpanm --notest \

ENV SDRROOT /htapps/babel
ENV ROOTDIR "${SDRROOT}/crms"

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

RUN mkdir -p $ROOTDIR
COPY . $ROOTDIR
WORKDIR $ROOTDIR
11 changes: 0 additions & 11 deletions Makefile.PL

This file was deleted.

15 changes: 5 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,13 @@ A web app and suite of tools for performing copyright review projects.
git submodule init
git submodule update
docker compose build
docker compose up -d mariadb
docker compose up -d mariadb mariadb-ht
docker compose run --rm test
```

## Running Tests with Coverage

```
scripts/cover.sh
```

The other coverage script -- `scripts/test_and_cover.sh` -- is used by GitHub actions
to upload results to Coveralls.
By default the `test` service produces a `Devel::Cover` HTML report using
`scripts/test.sh`. The other script, `scripts/test_and_cover.sh`, is for upload to
Coveralls and is used in the GitHub action.

## What is Where

Expand All @@ -32,7 +27,7 @@ to upload results to Coveralls.
- `docker` Database seeds
- `lib` Perl modules (new development and refactored modules from `cgi`)
- `prep` Destination for some log files and reports
- `scripts` Binaries run as part of development or by GitHub
- `scripts` Testing wrappers run as part of development or by GitHub
- `t` Tests
- `web` Static assets including images, JS, CSS

Expand Down
41 changes: 0 additions & 41 deletions docker-compose.test.yml

This file was deleted.

33 changes: 28 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,37 @@
version: '3'
---

x-condition-healthy: &healthy
condition: service_healthy

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

services:

mariadb:
build: docker/db
restart: always
environment:
MYSQL_ROOT_PASSWORD: 'crms'
MYSQL_RANDOM_ROOT_PASSWORD: 1
ports:
- 3306:3306
healthcheck:
<<: *healthcheck-defaults
test: [ "CMD", "healthcheck.sh", "--su-mysql", "--connect", "--innodb_initialized" ]

mariadb_ht:
image: ghcr.io/hathitrust/db-image:latest
restart: always
environment:
MYSQL_ROOT_PASSWORD: 'crms'
MYSQL_RANDOM_ROOT_PASSWORD: 1
ports:
- 3307:3306
healthcheck:
<<: *healthcheck-defaults
test: [ "CMD", "healthcheck.sh", "--su-mysql", "--connect", "--innodb_initialized" ]

test:
build: .
Expand All @@ -27,7 +42,15 @@ services:
- CRMS_DB_HOST=mariadb
- CRMS_DB_HOST_DEVELOPMENT=mariadb
- CRMS_HT_DB_HOST=mariadb_ht
# pass through info needed by coveralls uploader
- GITHUB_TOKEN
- GITHUB_RUN_ID
- GITHUB_EVENT_TOKEN
- GITHUB_EVENT_PATH
- GITHUB_SHA
- GITHUB_REF
- GITHUB_ACTIONS
depends_on:
- mariadb
- mariadb_ht
mariadb: *healthy
mariadb_ht: *healthy
command: scripts/test.sh
2 changes: 1 addition & 1 deletion docker/db/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mariadb:10.1
FROM mariadb:10.11

# copy schema files inside
COPY sql/* /docker-entrypoint-initdb.d/
5 changes: 0 additions & 5 deletions scripts/cover.sh

This file was deleted.

5 changes: 1 addition & 4 deletions scripts/test.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#!/bin/bash

perl /htapps/babel/crms/Makefile.PL
/usr/local/bin/wait-for --timeout=300 mariadb:3306
/usr/local/bin/wait-for --timeout=30 mariadb_ht:3306
make test TEST_VERBOSE=1
cover -test -ignore_re '^t/' +ignore_re '^post' -report html -make 'prove -r t/; exit $?'
2 changes: 0 additions & 2 deletions scripts/test_and_cover.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/bin/bash

/usr/local/bin/wait-for --timeout=300 mariadb:3306
/usr/local/bin/wait-for --timeout=30 mariadb_ht:3306
cover -test -ignore_re '^t/' +ignore_re '^post' -report Coveralls -make 'prove -r t/; exit $?'