10000 Add additional dockerfiles to build production reaction images with a… · github4f/reaction@ce2c0e0 · GitHub
[go: up one dir, main page]

Skip to content

Commit ce2c0e0

Browse files
committed
Add additional dockerfiles to build production reaction images with and without mongodb.
1 parent 16ac736 commit ce2c0e0

9 files changed

+273
-139
lines changed

.dockerignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,9 @@
33
.npm
44
.git
55
.build.log
6+
Dockerfile
7+
docker
8+
docs
9+
.meteor/local
10+
packages/*/.npm
11+
packages/*/lib/bower

Dockerfile

Lines changed: 0 additions & 138 deletions
This file was deleted.

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
docker/reaction.dev.docker

bin/docker/build-bundle.sh

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#/bin/bash
2+
3+
# install dependencies
4+
apt-get update
5+
apt-get -qq -y install --no-install-recommends ca-certificates curl git
6+
7+
# install meteor
8+
curl --progress-bar --fail "https://d3sqy0vbqsdhku.cloudfront.net/packages-bootstrap/1.2.1/meteor-bootstrap-os.linux.x86_64.tar.gz" | tar -xzf - -C "/root" -o
9+
test -x "/root/.meteor/meteor"
10+
ln -s /root/.meteor/meteor /usr/bin/meteor
11+
12+
# install node from meteor tool package
13+
METEOR_TOOL="/root/.meteor/$(dirname "$(readlink "/root/.meteor/meteor")")"
14+
cd "$METEOR_TOOL/dev_bundle"
15+
cp -r --parents bin/node /usr
16+
cp -r --parents include/ /usr
17+
18+
# install npm
19+
curl https://www.npmjs.com/install.sh | sh
20+
21+
# build the meteor application
22+
cd /var/src
23+
/usr/bin/build-meteor.sh
24+
25+
# clean source tree
26+
rm -rf /var/src/packages/*/lib/bower
27+
rm -rf /var/src/packages/*/.npm
28+
rm -rf /var/src/.meteor/local
29+
30+
# clean additional files created outside the source tree
31+
rm -rf /root/.npm /root/.cache /root/.config /root/.cordova /root/.local
32+
rm -rf /tmp/*
33+
34+
# remove npm
35+
rm -rf /usr/bin/npm
36+
rm -rf /usr/lib/node_modules/npm
37+
38+
# remove meteor
39+
rm -rf /usr/bin/meteor
40+
rm -rf /root/.meteor
41+
42+
# remove dependencies
43+
apt-get -qq -y purge ca-certificates curl git
44+
apt-get -qq -y autoremove
45+
rm -rf /var/lib/apt/lists/*

bin/docker/entrypoint.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ set -e
1212
: ${ROOT_URL:="http://localhost"}
1313
: ${MONGO_URL:="mongodb://127.0.0.1:27017/meteor"}
1414

15+
# set default node executable
16+
: ${NODE:="node"}
17+
1518
#start mongodb (optional)
1619
if [[ "${MONGO_URL}" == *"127.0.0.1"* ]]; then
1720
echo "Starting local MongoDB..."
@@ -21,4 +24,4 @@ if [[ "${MONGO_URL}" == *"127.0.0.1"* ]]; then
2124
fi
2225

2326
# Run meteor
24-
exec nodemon ./main.js
27+
exec $NODE ./main.js

bin/docker/install-graphicsmagick.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#/bin/bash
2+
3+
touch /var/timestamp
4+
apt-get update
5+
apt-get -qq -y install --no-install-recommends graphicsmagick
6+
find /usr/share/doc \( -type f -o -empty \) -cnewer "/var/timestamp" -delete
7+
apt-get clean
8+
rm -rf /var/lib/apt/lists/*

bin/docker/install-mongodb.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#/bin/bash
2+
3+
apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
4+
echo "deb http://repo.mongodb.org/apt/debian wheezy/mongodb-org/3.0 main" | tee /etc/apt/sources.list.d/mongodb-org-3.0.list
5+
apt-get update
6+
apt-get -qq -y install --no-install-recommends adduser mongodb-org-server
7+
apt-get clean
8+
rm -rf /var/lib/apt/lists/*

docker/reaction.dev.docker

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
############################################################
2+
# Builds a Meteor + Reaction + MongoDB Docker Image
3+
#
4+
# Important: Best to run from a clean directory that hasn't had meteor run in it.
5+
# Important: packages/<pkg>/.npm and .build* should not exist
6+
#
7+
# NOTE: this script has some reaction specific scripts,
8+
# you probably don't want to use this a generic dockerfile
9+
#
10+
# Usage:
11+
# Build:
12+
# cd reaction
13+
# docker build -t <your org>/reaction .
14+
#
15+
# Run Reaction, Meteor + local mongo:
16+
#
17+
# docker run --rm -p ::3000
18+
# -e ROOT_URL="http://localhost" \
19+
# -e REACTION_EMAIL="youradmin@yourdomain.com" \
20+
# -e REACTION_USER="admin" \
21+
# -e REACTION_AUTH="password" \
22+
# -t ongoworks/reaction
23+
#
24+
#
25+
# Optional Meteor parameters (-e):
26+
#
27+
# ROOT_URL="< hostname>"
28+
# MONGO_URL="<your mongodb connect string>"
29+
# OPLOG_URL="<mongo oplog url>"
30+
# PORT="<meteor port>"
31+
# METEOR_SETTINGS="{json}"
32+
# DISABLE_WEBSOCKETS="1"
33+
#
34+
# Reaction Specific parameter (-e):
35+
#
36+
# MAIL_URL="<smtp connection string>"
37+
# REACTION_EMAIL="youradmin@yourdomain.com"
38+
# REACTION_USER="admin"
39+
# REACTION_AUTH="password"
40+
#
41+
##############################################################
42+
43+
FROM mongo:3.0
44+
MAINTAINER Aaron Judd <hello@reactioncommerce.com>
45+
46+
ENV DEBIAN_FRONTEND noninteractive
47+
48+
# https://github.com/meteor/meteor/issues/4019
49+
# ENV LC_ALL C
50+
51+
# Install git, curl, python, etc
52+
# Install imagemagick (optional for cfs:graphicsmagick)
53+
RUN apt-get -qq update && apt-get install -qq -y \
54+
build-essential \
55+
apt-utils \
56+
ca-certificates \
57+
chrpath \
58+
curl \
59+
gcc \
60+
git \
61+
graphicsmagick \
62+
libfreetype6 \
63+
libfreetype6-dev \
64+
libssl-dev \
65+
libfontconfig1 \
66+
make \
67+
procps \
68+
python \
69+
xz-utils
70+
71+
# install node from package nodesource
72+
RUN apt-get -qq upgrade
73+
RUN curl -sL https://deb.nodesource.com/setup_0.10 | bash -
74+
RUN apt-get install -y nodejs
75+
76+
# Install forever & phantomjs
77+
RUN npm install --silent -g phantomjs nodemon
78+
79+
# https://github.com/meteor/meteor/wiki/File-Change-Watcher-Efficiency
80+
# will only work if docker run in priviledged mode
81+
# RUN echo fs.inotify.max_user_watches=524288 | tee -a /etc/sysctl.conf && sysctl -p
82+
83+
# Install Meteor
84+
RUN curl -sL https://install.meteor.com | sed s/--progress-bar/-sL/g | /bin/sh
85+
86+
# Default (required) Meteor env variables
87+
ENV PORT 80
88+
ENV ROOT_URL http://localhost
89+
ENV MONGO_URL mongodb://127.0.0.1:27017/meteor
90+
ENV NODE nodemon
91+
92+
# Expose container port 3000 to the host (outside the container)
93+
# you can always map other ports such as 8080 in docker run
94+
# 80 is the default meteor production port, while 3000 is development mode
95+
EXPOSE 80
96+
97+
# Install entrypoint and build scripts
98+
# adding the files locally
99+
# and setting permissions.
100+
COPY bin/docker/entrypoint.sh /usr/bin/entrypoint.sh
101+
RUN chmod +x /usr/bin/entrypoint.sh
102+
103+
COPY bin/docker/build-meteor.sh /usr/bin/build-meteor.sh
104+
RUN chmod +x /usr/bin/build-meteor.sh
105+
106+
COPY bin/docker/cleanup.sh /usr/bin/cleanup.sh
107+
RUN chmod +x /usr/bin/cleanup.sh
108+
109+
# Make sure we have a directory for the application
110+
RUN mkdir -p /var/www
111+
RUN chown -R www-data:www-data /var/www
112+
113+
# add app to /usr/src
114+
# VOLUME ["/usr/src/meteor"]
115+
VOLUME ["/data/db"]
116+
COPY . /usr/src/meteor
117+
WORKDIR /usr/src/meteor/
118+
119+
#
120+
# Build meteor..
121+
# most of this can go away with Less updates
122+
# coming in Meteor 1.2.0 - however unless you
123+
# package the repo to just run development
124+
# you'll need to do some trick like this
125+
# also runs npm install in programs/server
126+
#
127+
RUN bash /usr/bin/build-meteor.sh
128+
129+
# cleanup
130+
RUN apt-get autoremove -y
131+
RUN npm cache clear
132+
RUN bash /usr/bin/cleanup.sh
133+
134+
# switch to production meteor bundle
135+
WORKDIR /var/www/bundle
136+
137+
# start mongo and reaction
138+
ENTRYPOINT ["/usr/bin/entrypoint.sh"]
139+
CMD []

0 commit comments

Comments
 (0)
0