Permalink
Browse files

Update Docker support

  • Loading branch information...
bladealslayer committed Nov 1, 2016
1 parent a806827 commit 9c067c1c0c22582cc73197ca0c205496d7c5fc92
View
@@ -1,5 +1,70 @@
.git
-tmp
log
-.sass-cache
-vendor/bundle
+.DS_Store
+
+db/*.sqlite3
+db/sphinx
+config/*.sphinx.conf
+config/database.yml
+config/config.yml
+config/session_secret
+config/gmaps_api_key.yml
+config/translation.yml
+tmp/
+doc/api
+doc/app
+public/images/listing_images
+index/
+db/development_structure.sql
+old_databases.sql
+.bundle
+.sass-cache/
+capybara*
+public/system/favicons
+public/system/images
+public/system/listing_images
+public/system/people
+public/system/cover_photos/
+public/system/logos/
+public/system/small_cover_photos/
+public/system/wide_logos/
+.loadpath
+.project
+cg.sh
+public/assets/
+app/assets/webfonts/
+app/assets/stylesheets/customizations-*
+app/assets/stylesheets/custom-style-*
+config/mangopay.pem
+log/*.log
+log/*.pid
+log/.DS_Store
+log/*.age
+log/*.db
+node_modules
+coverage/
+.idea/
+*.sock
+.vagrant
+.env
+
+# React on Rails
+npm-debug.log*
+node_modules
+client/node_modules
+
+# Generated js bundles
+/app/assets/webpack/*
+
+# Generated i18n-js bundles
+/app/assets/javascripts/i18n/*
+/client/app/i18n/*
+!/client/app/i18n/.keep
+/client/app/routes/*
+!/client/app/routes/.keep
+
+# Generated assets
+/public/webpack/*
+
+# Mocha results
+test-results.xml
View
@@ -1,26 +1,100 @@
-FROM ubuntu:14.04
+FROM ruby:2.3.1
+
MAINTAINER Sharetribe Team <team@sharetribe.com>
-RUN apt-get -yqq update
-
-# Install RVM, Ruby, and Bundler
-RUN apt-get -yqq install curl git libxml2
-RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys D39DC0E3
-RUN \curl -L https://get.rvm.io | bash -s stable
-RUN /bin/bash -l -c "rvm requirements"
-RUN /bin/bash -l -c "rvm install 2.1.8"
-RUN /bin/bash -l -c "gem install bundler --no-ri --no-rdoc"
-
-# Install deps
-RUN apt-get -yqq install build-essential mysql-client libmysqlclient-dev libxslt-dev libxml2-dev mysql-server-5.5 nodejs sphinxsearch imagemagick
-RUN /bin/bash -l -c "gem install mysql2 -v 0.2.7"
-
-# Create directory for Sharetribe
-RUN /bin/bash -l -c "mkdir -p /opt/sharetribe"
-WORKDIR /opt/sharetribe
-
-# Run Bundle install
-ADD Gemfile /opt/sharetribe/Gemfile
-ADD Gemfile.lock /opt/sharetribe/Gemfile.lock
-RUN /bin/bash -l -c "bundle install"
-
-EXPOSE 3000
+
+ENV REFRESHED_AT 2016-11-08
+
+RUN apt-get update \
+ && apt-get dist-upgrade -y
+
+#
+# Node (based on official docker node image)
+#
+
+# gpg keys listed at https://github.com/nodejs/node
+RUN set -ex \
+ && for key in \
+ 9554F04D7259F04124DE6B476D5A82AC7E37093B \
+ 94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \
+ 0034A06D9D9B0064CE8ADF6BF1747F4AD2306D93 \
+ FD3A5288F042B6850C66B31F09FE44734EB7990E \
+ 71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 \
+ DD8F2338BAE7501E3DD5AC78C273792F7D83545D \
+ B9AE9905FFD7803F25714661B63B535A4C206CA9 \
+ C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \
+ ; do \
+ gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \
+ done
+
+ENV NPM_CONFIG_LOGLEVEL info
+ENV NODE_VERSION 6.9.1
+
+RUN curl -SLO "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-x64.tar.xz" \
+ && curl -SLO "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt.asc" \
+ && gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \
+ && grep " node-v$NODE_VERSION-linux-x64.tar.xz\$" SHASUMS256.txt | sha256sum -c - \
+ && tar -xJf "node-v$NODE_VERSION-linux-x64.tar.xz" -C /usr/local --strip-components=1 \
+ && rm "node-v$NODE_VERSION-linux-x64.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt \
+ && ln -s /usr/local/bin/node /usr/local/bin/nodejs
+
+#
+# Sharetribe
+#
+
+# Install latest bundler
+RUN gem install bundler
+
+# Run as non-privileged user
+RUN useradd -m -s /bin/bash app \
+ && mkdir /opt/app /opt/app/client /opt/app/log /opt/app/tmp && chown -R app:app /opt/app
+
+WORKDIR /opt/app
+
+COPY Gemfile /opt/app
+COPY Gemfile.lock /opt/app
+
+ENV RAILS_ENV production
+
+USER app
+
+RUN bundle install --deployment --without test,development
+
+COPY package.json /opt/app/
+COPY client/package.json /opt/app/client/
+COPY client/customloaders/customfileloader /opt/app/client/customloaders/customfileloader
+
+ENV NODE_ENV production
+ENV NPM_CONFIG_LOGLEVEL error
+ENV NPM_CONFIG_PRODUCTION true
+
+RUN npm install
+
+COPY . /opt/app
+
+EXPOSE 3000
+
+CMD ["script/startup.sh"]
+
+#
+# Assets
+#
+
+# Fix ownership of directories that need to be writable
+USER root
+RUN mkdir -p \
+ app/assets/webpack \
+ public/assets \
+ public/webpack \
+ && chown -R app:app \
+ app/assets/javascripts \
+ app/assets/webpack \
+ client/app/ \
+ public/assets \
+ public/webpack
+USER app
+
+# If assets.tar.gz file exists in project root
+# assets will be extracted from there.
+# Otherwise, assets will be compiled with `rake assets:precompile`.
+# Useful for caching assets between builds.
+RUN script/prepare-assets.sh
View
@@ -0,0 +1,33 @@
+version: '2'
+services:
+ web:
+ build: .
+ mem_limit: 512m
+ environment:
+ - PASSENGER_MAX_POOL_SIZE=2
+ labels:
+ - convox.deployment.minimum=100
+ - convox.deployment.maximum=200
+ - convox.port.80.protocol=http
+ - convox.port.443.protocol=https
+ - convox.health.path=/_health
+ - convox.health.timeout=8
+ - convox.idle.timeout=60
+ ports:
+ - "80:3000"
+ - "443:3000"
+ worker:
+ build: .
+ mem_limit: 512m
+ environment:
+ - QUEUES=default,paperclip,mailers
+ - MAGICK_MAP_LIMIT=64MiB
+ - MAGICK_MEMORY_LIMIT=256MiB
+ - MAGICK_TIME_LIMIT=30
+ labels:
+ - convox.deployment.minimum=0
+ - convox.deployment.maximum=200
+ # scheduled task definitions
+ # Uncomment when deploying own installation of Sharetribe
+ #- convox.cron.test-task=0 9 * * ? bundle exec rails runner CommunityMailer.deliver_community_updates
+ command: [ "bundle", "exec", "rake", "jobs:work" ]
View
@@ -0,0 +1,22 @@
+version: '2'
+services:
+ web:
+ build: .
+ ports:
+ - "3000:3000"
+ env_file: .env
+ worker:
+ build: .
+ env_file: .env
+ environment:
+ - QUEUES=default,paperclip,mailers
+ - MAGICK_MAP_LIMIT=64MiB
+ - MAGICK_MEMORY_LIMIT=256MiB
+ - MAGICK_TIME_LIMIT=30
+ command: bundle exec rake jobs:work
+ memcached:
+ image: memcached:latest
+networks:
+ default:
+ external:
+ name: sharetribe
@@ -0,0 +1,8 @@
+# Asset customization variables. These are configuration options
+# that must be present at asset compilation stage.
+
+# Example:
+# export font_proximanovasoft_url=https://www.example.com/fonts/
+# export ss_pika_location=//assets.example.com/webfonts/ss-pika.css
+# export ss_social_location=//assets.example.com/webfonts/ss-social.css
+# export icon_pack=ss-pika
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+set -e
+
+tar cfz assets.tar.gz \
+ app/assets/javascripts/i18n \
+ app/assets/webpack \
+ client/app/i18n \
+ client/app/routes \
+ public/assets \
+ public/webpack
View
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+set -e
+
+# Use supplied assets tarball or compile assets, if it doesn't exist
+if [ -f "assets.tar.gz" ] ; then
+ tar vxfz assets.tar.gz
+else
+ # Set dummy database connection string
+ export DATABASE_URL="mysql2://user:pass@127.0.0.1/dummy"
+
+ # Edit the script/asset-variables.sh file to e.g. set font locations, icon pack, etc.
+ [ -f "script/asset-variables.sh" ] && source "script/asset-variables.sh"
+
+ secret_key_base=$(ruby -r securerandom -e "puts SecureRandom.hex(64)")
+ export secret_key_base
+
+ bundle exec rake assets:precompile
+fi
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+# Exit code is 0 (true) if assets should be rebuilt
+
+set -e
+
+COMPARE_SHA="${1-HEAD}"
+
+# Make sure cached revision exists
+[ "$(git cat-file -t "$COMPARE_SHA")" != "commit" ] && return 0
+
+# TODO consider if only ancestors should be treated as valid cache
+
+CHANGES=$(git diff --shortstat "$COMPARE_SHA" -- \
+ app/assets \
+ client \
+ package.json \
+ vendor/assets)
+
+[ -n "$CHANGES" ]
View
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+rm -f tmp/pids/server.pid
+
+exec bundle exec passenger start -p "${PORT-3000}" --max-pool-size "${PASSENGER_MAX_POOL_SIZE-1}"

0 comments on commit 9c067c1

Please sign in to comment.