Skip to content

Commit

Permalink
Introduce devbuild and restructured folder structure
Browse files Browse the repository at this point in the history
  • Loading branch information
arunoda committed May 8, 2015
1 parent 19d092d commit 8a64274
Show file tree
Hide file tree
Showing 19 changed files with 90 additions and 34 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ For that, you can use `meteorhacks/meteord` as your base image. Magically, that'
Add following `Dockerfile` into the root of your app:

~~~shell
FROM meteorhacks/meteord:on-build
FROM meteorhacks/meteord:onbuild
~~~

Then you can build the docker image with:
Expand All @@ -37,6 +37,12 @@ docker run -d \
yourname/app
~~~

#### Stop downloading Meteor each and every time (mostly in development)

So, with the above method, MeteorD will download and install Meteor each and every time. That's bad specially in development. So, we've a solution for that. Simply use `meteorhacks/meteord:devbuild` as your base image.

> WARNING: Don't use `meteorhacks/meteord:devbuild` for your final build. If you used it, your image will carry the Meteor distribution as well. As a result of that, you'll end up with an image with ~700 MB.
Then you can access your app from the port 8080 of the host system.

### 2. Running a Meteor bundle with Docker
Expand Down Expand Up @@ -88,5 +94,5 @@ docker run -d \
-e BUNDLE_URL=http://mybundle_url_at_s3.tar.gz \
-e REBULD_NPM_MODULES=1 \
-p 8080:80 \
meteorhacks/meteord:bin-build
meteorhacks/meteord:binbuild
~~~
10 changes: 6 additions & 4 deletions base/scripts/init.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
bash $METEORD_DIR/install_base.sh
bash $METEORD_DIR/install_node.sh
bash $METEORD_DIR/install_phantomjs.sh
bash $METEORD_DIR/cleanup.sh
set -e

bash $METEORD_DIR/lib/install_base.sh
bash $METEORD_DIR/lib/install_node.sh
bash $METEORD_DIR/lib/install_phantomjs.sh
bash $METEORD_DIR/lib/cleanup.sh
22 changes: 22 additions & 0 deletions base/scripts/lib/build_app.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
set -e

COPIED_APP_PATH=/copied-app
BUNDLE_DIR=/tmp/bundle-dir

# sometimes, directly copied folder cause some wierd issues
# this fixes that
cp -R /app $COPIED_APP_PATH
cd $COPIED_APP_PATH

meteor build --directory $BUNDLE_DIR --server=http://localhost:3000

cd $BUNDLE_DIR/bundle/programs/server/
npm i

mv $BUNDLE_DIR/bundle /built_app

# cleanup
rm -rf $COPIED_APP_PATH
rm -rf $BUNDLE_DIR
rm -rf ~/.meteor
rm /usr/local/bin/meteor
3 changes: 2 additions & 1 deletion base/scripts/cleanup.sh → base/scripts/lib/cleanup.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## Shamelessly copied from: https://github.com/chriswessels/meteor-tupperware
## Borrowed from: https://github.com/chriswessels/meteor-tupperware

set -e
# Autoremove any junk
apt-get autoremove -y

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash

set -e
apt-get update -y
apt-get install -y curl bzip2
3 changes: 3 additions & 0 deletions base/scripts/lib/install_meteor.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
set -e

curl https://install.meteor.com | /bin/sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash

set -e
NODE_VERSION=0.10.36
NODE_ARCH=x64

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Install PhantomJS
set -e
apt-get -y install libfreetype6 libfreetype6-dev fontconfig
ARCH=`uname -m`
PHANTOMJS_VERSION=1.9.8
Expand Down
24 changes: 3 additions & 21 deletions base/scripts/on_build.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,5 @@
#!/bin/bash
curl https://install.meteor.com | /bin/sh
set -e

COPIED_APP_PATH=/copied-app
BUNDLE_DIR=/tmp/bundle-dir

# sometimes, directly copied folder cause some wierd issues
# this fixes that
cp -R /app $COPIED_APP_PATH
cd $COPIED_APP_PATH

meteor build --directory $BUNDLE_DIR --server=http://localhost:3000

cd $BUNDLE_DIR/bundle/programs/server/
npm i

mv $BUNDLE_DIR/bundle /built_app

# cleanup
rm -rf $COPIED_APP_PATH
rm -rf $BUNDLE_DIR
rm -rf ~/.meteor
rm /usr/local/bin/meteor
bash $METEORD_DIR/lib/install_meteor.sh
bash $METEORD_DIR/lib/build_app.sh
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions devbuild/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM meteorhacks/meteord:base
MAINTAINER MeteorHacks Pvt Ltd.

ONBUILD RUN bash $METEORD_DIR/lib/install_meteor.sh
ONBUILD COPY ./ /app
ONBUILD RUN bash $METEORD_DIR/lib/build_app.sh
File renamed without changes.
5 changes: 3 additions & 2 deletions tests/build_it.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
docker build -t meteorhacks/meteord:base ../base
docker build -t meteorhacks/meteord:on-build ../on-build
docker build -t meteorhacks/meteord:bin-build ../bin-build
docker build -t meteorhacks/meteord:onbuild ../onbuild
docker build -t meteorhacks/meteord:devbuild ../devbuild
docker build -t meteorhacks/meteord:binbuild ../binbuild
1 change: 1 addition & 0 deletions tests/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ set -e
bash ./build_it.sh

bash ./test_meteor_app.sh
bash ./test_meteor_app_with_devbuild.sh
bash ./test_bundle_local_mount.sh
bash ./test_bundle_web.sh
bash ./test_binary_build_on_base.sh
Expand Down
2 changes: 1 addition & 1 deletion tests/test_binary_build_on_bin_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ docker run -d \
-e BUNDLE_URL=https://s3.amazonaws.com/zeema-data/aa.tar.gz \
-e REBULD_NPM_MODULES=1 \
-p 9090:80 \
meteorhacks/meteord:bin-build
meteorhacks/meteord:binbuild

echo "Waiting for binary building is happening"
sleep 20
Expand Down
2 changes: 1 addition & 1 deletion tests/test_meteor_app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ clean

meteor create hello
cd hello
echo FROM meteorhacks/meteord:on-build >> Dockerfile
echo FROM meteorhacks/meteord:onbuild >> Dockerfile

docker build -t meteor-app-image ./
docker run -d \
Expand Down
31 changes: 31 additions & 0 deletions tests/test_meteor_app_with_devbuild.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

function clean() {
docker rm -f meteor-app
docker rmi -f meteor-app-image
rm -rf hello
}

cd /tmp
clean

meteor create hello
cd hello
echo FROM meteorhacks/meteord:devbuild >> Dockerfile

docker build -t meteor-app-image ./
docker run -d \
--name meteor-app \
-e ROOT_URL=http://yourapp_dot_com \
-p 8080:80 \
meteor-app-image

sleep 5

appContent=`curl http://localhost:8080`
clean

if [[ $appContent != *"yourapp_dot_com"* ]]; then
echo "Failed: Meteor app"
exit 1
fi

0 comments on commit 8a64274

Please sign in to comment.