Skip to content

Commit

Permalink
Merge pull request #88 from GabrielInTheWorld/of-prod-setup
Browse files Browse the repository at this point in the history
Updates the prod-setup
  • Loading branch information
GabrielInTheWorld committed Jul 27, 2021
2 parents b9c9d32 + a27f01c commit c2b69fa
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 10 deletions.
10 changes: 3 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:14-buster-slim AS build
FROM node:16 AS build

WORKDIR /app

Expand All @@ -16,17 +16,13 @@ RUN npm run build

RUN npm prune --production

FROM node:14-buster-slim

RUN apt-get -y update && apt-get -y upgrade && \
apt-get install --no-install-recommends -y wait-for-it

RUN apt-get clean
FROM node:16-alpine

WORKDIR /app

COPY --from=build /app/build .
COPY --from=build /app/entrypoint.sh .
COPY --from=build /app/wait-for.sh .
COPY --from=build /app/node_modules ./node_modules

EXPOSE 9004
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM python:3.9.0-slim-buster

RUN apt-get -y update && apt-get -y upgrade && \
apt-get install --no-install-recommends -y wait-for-it && \
apt-get install -y make git curl
apt-get install -y make git curl netcat

RUN curl -sL https://deb.nodesource.com/setup_14.x | bash -
RUN apt-get install -y nodejs
Expand Down
4 changes: 2 additions & 2 deletions auth/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -e
export CACHE_PORT="${CACHE_PORT:-6379}"
export MESSAGE_BUS_PORT="${MESSAGE_BUS_PORT:-6379}"

wait-for-it --timeout=10 "$CACHE_HOST:$CACHE_PORT"
wait-for-it --timeout=10 "$MESSAGE_BUS_HOST:$MESSAGE_BUS_PORT"
./wait-for.sh --timeout=10 "$CACHE_HOST:$CACHE_PORT"
./wait-for.sh --timeout=10 "$MESSAGE_BUS_HOST:$MESSAGE_BUS_PORT"

exec "$@"
29 changes: 29 additions & 0 deletions auth/wait-for.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/sh

TIMEOUT=1
HOST=""
PORT=""

while [ "$1" != "" ]; do
PARAM=`echo $1 | awk -F= '{print $1}'`
VALUE=`echo $1 | awk -F= '{print $2}'`
case $PARAM in
*:* )
HOST=${PARAM%:*}
PORT=${PARAM#*:}
;;
-t | --timeout)
if [ "$VALUE" -gt 0 ]; then
TIMEOUT=$VALUE
fi
;;
esac
shift
done

while ! nc -z "$HOST" "$PORT"; do
echo "waiting for $HOST:$PORT for $TIMEOUT seconds..."
sleep $TIMEOUT
done

echo "$HOST:$PORT is available"

0 comments on commit c2b69fa

Please sign in to comment.