From 050b321148e2ad5939ed482957ce429a0d056df9 Mon Sep 17 00:00:00 2001 From: Nathan219 Date: Thu, 22 Jan 2015 14:37:37 -0800 Subject: [PATCH] Creating individual files for each source dockerfile to make them easier to edit --- scripts/seed-version.js | 116 ++------------------------ scripts/sourceDockerfiles/mysql | 10 +++ scripts/sourceDockerfiles/nodejs | 18 ++++ scripts/sourceDockerfiles/postgresSql | 9 ++ scripts/sourceDockerfiles/python | 20 +++++ scripts/sourceDockerfiles/rails | 30 +++++++ scripts/sourceDockerfiles/ruby | 26 ++++++ 7 files changed, 121 insertions(+), 108 deletions(-) create mode 100644 scripts/sourceDockerfiles/mysql create mode 100644 scripts/sourceDockerfiles/nodejs create mode 100644 scripts/sourceDockerfiles/postgresSql create mode 100644 scripts/sourceDockerfiles/python create mode 100644 scripts/sourceDockerfiles/rails create mode 100644 scripts/sourceDockerfiles/ruby diff --git a/scripts/seed-version.js b/scripts/seed-version.js index 526ab9532..807ce5c7c 100644 --- a/scripts/seed-version.js +++ b/scripts/seed-version.js @@ -11,6 +11,8 @@ 'use strict'; require('loadenv')(); + +var fs = require('fs'); var Context = require('models/mongo/context'); var ContextVersion = require('models/mongo/context-version'); var InfraCodeVersion = require('models/mongo/infra-code-version'); @@ -248,127 +250,25 @@ function newCV (context, icv, cb) { var sources = [{ name: 'NodeJs', isTemplate: true, - body: '# Full list of versions available here: https://registry.hub.docker.com/_/node/tags/manage/\n' + - 'FROM node:\n' + - '\n' + - '# Open up ports on the server\n' + - 'EXPOSE \n' + - '\n' + - '# Add repository files to server\n' + - 'ADD ./ /\n' + - 'WORKDIR /\n' + - '\n' + - '# Install dependencies\n' + - 'RUN apt-get update \n' + - '\n' + - '\n' + - 'RUN npm install\n' + - '\n' + - '# Command to start the app\n' + - 'CMD \n' + body: fs.readFileSync(__dirname + '/sourceDockerFiles/nodejs').toString() }, { name: 'Rails', isTemplate: true, - body: 'FROM ruby:\n' + - '# Open up ports on the server\n' + - 'EXPOSE \n' + - '\n' + - '# Install Rails (and its dependencies)\n' + - 'RUN apt-get update && apt-get install -y nodejs --no-install-recommends && rm -rf /var/lib/apt/lists/*\n' + - '\n' + - '\n' + - '# see http://guides.rubyonrails.org/command_line.html#rails-dbconsole\n' + - 'RUN apt-get update && apt-get install -y mysql-client postgresql-client sqlite3 --no-install-recommends && rm -rf /var/lib/apt/lists/*\n' + - '\n' + - '# Specify the version of Rails to install\n' + - 'ENV RAILS_VERSION \n' + - 'RUN gem install rails --version "$RAILS_VERSION"\n' + - '\n' + - '# Add repository files to server\n' + - 'ADD ./ /\n' + - 'WORKDIR /\n' + - '\n' + - '# Install dependencies\n' + - 'RUN apt-get update \n' + - '\n' + - '\n' + - 'RUN bundle install\n' + - '\n' + - '# Setup and seed database\n' + - 'RUN rake db:create db:migrate\n' + - '\n' + - '# Command to start the app\n' + - 'CMD \n' + body: fs.readFileSync(__dirname + '/sourceDockerFiles/rails').toString() }, { name: 'Ruby', isTemplate: true, - body: 'FROM ruby:\n' + - '# Open up ports on the server\n' + - 'EXPOSE \n' + - '\n' + - '# Install Rails (and its dependencies)\n' + - 'RUN apt-get update && apt-get install -y nodejs --no-install-recommends && rm -rf /var/lib/apt/lists/*\n' + - '\n' + - '\n' + - '# see http://guides.rubyonrails.org/command_line.html#rails-dbconsole\n' + - 'RUN apt-get update && apt-get install -y mysql-client postgresql-client sqlite3 --no-install-recommends && rm -rf /var/lib/apt/lists/*\n' + - '\n' + - '# Add repository files to server\n' + - 'ADD ./ /\n' + - 'WORKDIR /\n' + - '\n' + - '# Install dependencies\n' + - 'RUN apt-get update \n' + - '\n' + - '\n' + - 'RUN bundle install\n' + - '\n' + - '# Command to start the app\n' + - 'CMD \n' + body: fs.readFileSync(__dirname + '/sourceDockerFiles/ruby').toString() }, { name: 'Python', isTemplate: true, - body: 'FROM python:\n' + - '\n' + - '# Open up ports on the server\n' + - 'EXPOSE \n' + - '\n' + - '# Install environmental dependencies\n' + - 'RUN apt-get -y -q update && apt-get install -y -q libmysqlclient-dev postgresql-server-dev-9.1\n' + - '\n' + - '# Add the repository to the /home folder\n' + - 'ADD ./ /home/\n' + - 'WORKDIR /home\n' + - '\n' + - '# Install dependencies\n' + - 'RUN pip install -r /home/requirements.txt\n' + - '\n' + - 'RUN apt-get update \n' + - '\n' + - '\n' + - '# Command to start the app\n' + - 'CMD \n' + body: fs.readFileSync(__dirname + '/sourceDockerFiles/python').toString() }, { name: 'PostgreSQL', - body: '# Full list of versions available here: https://registry.hub.docker.com/_/postgres/tags/manage/\n'+ - 'FROM postgres:9.4\n' + - '\n' + - '# Set recommended environment variables\n' + - 'ENV POSTGRES_USER postgres\n' + - 'ENV POSTGRES_PASSWORD postgres\n' + - '\n' + - '# Open port 5432 on the server\n' + - 'EXPOSE 5432\n' + body: fs.readFileSync(__dirname + '/sourceDockerFiles/postgresSql').toString() }, { name: 'MySQL', - body: 'FROM mysql:5.6\n' + -'# Set required environment variables\n' + -'ENV MYSQL_USER root\n' + -'ENV MYSQL_PASSWORD root\n' + -'ENV MYSQL_ROOT_PASSWORD root\n' + -'ENV MYSQL_DATABASE app\n\n' + -'# Open port 3306 on the server\n' + -'EXPOSE 3306\n' + body: fs.readFileSync(__dirname + '/sourceDockerFiles/mysql').toString() }, { name: 'MongoDB', body: '# Full list of versions available here: https://registry.hub.docker.com/_/mongo/tags/manage/\n'+ diff --git a/scripts/sourceDockerfiles/mysql b/scripts/sourceDockerfiles/mysql new file mode 100644 index 000000000..be7cf83fa --- /dev/null +++ b/scripts/sourceDockerfiles/mysql @@ -0,0 +1,10 @@ +FROM mysql:5.6 + +# Set required environment variables +ENV MYSQL_USER root +ENV MYSQL_PASSWORD root +ENV MYSQL_ROOT_PASSWORD root +ENV MYSQL_DATABASE app + +# Open port 3306 on the server +EXPOSE 3306 \ No newline at end of file diff --git a/scripts/sourceDockerfiles/nodejs b/scripts/sourceDockerfiles/nodejs new file mode 100644 index 000000000..04be90364 --- /dev/null +++ b/scripts/sourceDockerfiles/nodejs @@ -0,0 +1,18 @@ +# Full list of versions available here: https://registry.hub.docker.com/_/node/tags/manage/\n' + +FROM node: + +# Open up ports on the server +EXPOSE + +# Add repository files to serv +ADD ./ / +WORKDIR / + +# Install dependencies +RUN apt-get update + + +RUN npm install + +# Command to start the app +CMD \ No newline at end of file diff --git a/scripts/sourceDockerfiles/postgresSql b/scripts/sourceDockerfiles/postgresSql new file mode 100644 index 000000000..18ae76097 --- /dev/null +++ b/scripts/sourceDockerfiles/postgresSql @@ -0,0 +1,9 @@ +# Full list of versions available here: https://registry.hub.docker.com/_/postgres/tags/manage/ +FROM postgres:9.4 + +# Set recommended environment variables +ENV POSTGRES_USER postgres +ENV POSTGRES_PASSWORD postgres + +# Open port 5432 on the server +EXPOSE 5432 \ No newline at end of file diff --git a/scripts/sourceDockerfiles/python b/scripts/sourceDockerfiles/python new file mode 100644 index 000000000..e35d4bec5 --- /dev/null +++ b/scripts/sourceDockerfiles/python @@ -0,0 +1,20 @@ +FROM python: + +# Open up ports on the server +EXPOSE + +# Install environmental dependencies +RUN apt-get -y -q update && apt-get install -y -q libmysqlclient-dev postgresql-server-dev-9.1 + +# Add the repository to the /home folder +ADD ./ /home/ +WORKDIR /home + +# Install dependencies +RUN pip install -r /home/requirements.txt + +RUN apt-get update + + +# Command to start the app +CMD \ No newline at end of file diff --git a/scripts/sourceDockerfiles/rails b/scripts/sourceDockerfiles/rails new file mode 100644 index 000000000..292f2daf5 --- /dev/null +++ b/scripts/sourceDockerfiles/rails @@ -0,0 +1,30 @@ +FROM ruby: +# Open up ports on the server +EXPOSE + +# Install Rails (and its dependencies) +RUN apt-get update && apt-get install -y nodejs --no-install-recommends && rm -rf /var/lib/apt/lists/* + + +# see http://guides.rubyonrails.org/command_line.html#rails-dbconsole +RUN apt-get update && apt-get install -y mysql-client postgresql-client sqlite3 --no-install-recommends && rm -rf /var/lib/apt/lists/* + +# Specify the version of Rails to install +ENV RAILS_VERSION +RUN gem install rails --version "$RAILS_VERSION" + +# Add repository files to server +ADD ./ / +WORKDIR / + +# Install dependencies +RUN apt-get update + + +RUN bundle install + +# Setup and seed database +RUN rake db:create db:migrate + +# Command to start the app +CMD \ No newline at end of file diff --git a/scripts/sourceDockerfiles/ruby b/scripts/sourceDockerfiles/ruby new file mode 100644 index 000000000..8f5d8836d --- /dev/null +++ b/scripts/sourceDockerfiles/ruby @@ -0,0 +1,26 @@ +FROM ruby: +# Open up ports on the server +EXPOSE + +# Install Rails (and its dependencies) +RUN apt-get update && apt-get install -y nodejs --no-install-recommends && rm -rf /var/lib/apt/lists/* + + +# see http://guides.rubyonrails.org/command_line.html#rails-dbconsole +RUN apt-get update && apt-get install -y mysql-client postgresql-client sqlite3 --no-install-recommends && rm -rf /var/lib/apt/lists/* + +# Add repository files to server +ADD ./ / +WORKDIR / + +# Install dependencies +RUN apt-get update + + +RUN bundle install + +# Setup and seed database +RUN rake db:create db:migrate + +# Command to start the app +CMD \ No newline at end of file