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

adding wait / vendor module setup support #60

Merged
merged 2 commits into from
Apr 26, 2017
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
34 changes: 26 additions & 8 deletions dockerfiles/billing-development.dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,36 @@
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 /usr/local/bin/wait.sh https://raw.githubusercontent.com/Storj/storj-sdk/master/scripts/wait.sh

EXPOSE 3000

RUN mkdir /billing
WORKDIR /billing
RUN mkdir /opt/billing
# Map `/opt/app` to this services project root
RUN ln -s /opt/billing /opt/app
WORKDIR /opt/billing

RUN yarn global add nodemon

COPY ./package.json /billing/package.json
COPY ./package.json /opt/billing/package.json
RUN yarn install --ignore-engines

COPY ./bin /billing/bin
COPY ./lib /billing/lib
COPY ./index.js /billing/index.js
COPY ./test /billing/test
COPY ./bin /opt/billing/bin
COPY ./lib /opt/billing/lib
COPY ./index.js /opt/billing/index.js
COPY ./test /opt/billing/test

# Add setup script which takes care of vendored modules
ADD ./setup.sh /usr/local/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", "--"]

CMD npm run start-dev
# The default command this container will run is the billing server, but the user can pass in their own commands which get handled by wait.sh and dumb-init.
CMD ["/bin/bash", "/usr/local/bin/wait.sh", "/usr/local/bin/setup.sh", "npm run start-dev"]
18 changes: 17 additions & 1 deletion dockerfiles/billing-importer.dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
FROM node:6

# 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

COPY ./dockerfiles/files/billing-queries.package.json /root/package.json

WORKDIR /root
Expand All @@ -15,4 +24,11 @@ COPY ./lib/config.js /root/lib/config.js
ENV BILLING_URL http://billing
RUN chmod +x /root/bin/billing-queries.js

CMD npm run start-importer
# 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 billing-importer, 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-importer"]
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 /opt/app

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

echo "Rebuilding linked modules"
npm rebuild
done

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