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

Fix various issues with installation of CamCHILDMine #17

Open
wants to merge 62 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
0afd95d
Workflow to build docker images
martinburchell Jul 11, 2024
edc3cb0
Ignore Emacs autosave files
martinburchell Jul 11, 2024
2ec09d4
Stacktrace from gradlew cargoDeployRemote
martinburchell Jul 11, 2024
74f67c5
Avoid readonly variables in docker compose script
martinburchell Jul 11, 2024
2571098
Check webapp in docker workflow
martinburchell Jul 11, 2024
af17cb7
Split up steps of Docker workflow
martinburchell Jul 11, 2024
bebb6aa
Try waiting a bit before dumping logs
martinburchell Jul 11, 2024
21ec0cd
Try to get a bit more log output
martinburchell Jul 11, 2024
a480c03
Increase workflow timeout to 15 minutes
martinburchell Jul 22, 2024
97a1f9a
Use camCHILDMine in workflow
martinburchell Jul 22, 2024
f0355c0
Refactor build script mine name variable
martinburchell Jul 22, 2024
fe667db
camCHILDMine requires bash in the builder Docker image
martinburchell Jul 22, 2024
bbfa848
Allow mine data volume to be overridden
martinburchell Jul 22, 2024
532562f
Check the right webapp in the Docker workflow
martinburchell Jul 22, 2024
20ea19d
Abort on build script failure
martinburchell Jul 22, 2024
76597f7
clone camCHILDMine in workflow
martinburchell Jul 22, 2024
6acd919
Remove duplicate set -e
martinburchell Jul 22, 2024
57b0ff7
Try to abort workflow early if build fails
martinburchell Jul 22, 2024
e556605
Remove obsolete docker compose versions
martinburchell Jul 22, 2024
cf35bcb
Set default for FORCE_MINE_BUILD
martinburchell Jul 22, 2024
4ea2b21
Try docker compose run to get build errors from the builder itself
martinburchell Jul 22, 2024
dc934cd
Ignore Silver Searcher .ignore file
martinburchell Jul 22, 2024
d41faad
Maybe I got those arguments wrong. Also remove the container
martinburchell Jul 22, 2024
aa6128e
Maybe we don't need detach mode
martinburchell Jul 22, 2024
80bddbe
More uninitialised variables in the build script
martinburchell Jul 22, 2024
ac05e96
Checkout cadre-dev branch of camCHILDMine in workflow
martinburchell Jul 22, 2024
e7e9409
Need to change directory before switching git branch
martinburchell Jul 22, 2024
dffdba7
Fix message in build script
martinburchell Jul 22, 2024
3e3a40d
Fix up project.xml path
martinburchell Jul 22, 2024
e003498
Fix path to malaria-data.tar.gz in build script
martinburchell Jul 22, 2024
ede97c8
Fix problem with database name case-sensitivity
martinburchell Jul 22, 2024
f3b76db
Shuffle docker compose commands in workflow
martinburchell Jul 23, 2024
0814188
Dump Docker logs on failure
martinburchell Jul 23, 2024
d066da6
Enable stacktrace on cargoDeployRemote
martinburchell Jul 24, 2024
9461268
Better fix for https://github.com/intermine/intermine/issues/2162
martinburchell Jul 24, 2024
59c5b5e
Separate workflow to build biotestmine
martinburchell Jul 25, 2024
d1fa47e
Try to sort out all the permissions issues
martinburchell Jul 25, 2024
3f5ca8e
Fix mkdatadirs arguments
martinburchell Jul 25, 2024
b3451ae
Put default Docker settings in .env
martinburchell Jul 25, 2024
f2dd6c7
Trigger workflows when .env changes [no ci]
martinburchell Jul 25, 2024
622be9e
Reminder to mkdir for your mine
martinburchell Jul 25, 2024
32ea5dc
Wait for postgres to be available or fail
martinburchell Jul 31, 2024
c00a625
Use wait-for-it instead of wait4x to wait for postgres
martinburchell Jul 31, 2024
6bdb8c1
Fix permissions problem with Postgres container
martinburchell Jul 31, 2024
682322e
Bail out early if there was a problem with Solr, Tomcat or Postgres
martinburchell Jul 31, 2024
0640b40
Run Docker and Postgres containers as root
martinburchell Jul 31, 2024
f050524
Try PGPASSWORD for postgres and reinstate user for Solr
martinburchell Aug 1, 2024
7ee825b
Fix Solr user
martinburchell Aug 1, 2024
70420f6
Ensure Solr volume is owned by the Solr user
martinburchell Aug 2, 2024
d2efdfa
Use docker compose up now the build seems to be working
martinburchell Aug 2, 2024
4156e9b
Move checking the webapp so we dump the docker logs on failure
martinburchell Aug 2, 2024
b23960b
Fix camchildmine web app path
martinburchell Aug 2, 2024
75fd434
Fix Postgres health check
martinburchell Nov 7, 2024
25106a8
Don't copy malaria-data.tar.gz if it doesn't exist
martinburchell Nov 8, 2024
9423d79
Move CamCHILDMine workflow to that project
martinburchell Dec 18, 2024
df8b4fd
Less noisy output of shell scripts
martinburchell Dec 18, 2024
39841d8
Fix mkdatadirs.sh to run from anywhere
martinburchell Dec 18, 2024
9ca3a08
Add note about potential 404 when building the webapp
martinburchell Dec 18, 2024
1b26a48
Remove debug code in Dockerfile
martinburchell Dec 18, 2024
53e9856
Add licence for wait-for-it
martinburchell Dec 18, 2024
c9d9ab5
Use separate memory configuration for builder, Solr and Tomcat
martinburchell Dec 18, 2024
fcf7844
Remove debugging from build.sh
martinburchell Dec 18, 2024
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
12 changes: 12 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
DOCKER_UID=1000
DOCKER_GID=1000
MINE_NAME=biotestmine
MINE_REPO_URL=
IM_DATA_DIR=DATA_DIR
BUILDER_MEM_OPTS=:"-Xmx2g -Xms1g"
SOLR_MEM_OPTS=:"-Xmx2g -Xms1g"
TOMCAT_MEM_OPTS=:"-Xmx1g -Xms500m"
IM_REPO_URL=
IM_REPO_BRANCH=
TOMCAT_HOST_PORT=9999
TOMCAT_PORT=8080
63 changes: 63 additions & 0 deletions .github/workflows/biotestmine.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
---
# yamllint disable rule:line-length
name: Biotestmine
# yamllint disable-line rule:truthy
on:
push:
paths:
- '.env'
- '.github/workflows/biotestmine.yml'
- 'intermine_builder/**'
- 'local.docker-compose.yml'
- 'mkdatadirs.sh'
- 'postgres/**'
- 'solr/**'
- 'tomcat/**'

jobs:
biotestmine:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install prerequisites
run: |
set -euo pipefail
sudo apt -y install wait-for-it
- name: Make data dirs
run: |
set -euo pipefail
cd ${GITHUB_WORKSPACE}
./mkdatadirs.sh
mkdir ./data/mine/biotestmine
- name: Up
run: |
set -euo pipefail
cd ${GITHUB_WORKSPACE}
# Use run to trap any build errors early
# DOCKER_UID=$(id -u) DOCKER_GID=$(id -g) docker compose -f local.docker-compose.yml run --rm intermine_builder
DOCKER_UID=$(id -u) DOCKER_GID=$(id -g) docker compose -f local.docker-compose.yml up -d
- name: Wait
run: |
set -euo pipefail
cd ${GITHUB_WORKSPACE}
# Wait for builder to finish and return exit code
DOCKER_UID=$(id -u) DOCKER_GID=$(id -g) docker compose -f local.docker-compose.yml wait intermine_builder
# Wait 15 minutes
wait-for-it localhost:9999 --timeout=900

- name: Check webapp
run: |
set -euo pipefail
curl -I -L --retry 10 --fail --insecure "http://localhost:9999/biotestmine/"

- name: Dump Docker logs
if: failure()
run: |
set -euo pipefail
cd ${GITHUB_WORKSPACE}
sleep 120
DOCKER_UID=$(id -u) DOCKER_GID=$(id -g) docker compose -f local.docker-compose.yml logs intermine_builder
DOCKER_UID=$(id -u) DOCKER_GID=$(id -g) docker compose -f local.docker-compose.yml logs postgres
DOCKER_UID=$(id -u) DOCKER_GID=$(id -g) docker compose -f local.docker-compose.yml logs solr
DOCKER_UID=$(id -u) DOCKER_GID=$(id -g) docker compose -f local.docker-compose.yml logs tomcat
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
.env
/data

# Emacs backup
*~

# Silver searcher
.ignore
3 changes: 1 addition & 2 deletions dockerhub.docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: "3"
services:
intermine_builder:
container_name: intermine_builder
Expand All @@ -19,7 +18,7 @@ services:
- MEM_OPTS=${MEM_OPTS:-"-Xmx2g -Xms1g"}
- IM_REPO_URL=${IM_REPO_URL:-}
- IM_REPO_BRANCH=${IM_REPO_BRANCH:-}
depends_on:
depends_on:
- postgres
- solr
- tomcat
Expand Down
177 changes: 98 additions & 79 deletions intermine_builder/build.sh

Large diffs are not rendered by default.

27 changes: 22 additions & 5 deletions intermine_builder/intermine_builder.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
FROM alpine:3.12.5
LABEL maintainer="Ank"

# -----------------------------------------------------------------------------
# Permissions
# -----------------------------------------------------------------------------
# https://vsupalov.com/docker-shared-permissions/

ARG USER_ID
ARG GROUP_ID

RUN addgroup --gid $GROUP_ID intermine
RUN adduser -D -g '' -u $USER_ID -G intermine intermine

ENV JAVA_HOME="/usr/lib/jvm/default-jvm"

RUN apk add --no-cache openjdk8 openjdk8-jre && \
ln -sf "${JAVA_HOME}/bin/"* "/usr/bin/"

RUN apk add --no-cache git \
RUN apk add --no-cache bash \
git \
maven \
postgresql-client \
perl \
Expand Down Expand Up @@ -58,9 +70,6 @@ RUN cpanm --force Ouch \
# Digest::MD5 \
# Log::Handler

RUN mkdir /home/intermine && mkdir /home/intermine/intermine
RUN chmod -R 777 /home/intermine

ENV MEM_OPTS="-Xmx1g -Xms500m"
ENV GRADLE_OPTS="-server ${MEM_OPTS} -XX:+UseParallelGC -XX:SoftRefLRUPolicyMSPerMB=1 -XX:MaxHeapFreeRatio=99 -Dorg.gradle.daemon=false -Duser.home=/home/intermine"
ENV HOME="/home/intermine"
Expand All @@ -73,8 +82,16 @@ ENV TOMCAT_PWD="tomcat"
ENV TOMCAT_PORT=8080
ENV PGPORT=5432

RUN mkdir /home/intermine/intermine
COPY ./build.sh /home/intermine
RUN chmod a+rx /home/intermine/build.sh
RUN chown -R intermine:intermine /home/intermine
RUN chmod u+x /home/intermine/build.sh

COPY ./wait-for-it/wait-for-it.sh /usr/local/bin/wait-for-it
RUN chmod +x /usr/local/bin/wait-for-it

WORKDIR /home/intermine/intermine

USER intermine

CMD ["/bin/sh","/home/intermine/build.sh"]
20 changes: 20 additions & 0 deletions intermine_builder/wait-for-it/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2016 Giles Hall

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
182 changes: 182 additions & 0 deletions intermine_builder/wait-for-it/wait-for-it.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
#!/usr/bin/env bash
# Use this script to test if a given TCP host/port are available

WAITFORIT_cmdname=${0##*/}

echoerr() { if [[ $WAITFORIT_QUIET -ne 1 ]]; then echo "$@" 1>&2; fi }

usage()
{
cat << USAGE >&2
Usage:
$WAITFORIT_cmdname host:port [-s] [-t timeout] [-- command args]
-h HOST | --host=HOST Host or IP under test
-p PORT | --port=PORT TCP port under test
Alternatively, you specify the host and port as host:port
-s | --strict Only execute subcommand if the test succeeds
-q | --quiet Don't output any status messages
-t TIMEOUT | --timeout=TIMEOUT
Timeout in seconds, zero for no timeout
-- COMMAND ARGS Execute command with args after the test finishes
USAGE
exit 1
}

wait_for()
{
if [[ $WAITFORIT_TIMEOUT -gt 0 ]]; then
echoerr "$WAITFORIT_cmdname: waiting $WAITFORIT_TIMEOUT seconds for $WAITFORIT_HOST:$WAITFORIT_PORT"
else
echoerr "$WAITFORIT_cmdname: waiting for $WAITFORIT_HOST:$WAITFORIT_PORT without a timeout"
fi
WAITFORIT_start_ts=$(date +%s)
while :
do
if [[ $WAITFORIT_ISBUSY -eq 1 ]]; then
nc -z $WAITFORIT_HOST $WAITFORIT_PORT
WAITFORIT_result=$?
else
(echo -n > /dev/tcp/$WAITFORIT_HOST/$WAITFORIT_PORT) >/dev/null 2>&1
WAITFORIT_result=$?
fi
if [[ $WAITFORIT_result -eq 0 ]]; then
WAITFORIT_end_ts=$(date +%s)
echoerr "$WAITFORIT_cmdname: $WAITFORIT_HOST:$WAITFORIT_PORT is available after $((WAITFORIT_end_ts - WAITFORIT_start_ts)) seconds"
break
fi
sleep 1
done
return $WAITFORIT_result
}

wait_for_wrapper()
{
# In order to support SIGINT during timeout: http://unix.stackexchange.com/a/57692
if [[ $WAITFORIT_QUIET -eq 1 ]]; then
timeout $WAITFORIT_BUSYTIMEFLAG $WAITFORIT_TIMEOUT $0 --quiet --child --host=$WAITFORIT_HOST --port=$WAITFORIT_PORT --timeout=$WAITFORIT_TIMEOUT &
else
timeout $WAITFORIT_BUSYTIMEFLAG $WAITFORIT_TIMEOUT $0 --child --host=$WAITFORIT_HOST --port=$WAITFORIT_PORT --timeout=$WAITFORIT_TIMEOUT &
fi
WAITFORIT_PID=$!
trap "kill -INT -$WAITFORIT_PID" INT
wait $WAITFORIT_PID
WAITFORIT_RESULT=$?
if [[ $WAITFORIT_RESULT -ne 0 ]]; then
echoerr "$WAITFORIT_cmdname: timeout occurred after waiting $WAITFORIT_TIMEOUT seconds for $WAITFORIT_HOST:$WAITFORIT_PORT"
fi
return $WAITFORIT_RESULT
}

# process arguments
while [[ $# -gt 0 ]]
do
case "$1" in
*:* )
WAITFORIT_hostport=(${1//:/ })
WAITFORIT_HOST=${WAITFORIT_hostport[0]}
WAITFORIT_PORT=${WAITFORIT_hostport[1]}
shift 1
;;
--child)
WAITFORIT_CHILD=1
shift 1
;;
-q | --quiet)
WAITFORIT_QUIET=1
shift 1
;;
-s | --strict)
WAITFORIT_STRICT=1
shift 1
;;
-h)
WAITFORIT_HOST="$2"
if [[ $WAITFORIT_HOST == "" ]]; then break; fi
shift 2
;;
--host=*)
WAITFORIT_HOST="${1#*=}"
shift 1
;;
-p)
WAITFORIT_PORT="$2"
if [[ $WAITFORIT_PORT == "" ]]; then break; fi
shift 2
;;
--port=*)
WAITFORIT_PORT="${1#*=}"
shift 1
;;
-t)
WAITFORIT_TIMEOUT="$2"
if [[ $WAITFORIT_TIMEOUT == "" ]]; then break; fi
shift 2
;;
--timeout=*)
WAITFORIT_TIMEOUT="${1#*=}"
shift 1
;;
--)
shift
WAITFORIT_CLI=("$@")
break
;;
--help)
usage
;;
*)
echoerr "Unknown argument: $1"
usage
;;
esac
done

if [[ "$WAITFORIT_HOST" == "" || "$WAITFORIT_PORT" == "" ]]; then
echoerr "Error: you need to provide a host and port to test."
usage
fi

WAITFORIT_TIMEOUT=${WAITFORIT_TIMEOUT:-15}
WAITFORIT_STRICT=${WAITFORIT_STRICT:-0}
WAITFORIT_CHILD=${WAITFORIT_CHILD:-0}
WAITFORIT_QUIET=${WAITFORIT_QUIET:-0}

# Check to see if timeout is from busybox?
WAITFORIT_TIMEOUT_PATH=$(type -p timeout)
WAITFORIT_TIMEOUT_PATH=$(realpath $WAITFORIT_TIMEOUT_PATH 2>/dev/null || readlink -f $WAITFORIT_TIMEOUT_PATH)

WAITFORIT_BUSYTIMEFLAG=""
if [[ $WAITFORIT_TIMEOUT_PATH =~ "busybox" ]]; then
WAITFORIT_ISBUSY=1
# Check if busybox timeout uses -t flag
# (recent Alpine versions don't support -t anymore)
if timeout &>/dev/stdout | grep -q -e '-t '; then
WAITFORIT_BUSYTIMEFLAG="-t"
fi
else
WAITFORIT_ISBUSY=0
fi

if [[ $WAITFORIT_CHILD -gt 0 ]]; then
wait_for
WAITFORIT_RESULT=$?
exit $WAITFORIT_RESULT
else
if [[ $WAITFORIT_TIMEOUT -gt 0 ]]; then
wait_for_wrapper
WAITFORIT_RESULT=$?
else
wait_for
WAITFORIT_RESULT=$?
fi
fi

if [[ $WAITFORIT_CLI != "" ]]; then
if [[ $WAITFORIT_RESULT -ne 0 && $WAITFORIT_STRICT -eq 1 ]]; then
echoerr "$WAITFORIT_cmdname: strict mode, refusing to execute subprocess"
exit $WAITFORIT_RESULT
fi
exec "${WAITFORIT_CLI[@]}"
else
exit $WAITFORIT_RESULT
fi
Loading