Skip to content

Commit

Permalink
Initial release
Browse files Browse the repository at this point in the history
  • Loading branch information
thamerla committed Nov 30, 2016
0 parents commit d0347bb
Show file tree
Hide file tree
Showing 7 changed files with 162 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM node:6.9.1-alpine

ENV BUILD_PACKAGES="python make gcc g++ git curl tar bzip2" \
NODE_ENV=production

WORKDIR /

RUN apk add --update --no-cache ${BUILD_PACKAGES} && \
npm install -g node-gyp && \
node-gyp install

COPY scripts /scripts

ONBUILD COPY .build /
ONBUILD RUN sh /scripts/build.sh
ONBUILD RUN sh /scripts/rebuild_bin_npm_modules.sh
ONBUILD RUN sh /scripts/clean.sh

EXPOSE 80

ENTRYPOINT sh /scripts/run.sh
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2016 Tomasz Hamerla

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
58 changes: 58 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Alpine meteor

Utilizes [Alpine Linux](https://alpinelinux.org/) to provide a [Docker](https://www.docker.com/) image just tiny enough to run a Meteor-based application.

## Tags

`:latest`

`:1.4.3`

Tag is just a Meteor version that the image was prepared for. If your application was bundled using the same version, you may be sure that the build will go smoothly. Otherwise, compatibility issues may occur.

## What's included?

This is an ultra minimal image. Only packages essential to build a Meteor application image are added. Bash is not included (only POSIX-compatible shell is installed). PhantomJS or other packages (and their install scripts) that you may find useful are not included either.

## Usage

**Note**: Due to Docker's limitations, only one way of building is supported. However, you may use either a tarball or a directory. Just make sure it's put inside the `.build` folder. Bear in mind that a directory has a higer priority.

For a use case, see [this repository](https://github.com/nonyy/siteace).

### Recommended build steps:

- Ensure that the application bundle is inside `.build` directory. The following command may be used to generate the bundle:

`meteor build --directory --server-only --architecture os.linux.x86_64 .build`

- Create a Dockerfile with the following text inside:

`FROM nonyy/alpine-meteor`

- **(Optional)** If the build is done inside the source code directory, it's recommended to add the following `.dockerignore` to speed up the process, ignoring all the files except the bundle:

```
*
!.build
```

- Build using the following command:

`docker build -t NAME .`

where NAME is the image name you want to use
- Test using the following commands:

```
docker run -d --name mongo mvertes/alpine-mongo:3.2.10-3
docker run -d --link mongo:db --name meteor -p 3000:80 NAME
```

where NAME is the image name you want to use. You may use the official mongo image or any other implementation you find useful.

**Note**: As different Meteor versions may support different mongo versions - please make sure the correct one is used... or that the correct README is read. Run options may be overwritten using the -e parameter to the run command.

## Acknowledgements

Heavily influenced by [Martin Bucko's alpine-meteor image](https://github.com/Treecom/alpine-meteor). Thanks for the inspiration!
24 changes: 24 additions & 0 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/sh

set -e

export PYTHONPATH=/usr/lib/python2.7
export GYP_DEFINES="linux_use_gold_flags=0"

TARBALL=$(ls / | grep '\.tar\.gz')

if [[ -d /bundle ]]; then
echo "Using bundle directory"

elif [[ -f $TARBALL ]]; then
echo "Using bundle tarball"
tar xzf $TARBALL
rm $TARBALL

else
echo "Application bundle not provided"
exit 1
fi

cd /bundle/programs/server
npm install
11 changes: 11 additions & 0 deletions scripts/clean.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

set -e

apk del --purge ${BUILD_PACKAGES} wget

npm uninstall -g node-gyp
npm cache clear
npm uninstall -g npm

rm -rf /tmp/* /var/cache/apk/* /root/.node-gyp ./root/.npm
11 changes: 11 additions & 0 deletions scripts/rebuild_bin_npm_modules.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

export PYTHONPATH=/usr/lib/python2.7
export GYP_DEFINES="linux_use_gold_flags=0"

BINARY_MODULES=$(find /bundle -name 'binding\.gyp' -exec dirname {} \; | grep -v fibers)

for BINARY_MODULE in $BINARY_MODULES; do
cd $BINARY_MODULE
node-gyp rebuild
done
16 changes: 16 additions & 0 deletions scripts/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh

set -e

: ${DB:="meteor"}
: ${MONGO_URL:="mongodb://${DB_PORT_27017_TCP_ADDR}:${DB_PORT_27017_TCP_PORT}/${DB}"}
: ${PORT:="80"}
: ${ROOT_URL:="http://localhost"}

export MONGO_URL
export PORT
export ROOT_URL

cd /bundle
echo "=> Starting meteor app on port :$PORT"
node main.js

0 comments on commit d0347bb

Please sign in to comment.