Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

Commit

Permalink
wip adding wait / vendor module setup support
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanchriswhite committed Apr 24, 2017
1 parent 3bd248d commit bb31fe9
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
17 changes: 17 additions & 0 deletions dockerfiles/billing-development.dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
FROM storjlabs/node-storj:latest

# We use dumb-init since Node.js is pretty terrible at running as PID 1
RUN wget -O /usr/local/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64 \
&& chmod +x /usr/local/bin/dumb-init

# wait.sh forces our app to wait for other containers to come up before starting
# Should pull this into the repo to cache it or use the included wait scritp that comes with newer docker
# We shouldn't have to do this at all however. Our services should wait for other services until they are alive.
RUN wget -O /bin/wait.sh https://raw.githubusercontent.com/Storj/storj-sdk/master/scripts/wait.sh

EXPOSE 3000

RUN mkdir /billing
Expand All @@ -15,4 +24,12 @@ COPY ./lib /billing/lib
COPY ./index.js /billing/index.js
COPY ./test /billing/test

## Add setup script which takes care of vendored modules
#ADD ./setup.sh /bin/setup.sh
#
## Pass everything through dumb-init and wait.sh first, making sure our process handles the responsibilities of PID 1 and waits for services it depends on to start before coming up.
#ENTRYPOINT ["dumb-init", "--"]
#
## The default command this container will run is the bridge, but the user can pass in their own commands which get handled by wait.sh and dumb-init.
#CMD ["/bin/bash", "/bin/wait.sh", "/bin/setup.sh", "npm run start-dev"]
CMD npm run start-dev
17 changes: 17 additions & 0 deletions dockerfiles/billing-production.dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
FROM node:6.10

# We use dumb-init since Node.js is pretty terrible at running as PID 1
RUN wget -O /usr/local/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64 \
&& chmod +x /usr/local/bin/dumb-init

# wait.sh forces our app to wait for other containers to come up before starting
# Should pull this into the repo to cache it or use the included wait scritp that comes with newer docker
# We shouldn't have to do this at all however. Our services should wait for other services until they are alive.
RUN wget -O /bin/wait.sh https://raw.githubusercontent.com/Storj/storj-sdk/master/scripts/wait.sh

# TODO: use `production` but first we have to fix packages `engines` to be all compatible with 6.x
#ENV THOR_ENV production
ENV THOR_ENV development
Expand All @@ -15,4 +24,12 @@ WORKDIR /billing

RUN yarn --ignore-engines

## Add setup script which takes care of vendored modules
#ADD ./setup.sh /bin/setup.sh
#
## Pass everything through dumb-init and wait.sh first, making sure our process handles the responsibilities of PID 1 and waits for services it depends on to start before coming up.
#ENTRYPOINT ["dumb-init", "--"]
#
## The default command this container will run is the bridge, but the user can pass in their own commands which get handled by wait.sh and dumb-init.
#CMD ["/bin/bash", "/bin/wait.sh", "/bin/setup.sh", "npm run start-prod"]
CMD npm run start-prod
15 changes: 15 additions & 0 deletions setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
cd /usr/src/app

for dir in /usr/src/vendor/* ; do
if [[ -d $dir ]]; then
echo "Manually linking $dir"
dir_name=$(basename $dir)
rm -rf /usr/src/app/node_modules/$dir_name
cp -rp $dir /usr/src/app/node_modules/$dir_name
fi

echo "Rebuilding linked modules"
npm rebuild
done

/bin/bash -c -- "$@"

0 comments on commit bb31fe9

Please sign in to comment.