Skip to content
This repository has been archived by the owner on Nov 14, 2020. It is now read-only.

Commit

Permalink
Fix running with docker compose
Browse files Browse the repository at this point in the history
Signed-off-by: wslulciuc <[email protected]>
  • Loading branch information
wslulciuc committed Feb 27, 2020
1 parent 11901cc commit 1d25802
Show file tree
Hide file tree
Showing 10 changed files with 379 additions and 225 deletions.
5 changes: 5 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ services:
- MARQUEZ_HOST=marquez
- MARQUEZ_PORT=5000
- MARQUEZ_ADMIN_PORT=5001
volumes:
- ./docker/wait-for-it.sh:/usr/local/bin/wait-for-it.sh
depends_on:
- marquez
entrypoint: ["./wait-for-it.sh", "marquez:5000", "--", "./entrypoint.sh"]

marquez:
image: marquezproject/marquez:latest
Expand All @@ -34,9 +37,11 @@ services:
- POSTGRES_USER=buendia
- POSTGRES_PASSWORD=macondo
volumes:
- ./docker/wait-for-it.sh:/usr/src/app/wait-for-it.sh
- ./docker/marquez.yml:/usr/src/app/config.yml
depends_on:
- marquez_db
entrypoint: ["./wait-for-it.sh", "marquez_db:5432", "--", "./entrypoint.sh"]

marquez_db:
image: "postgres:9.6"
Expand Down
2 changes: 1 addition & 1 deletion docker/db/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM alpine:3.7
WORKDIR /usr/local/bin
RUN apk add --update bash curl jq
COPY data/* ./data/
COPY wait-for-marquez.sh wait-for-marquez.sh
COPY seed-db.sh seed-db.sh
COPY entrypoint.sh entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
3 changes: 1 addition & 2 deletions docker/db/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@

set -e

./wait-for-marquez.sh "${MARQUEZ_HOST:-marquez}" "${MARQUEZ_ADMIN_PORT:-5001}" && \
./seed-db.sh
./seed-db.sh
33 changes: 0 additions & 33 deletions docker/db/wait-for-marquez.sh

This file was deleted.

179 changes: 179 additions & 0 deletions docker/wait-for-it.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
#!/bin/bash
#
# see: https://github.com/vishnubob/wait-for-it

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 > /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)
if [[ $WAITFORIT_TIMEOUT_PATH =~ "busybox" ]]; then
WAITFORIT_ISBUSY=1
WAITFORIT_BUSYTIMEFLAG="-t"

else
WAITFORIT_ISBUSY=0
WAITFORIT_BUSYTIMEFLAG=""
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
33 changes: 9 additions & 24 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@
"connected-react-router": "^6.4.0",
"css-loader": "^2.1.0",
"d3-color": "^1.4.0",
"d3-force": "^2.0.1",
"d3-hierarchy": "^1.1.9",
"d3-selection": "^1.4.0",
"d3-shape": "^1.3.7",
"d3-time-format": "^2.1.3",
"d3-zoom": "^1.8.3",
"http-proxy-middleware": "^0.20.0",
Expand Down
1 change: 1 addition & 0 deletions src/components/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ const Home: FunctionComponent<IAllProps> = props => {
const limit = 5

const { datasets, jobs, classes, showJobs, setShowJobs } = props

const matchingDatasets = datasets.filter(d => d.matches)
const matchingJobs = jobs.filter(j => j.matches)

Expand Down
4 changes: 2 additions & 2 deletions src/components/Legend.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from '@material-ui/core/styles'
import { Typography, Box } from '@material-ui/core'
const globalStyles = require('../global_styles.css')
const { jobNodeGrey, datasetNodeWhite } = globalStyles
const { datasetNodeWhite } = globalStyles

const styles = ({ spacing }: ITheme) => {
return createStyles({
Expand All @@ -16,7 +16,7 @@ const styles = ({ spacing }: ITheme) => {
},
jobShape: {
borderRadius: '50%',
backgroundColor: jobNodeGrey
backgroundColor: datasetNodeWhite
},
shape: {
width: spacing(2),
Expand Down
Loading

0 comments on commit 1d25802

Please sign in to comment.