Add Docker configuration

This commit is contained in:
François Turbelin
2019-05-23 23:10:54 +02:00
parent 723499332a
commit f9d72e10d5
5 changed files with 180 additions and 0 deletions

4
.dockerignore Normal file
View File

@@ -0,0 +1,4 @@
.git
.gitignore
log/*
tmp/*

57
Dockerfile Normal file
View File

@@ -0,0 +1,57 @@
FROM ubuntu:18.04
RUN apt-get update
## Rbenv & Ruby part
#Install all the requirements
RUN apt-get install -y curl git build-essential \
software-properties-common
RUN apt-get install -y zlib1g-dev libssl1.0-dev libreadline-dev \
libyaml-dev \
libffi-dev
# For newer rubies: libssl-dev libcurl4-openssl-dev
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash - && \
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
RUN apt-get update && apt-get install -y nodejs yarn
#Setup ENV variables
ENV PATH /usr/local/src/rbenv/shims:/usr/local/src/rbenv/bin:$PATH
ENV RBENV_ROOT /usr/local/src/rbenv
ENV RUBY_VERSION 2.1.5
ENV CONFIGURE_OPTS --disable-install-doc
RUN git clone https://github.com/rbenv/rbenv.git ${RBENV_ROOT} \
&& git clone https://github.com/rbenv/ruby-build.git ${RBENV_ROOT}/plugins/ruby-build \
&& ${RBENV_ROOT}/plugins/ruby-build/install.sh
RUN echo 'eval "$(rbenv init -)"' >> /etc/profile.d/rbenv.sh
RUN rbenv install $RUBY_VERSION \
&& rbenv global $RUBY_VERSION
RUN gem install bundler --version=1.17.2
# Postgres
RUN apt-get install wget
RUN sh -c "echo 'deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main' > /etc/apt/sources.list.d/pgdg.list"
RUN wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | apt-key add -
RUN apt-get update
RUN apt-get install -yqq --no-install-recommends postgresql-client-9.3 libpq-dev
# App dependencies
RUN apt-get install -yqq --no-install-recommends build-essential git-core curl zlib1g-dev libssl-dev libreadline-dev libyaml-dev libxml2-dev libxslt1-dev libcurl4-openssl-dev libffi-dev phantomjs
# System dependencies
RUN apt-get install -y wait-for-it
ENV BUNDLE_PATH /bundles
COPY . /usr/src/app/
COPY Gemfile* /usr/src/app/
WORKDIR /usr/src/app

View File

@@ -0,0 +1,64 @@
# Add application configuration variables here, as shown below.
#
# Change this, it has serious security implications.
# Minimum 30 but usually 128 characters. To obtain run 'rake secret', or faster, 'openssl rand -hex 128'
SECRET_TOKEN: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
# Time zone must match the operating system time zone in order to pass all tests.
# This string is the key for the MAPPING hash constant in ActiveSupport::TimeZone.
# Documentation including the hash: https://api.rubyonrails.org/classes/ActiveSupport/TimeZone.html
TIMEZONE: Melbourne
# Default country for dropdowns etc. See for codes: http://en.wikipedia.org/wiki/ISO_3166-1
DEFAULT_COUNTRY_CODE: AU
# Locale for translation.
LOCALE: en
# For multilingual - ENV doesn't have array so pass it as string with commas
AVAILABLE_LOCALES: en,es,en-GB
# Spree zone.
CHECKOUT_ZONE: Australia
# Find currency codes at http://en.wikipedia.org/wiki/ISO_4217.
CURRENCY: AUD
# The whenever gem can set the `MAILTO` variable for our cron jobs.
# You can define an email address to notify if any job outputs something.
# But you need a working mail server setup so that the message is delivered.
# See: config/schedule.rb
#SCHEDULE_NOTIFICATIONS: admin@example.com
# Mail settings
MAIL_HOST: 'example.com'
MAIL_DOMAIN: 'example.com'
MAIL_PORT: 25
SMTP_USERNAME: 'ofn'
SMTP_PASSWORD: 'f00d'
# Optional mail settings
# MAIL_SECURE_CONNECTION: 'TLS' # 'None' (default), 'SSL' or 'TLS'
# MAILS_FROM: hello@example.com
# MAIL_BCC: manager@example.com
# SingleSignOn login for Discourse
#
# DISCOURSE_SSO_SECRET should be a random string. It must be the same as provided to your Discourse instance.
#DISCOURSE_SSO_SECRET: ""
#
# DISCOURSE_URL must be the URL of your Discourse instance.
#DISCOURSE_URL: "https://noticeboard.openfoodnetwork.org.au"
# see: https://developers.google.com/maps/documentation/javascript/get-api-key
# GOOGLE_MAPS_API_KEY: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
# optional, see: https://www.skylight.io/oss
# SKYLIGHT_AUTHENTICATION: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
# Should be set if using Skylight, adds a link to Skylight dashboard to our footer
# SKYLIGHT_PUBLIC_DASHBOARD_URL: "https://oss.skylight.io/app/applications/xxxxxxxxxx"
# Stripe Connect details for instance account
# Find these under 'API keys' and 'Connect' in your Stripe account dashboard -> Account Settings
# Under 'Connect', the Redirect URI should be set to https://YOUR_SERVER_URL/stripe/callbacks (e.g. https://openfoodnetwork.org.uk/stripe/callbacks)
# Under 'Webhooks', you should set up a Connect endpoint pointing to https://YOUR_SERVER_URL/stripe/webhooks e.g. (https://openfoodnetwork.org.uk/stripe/webhooks)
# STRIPE_INSTANCE_SECRET_KEY: "sk_test_xxxxxx" # This can be a test key or a live key
# STRIPE_INSTANCE_PUBLISHABLE_KEY: "pk_test_xxxx" # This can be a test key or a live key
# STRIPE_CLIENT_ID: "ca_xxxx" # This can be a development ID or a production ID
# STRIPE_ENDPOINT_SECRET: "whsec_xxxx"

View File

@@ -0,0 +1,20 @@
default: &default
adapter: postgresql
encoding: utf8
pool: 5
timeout: 5000
host: db
port: 5432
#socket: /var/run/mysqld/mysqld.sock
development:
<<: *default
database: open_food_network_dev
username: ofn
password: f00d
test:
<<: *default
database: open_food_network_test
username: ofn
password: f00d

35
docker-compose.yml Normal file
View File

@@ -0,0 +1,35 @@
version: '3'
services:
db:
image: postgres:9.3
restart: always
environment:
POSTGRES_PASSWORD: f00d
POSTGRES_USER: ofn
volumes:
- 'postgres:/var/lib/postgresql/data'
web:
tty: true
stdin_open: true
build: .
ports:
- 3006:3000
volumes:
- .:/usr/src/app
- gems:/bundles
- ./config/database.docker.yml:/usr/src/app/config/database.yml
- ./config/application.docker.yml:/usr/src/app/config/application.yml
depends_on:
- db
command: >
bash -c "(bundle check || bundle install) &&
wait-for-it -t 30 db:5432 &&
bundle exec rake db:create &&
bundle exec rake ofn:dev:setup &&
rm -f tmp/pids/server.pid &&
bundle exec rails s -p 3000 -b '0.0.0.0'"
volumes:
gems:
postgres: