Skip to content

Instantly share code, notes, and snippets.

@scr512
Created February 27, 2016 06:39
Show Gist options
  • Save scr512/3763359be532772f9b2e to your computer and use it in GitHub Desktop.
Save scr512/3763359be532772f9b2e to your computer and use it in GitHub Desktop.
Docker example to build Cyclotron (Why am I putting this in a Gist? :])
#Dockerfile
FROM phusion/baseimage:latest
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
RUN echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-3.0.list
RUN apt-get update
RUN apt-get install -y build-essential git mongodb-org supervisor curl wget nginx
RUN curl -sL https://deb.nodesource.com/setup | sudo bash -
RUN apt-get install -y nodejs
RUN npm install -g npm@latest
RUN npm install -g gulp phantomjs casperjs bower
RUN mkdir -p /data/db
RUN mkdir -p /opt/app
WORKDIR /opt/app
RUN git clone https://github.com/ExpediaInceCommercePlatform/cyclotron.git /opt/app
RUN cd /opt/app/cyclotron-svc && npm install
RUN cd /opt/app/cyclotron-site && npm install
RUN cp /opt/app/cyclotron-svc/config/sample.config.js /opt/app/cyclotron-svc/config/config.js
ADD ./supervisor/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
ADD ./boot/boot.sh /usr/bin/boot.sh
ADD ./configService.js /opt/app/cyclotron-site/_public/js/conf/configService.js
RUN mkdir -p /var/log/supervisor
VOLUME ["/data"]
EXPOSE 8077
EXPOSE 8080
CMD ["/usr/bin/boot.sh"]
#configService.js
cyclotronServices.factory('configService', ['commonConfigService', function(commonConfigService) {
var cyclotronEnvironments, exports, merged, proxyOptions;
cyclotronEnvironments = [
{
name: 'Dev',
serviceUrl: 'http://cyclotron/api',
requiresAuth: true,
canPush: true
}, {
name: 'Localhost',
serviceUrl: 'http://127.0.0.1:8077',
requiresAuth: false,
canPush: false
}
];
proxyOptions = _.reduce(cyclotronEnvironments, function(options, environment) {
options[environment.name] = {
value: environment.serviceUrl
};
return options;
}, {});
exports = {
restServiceUrl: 'http://127.0.0.1:8077',
authentication: {
enable: false,
loginMessage: 'Please login using your LDAP username and password.'
},
enableAnalytics: true,
cyclotronEnvironments: cyclotronEnvironments,
dashboard: {
properties: {
dataSources: {
options: {
graphite: {
properties: {
url: {
"default": 'http://graphite'
},
proxy: {
options: proxyOptions
}
}
},
json: {
properties: {
proxy: {
options: proxyOptions
}
}
},
splunk: {
properties: {
host: {
"default": 'splunk'
},
proxy: {
options: proxyOptions
}
}
}
}
}
}
}
};
merged = _.merge(commonConfigService, exports, _["default"]);
merged.help[0].messages = [
{
type: 'info',
html: 'Welcome to Cyclotron!',
icon: 'fa-info-circle'
}
];
return merged;
}]);
#./supervisor/supervisord.conf
[supervisord]
nodaemon = true
[program:mongodb]
command = /usr/bin/mongod
stdout_logfile = /var/log/supervisor/%(program_name)s.log
stderr_logfile = /var/log/supervisor/%(program_name)s.log
autorestart = true
[program:cyclotron-svc]
directory = /opt/app/cyclotron-svc
command = /usr/bin/node /opt/app/cyclotron-svc/app.js
stdout_logfile = /var/log/supervisor/%(program_name)s.log
stderr_logfile = /var/log/supervisor/%(program_name)s.log
autorestart = true
[program:cyclotron-site]
directory = /opt/app/cyclotron-site
command = /usr/bin/gulp server
stdout_logfile = /var/log/supervisor/%(program_name)s.log
stderr_logfile = /var/log/supervisor/%(program_name)s.log
autorestart = true
#./boot/boot.sh
#!/bin/bash
exec /usr/bin/supervisord
#Build and run
docker build --no-cache -rm -t scr512/cyclotron /opt/docker/docker-cyclotron
docker run -d --restart=always --name cyclotron -v /work/cyclotron/data:/data -p 8080:8080 -p 8077:8077 scr512/cyclotron
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment