Merge pull request #43 from heukirne/master

add support for grunt build
This commit is contained in:
Henry Oswald 2016-05-20 17:15:39 +01:00
commit d1fd00ae7a
5 changed files with 143 additions and 20 deletions

View file

@ -1,5 +1,7 @@
FROM phusion/baseimage:0.9.16 FROM phusion/baseimage:0.9.16
ENV baseDir .
# Install Node.js and Grunt # Install Node.js and Grunt
RUN curl -sL https://deb.nodesource.com/setup | sudo bash - RUN curl -sL https://deb.nodesource.com/setup | sudo bash -
RUN apt-get install -y build-essential nodejs RUN apt-get install -y build-essential nodejs
@ -14,15 +16,22 @@ RUN adduser --system --group --home /var/www/sharelatex --no-create-home sharela
# Install ShareLaTeX # Install ShareLaTeX
RUN apt-get install -y git python RUN apt-get install -y git python
RUN git clone -b release https://github.com/sharelatex/sharelatex.git /var/www/sharelatex RUN git clone https://github.com/sharelatex/sharelatex.git /var/www/sharelatex
RUN cd /var/www/sharelatex && git pull origin release
# zlib1g-dev is needed to compile the synctex binaries in the CLSI during `grunt install`. # zlib1g-dev is needed to compile the synctex binaries in the CLSI during `grunt install`.
RUN apt-get install -y zlib1g-dev RUN apt-get install -y zlib1g-dev
ADD ${baseDir}/services.js /var/www/sharelatex/config/services.js
ADD ${baseDir}/package.json /var/www/package.json
ADD ${baseDir}/git-revision.js /var/www/git-revision.js
RUN cd /var/www && npm install
RUN cd /var/www/sharelatex; \ RUN cd /var/www/sharelatex; \
npm install; \ npm install; \
grunt install; grunt install;
RUN cd /var/www && node git-revision > revisions.txt
# Minify js assets # Minify js assets
RUN cd /var/www/sharelatex/web; \ RUN cd /var/www/sharelatex/web; \
@ -32,11 +41,11 @@ RUN cd /var/www/sharelatex/web; \
run apt-get update run apt-get update
RUN apt-get install -y nginx; RUN apt-get install -y nginx;
RUN rm /etc/nginx/sites-enabled/default RUN rm /etc/nginx/sites-enabled/default
ADD nginx/nginx.conf /etc/nginx/nginx.conf ADD ${baseDir}/nginx/nginx.conf /etc/nginx/nginx.conf
ADD nginx/sharelatex.conf /etc/nginx/sites-enabled/sharelatex.conf ADD ${baseDir}/nginx/sharelatex.conf /etc/nginx/sites-enabled/sharelatex.conf
RUN mkdir /etc/service/nginx RUN mkdir /etc/service/nginx
ADD runit/nginx.sh /etc/service/nginx/run ADD ${baseDir}/runit/nginx.sh /etc/service/nginx/run
# Set up ShareLaTeX services to run automatically on boot # Set up ShareLaTeX services to run automatically on boot
RUN mkdir /etc/service/chat-sharelatex; \ RUN mkdir /etc/service/chat-sharelatex; \
@ -50,16 +59,16 @@ RUN mkdir /etc/service/chat-sharelatex; \
mkdir /etc/service/track-changes-sharelatex; \ mkdir /etc/service/track-changes-sharelatex; \
mkdir /etc/service/web-sharelatex; mkdir /etc/service/web-sharelatex;
ADD runit/chat-sharelatex.sh /etc/service/chat-sharelatex/run ADD ${baseDir}/runit/chat-sharelatex.sh /etc/service/chat-sharelatex/run
ADD runit/clsi-sharelatex.sh /etc/service/clsi-sharelatex/run ADD ${baseDir}/runit/clsi-sharelatex.sh /etc/service/clsi-sharelatex/run
ADD runit/docstore-sharelatex.sh /etc/service/docstore-sharelatex/run ADD ${baseDir}/runit/docstore-sharelatex.sh /etc/service/docstore-sharelatex/run
ADD runit/document-updater-sharelatex.sh /etc/service/document-updater-sharelatex/run ADD ${baseDir}/runit/document-updater-sharelatex.sh /etc/service/document-updater-sharelatex/run
ADD runit/filestore-sharelatex.sh /etc/service/filestore-sharelatex/run ADD ${baseDir}/runit/filestore-sharelatex.sh /etc/service/filestore-sharelatex/run
ADD runit/real-time-sharelatex.sh /etc/service/real-time-sharelatex/run ADD ${baseDir}/runit/real-time-sharelatex.sh /etc/service/real-time-sharelatex/run
ADD runit/spelling-sharelatex.sh /etc/service/spelling-sharelatex/run ADD ${baseDir}/runit/spelling-sharelatex.sh /etc/service/spelling-sharelatex/run
ADD runit/tags-sharelatex.sh /etc/service/tags-sharelatex/run ADD ${baseDir}/runit/tags-sharelatex.sh /etc/service/tags-sharelatex/run
ADD runit/track-changes-sharelatex.sh /etc/service/track-changes-sharelatex/run ADD ${baseDir}/runit/track-changes-sharelatex.sh /etc/service/track-changes-sharelatex/run
ADD runit/web-sharelatex.sh /etc/service/web-sharelatex/run ADD ${baseDir}/runit/web-sharelatex.sh /etc/service/web-sharelatex/run
# Install TexLive # Install TexLive
RUN apt-get install -y wget RUN apt-get install -y wget
@ -86,14 +95,14 @@ RUN apt-get install -y unzip
RUN apt-get install -y imagemagick optipng RUN apt-get install -y imagemagick optipng
# phusion/baseimage init script # phusion/baseimage init script
ADD 00_regen_sharelatex_secrets.sh /etc/my_init.d/00_regen_sharelatex_secrets.sh ADD ${baseDir}/00_regen_sharelatex_secrets.sh /etc/my_init.d/00_regen_sharelatex_secrets.sh
ADD 00_make_sharelatex_data_dirs.sh /etc/my_init.d/00_make_sharelatex_data_dirs.sh ADD ${baseDir}/00_make_sharelatex_data_dirs.sh /etc/my_init.d/00_make_sharelatex_data_dirs.sh
ADD 00_set_docker_host_ipaddress.sh /etc/my_init.d/00_set_docker_host_ipaddress.sh ADD ${baseDir}/00_set_docker_host_ipaddress.sh /etc/my_init.d/00_set_docker_host_ipaddress.sh
ADD 99_migrate.sh /etc/my_init.d/99_migrate.sh ADD ${baseDir}/99_migrate.sh /etc/my_init.d/99_migrate.sh
# Install ShareLaTeX settings file # Install ShareLaTeX settings file
RUN mkdir /etc/sharelatex RUN mkdir /etc/sharelatex
ADD settings.coffee /etc/sharelatex/settings.coffee ADD ${baseDir}/settings.coffee /etc/sharelatex/settings.coffee
ENV SHARELATEX_CONFIG /etc/sharelatex/settings.coffee ENV SHARELATEX_CONFIG /etc/sharelatex/settings.coffee
EXPOSE 80 EXPOSE 80

View file

@ -0,0 +1,38 @@
services = require('./services')
module.exports = (grunt) ->
tag = grunt.option("tag") or 'latest'
repos = []
for service in services
url = service.repo.split('/')
owner = url[3]
repo = url[4].replace('.git','')
repos.push "/repos/#{owner}/#{repo}/git/refs/heads/#{service.version}"
grunt.initConfig
docker_io:
default_options:
options:
dockerFileLocation: '.'
buildName: 'sharelatex'
tag: grunt.option('tag') or 'latest'
push: grunt.option('push') or false
force: true
github:
combinedRevisions:
options:
#oAuth:
# access_token: ''
concat: true
src: repos
dest: 'version/' + tag + '.json'
grunt.loadNpmTasks 'grunt-docker-io'
grunt.loadNpmTasks 'grunt-github-api'
grunt.registerTask 'build', ['docker_io', 'github']
grunt.registerTask 'gitrev', ['github']
grunt.registerTask 'default', ['build']

22
server-ce/git-revision.js Normal file
View file

@ -0,0 +1,22 @@
var simple = require('simple-git');
var services = require('./sharelatex/config/services');
const fs = require('fs');
function print_latest(repoDir) {
git = simple(repoDir);
opt = [];
opt['max-count'] = 1;
git.log(opt, function(err, log) {
if (!err) {
console.log(repoDir + ',' + log.latest.hash);
}
})
}
for (id in services) {
service = services[id];
dirPath = __dirname + '/sharelatex/'+service.name;
if (fs.existsSync(dirPath)) {
print_latest(dirPath);
}
}

11
server-ce/package.json Normal file
View file

@ -0,0 +1,11 @@
{
"name": "none",
"author": "none",
"description": "none",
"dependencies": {
"grunt": "^0.4.5",
"grunt-docker-io": "^0.7.0",
"simple-git": "^1.32.1",
"grunt-github-api": "^0.2.3"
}
}

43
server-ce/services.js Normal file
View file

@ -0,0 +1,43 @@
module.exports =
[{
name: "web",
repo: "https://github.com/sharelatex/web-sharelatex.git",
version: "master"
}, {
name: "real-time",
repo: "https://github.com/sharelatex/real-time-sharelatex.git",
version: "master"
}, {
name: "document-updater",
repo: "https://github.com/sharelatex/document-updater-sharelatex.git",
version: "master"
}, {
name: "clsi",
repo: "https://github.com/sharelatex/clsi-sharelatex.git",
version: "master"
}, {
name: "filestore",
repo: "https://github.com/sharelatex/filestore-sharelatex.git",
version: "master"
}, {
name: "track-changes",
repo: "https://github.com/sharelatex/track-changes-sharelatex.git",
version: "master"
}, {
name: "docstore",
repo: "https://github.com/sharelatex/docstore-sharelatex.git",
version: "master"
}, {
name: "chat",
repo: "https://github.com/sharelatex/chat-sharelatex.git",
version: "master"
}, {
name: "tags",
repo: "https://github.com/sharelatex/tags-sharelatex.git",
version: "master"
}, {
name: "spelling",
repo: "https://github.com/sharelatex/spelling-sharelatex.git",
version: "master"
}]