From c7c949eead5f7eefabd3c566911569c81c2b056f Mon Sep 17 00:00:00 2001 From: Disassembler Date: Wed, 12 Sep 2018 16:16:38 +0200 Subject: [PATCH] cc build --- build-all.sh | 1 + crisiscleanup/Dockerfile | 48 ----------------- crisiscleanup/lxcfile | 54 +++++++++++++++++++ crisiscleanup/{build.sh => setup.sh} | 0 crisiscleanup/{ => setup}/createdb.sql | 0 .../{ => setup}/etc/init.d/crisiscleanup | 0 .../srv/crisiscleanup/conf/boot.rb | 0 .../srv/crisiscleanup/conf/database.yml | 0 .../conf/environments/production.rb | 0 .../crisiscleanup/conf/initializers/devise.rb | 0 .../{ => setup}/srv/crisiscleanup/db/seeds.rb | 0 zz-extra/lxc-build | 2 +- 12 files changed, 56 insertions(+), 49 deletions(-) delete mode 100644 crisiscleanup/Dockerfile create mode 100644 crisiscleanup/lxcfile rename crisiscleanup/{build.sh => setup.sh} (100%) mode change 100755 => 100644 rename crisiscleanup/{ => setup}/createdb.sql (100%) rename crisiscleanup/{ => setup}/etc/init.d/crisiscleanup (100%) mode change 100755 => 100644 rename crisiscleanup/{ => setup}/srv/crisiscleanup/conf/boot.rb (100%) rename crisiscleanup/{ => setup}/srv/crisiscleanup/conf/database.yml (100%) rename crisiscleanup/{ => setup}/srv/crisiscleanup/conf/environments/production.rb (100%) rename crisiscleanup/{ => setup}/srv/crisiscleanup/conf/initializers/devise.rb (100%) rename crisiscleanup/{ => setup}/srv/crisiscleanup/db/seeds.rb (100%) diff --git a/build-all.sh b/build-all.sh index 799ea01..d778a52 100755 --- a/build-all.sh +++ b/build-all.sh @@ -28,6 +28,7 @@ lxc-build ${SOURCE_DIR}/basic-runtimes/tomcat.lxcfile lxc-build ${SOURCE_DIR}/activemq lxc-build ${SOURCE_DIR}/ckan lxc-build ${SOURCE_DIR}/ckan-datapusher +lxc-build ${SOURCE_DIR}/crisiscleanup lxc-build ${SOURCE_DIR}/postgres lxc-build ${SOURCE_DIR}/redis lxc-build ${SOURCE_DIR}/solr diff --git a/crisiscleanup/Dockerfile b/crisiscleanup/Dockerfile deleted file mode 100644 index 63da7fb..0000000 --- a/crisiscleanup/Dockerfile +++ /dev/null @@ -1,48 +0,0 @@ -FROM ruby -LABEL maintainer="Disassembler " - -RUN \ - # Install NodeJS runtime - apk --no-cache add nodejs - -RUN \ - # Install runtime dependencies - apk --no-cache add libpq libxml2 libxslt tzdata - -ENV RAILS_ENV production - -RUN \ - # Install build dependencies - apk --no-cache add --virtual .deps build-base git libxml2-dev libxslt-dev linux-headers npm postgresql-dev yarn zlib-dev \ - # Clone CrisisCleanup - && git clone --depth 1 https://github.com/CrisisCleanup/crisiscleanup /srv/crisiscleanup \ - # Hackfix ruby and nodejs dependency versions - && sed -i 's/2\.2\.5/2.3.6/' /srv/crisiscleanup/Gemfile \ - && sed -i 's/rdoc (4\.2\.0)/rdoc (4.3.0)/' /srv/crisiscleanup/Gemfile.lock \ - && sed -i 's/8\.2\.0/>=8.2.0/' /srv/crisiscleanup/package.json \ - # Install Ruby and NodeJS dependencies - && cd /srv/crisiscleanup \ - && bundle config build.nokogiri --use-system-libraries \ - && bundle install \ - && npm install \ - && yarn \ - # Create CrisisCleanup secret - && echo -e "production:\n secret_key_base: $(rake secret)" >/srv/crisiscleanup/config/secrets.yml \ - # Generate static resources - && rake assets:precompile \ - # Create OS user - && addgroup -S -g 8005 cc \ - && adduser -S -u 8005 -h /srv/crisiscleanup -s /bin/false -g cc -G cc cc \ - && chown -R cc:cc /srv/crisiscleanup \ - # Cleanup - && apk --no-cache del .deps \ - && find /srv/crisiscleanup -name '.git*' -exec rm -rf {} + \ - && rm -rf /usr/local/share/.cache \ - && rm -rf /root/.bundle /root/.config /root/.npm - -VOLUME ["/srv/crisiscleanup/config"] -EXPOSE 8080 - -USER cc -WORKDIR /srv/crisiscleanup -CMD ["rails", "server"] diff --git a/crisiscleanup/lxcfile b/crisiscleanup/lxcfile new file mode 100644 index 0000000..e00c3dd --- /dev/null +++ b/crisiscleanup/lxcfile @@ -0,0 +1,54 @@ +LAYER shared/alpine +LAYER shared/ruby +LAYER shared/nodejs +LAYER shared/libxml + +LAYERFIX /usr/bin/fix-apk + +ENV RAILS_ENV production + +RUN EOF + # Install runtime dependencies + apk --no-cache add libpq tzdata + + # Install build dependencies + apk --no-cache add --virtual .deps build-base git libxml2-dev libxslt-dev linux-headers npm postgresql-dev yarn zlib-dev + + # Clone CrisisCleanup + git clone --depth 1 https://github.com/CrisisCleanup/crisiscleanup /srv/crisiscleanup + + # Hackfix ruby and nodejs dependency versions + sed -i 's/2\.2\.5/2.3.6/' /srv/crisiscleanup/Gemfile + sed -i 's/rdoc (4\.2\.0)/rdoc (4.3.0)/' /srv/crisiscleanup/Gemfile.lock + sed -i 's/8\.2\.0/>=8.2.0/' /srv/crisiscleanup/package.json + + # Install Ruby and NodeJS dependencies + cd /srv/crisiscleanup + bundle config build.nokogiri --use-system-libraries + bundle install + npm install + yarn + + # Create CrisisCleanup secret + echo -e "production:\n secret_key_base: $(rake secret)" >/srv/crisiscleanup/config/secrets.yml + + # Generate static resources + rake assets:precompile + + # Create OS user + addgroup -S -g 8005 cc + adduser -S -u 8005 -h /srv/crisiscleanup -s /bin/false -g cc -G cc cc + chown -R cc:cc /srv/crisiscleanup + + # Cleanup + apk --no-cache del .deps + find /srv/crisiscleanup -name '.git*' -exec rm -rf {} + + rm -rf /usr/local/share/.cache + rm -rf /root/.bundle /root/.config /root/.npm +EOF + +VOLUME /srv/crisiscleanup/conf srv/crisiscleanup/config + +USER 8005 8005 +WORKDIR /srv/crisiscleanup +CMD rails server diff --git a/crisiscleanup/build.sh b/crisiscleanup/setup.sh old mode 100755 new mode 100644 similarity index 100% rename from crisiscleanup/build.sh rename to crisiscleanup/setup.sh diff --git a/crisiscleanup/createdb.sql b/crisiscleanup/setup/createdb.sql similarity index 100% rename from crisiscleanup/createdb.sql rename to crisiscleanup/setup/createdb.sql diff --git a/crisiscleanup/etc/init.d/crisiscleanup b/crisiscleanup/setup/etc/init.d/crisiscleanup old mode 100755 new mode 100644 similarity index 100% rename from crisiscleanup/etc/init.d/crisiscleanup rename to crisiscleanup/setup/etc/init.d/crisiscleanup diff --git a/crisiscleanup/srv/crisiscleanup/conf/boot.rb b/crisiscleanup/setup/srv/crisiscleanup/conf/boot.rb similarity index 100% rename from crisiscleanup/srv/crisiscleanup/conf/boot.rb rename to crisiscleanup/setup/srv/crisiscleanup/conf/boot.rb diff --git a/crisiscleanup/srv/crisiscleanup/conf/database.yml b/crisiscleanup/setup/srv/crisiscleanup/conf/database.yml similarity index 100% rename from crisiscleanup/srv/crisiscleanup/conf/database.yml rename to crisiscleanup/setup/srv/crisiscleanup/conf/database.yml diff --git a/crisiscleanup/srv/crisiscleanup/conf/environments/production.rb b/crisiscleanup/setup/srv/crisiscleanup/conf/environments/production.rb similarity index 100% rename from crisiscleanup/srv/crisiscleanup/conf/environments/production.rb rename to crisiscleanup/setup/srv/crisiscleanup/conf/environments/production.rb diff --git a/crisiscleanup/srv/crisiscleanup/conf/initializers/devise.rb b/crisiscleanup/setup/srv/crisiscleanup/conf/initializers/devise.rb similarity index 100% rename from crisiscleanup/srv/crisiscleanup/conf/initializers/devise.rb rename to crisiscleanup/setup/srv/crisiscleanup/conf/initializers/devise.rb diff --git a/crisiscleanup/srv/crisiscleanup/db/seeds.rb b/crisiscleanup/setup/srv/crisiscleanup/db/seeds.rb similarity index 100% rename from crisiscleanup/srv/crisiscleanup/db/seeds.rb rename to crisiscleanup/setup/srv/crisiscleanup/db/seeds.rb diff --git a/zz-extra/lxc-build b/zz-extra/lxc-build index 2bc71a5..50d2315 100755 --- a/zz-extra/lxc-build +++ b/zz-extra/lxc-build @@ -77,7 +77,7 @@ class LXCImage: if line == script_eof: script_eof = None self.run_script(script) - elif in_script: + else: script.append(line) elif line.startswith('RUN'): script = []