From f9d72e10d5e1f99e250ca404b8dd0e3865d5aaa4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Turbelin?= Date: Thu, 23 May 2019 23:10:54 +0200 Subject: [PATCH 01/24] Add Docker configuration --- .dockerignore | 4 +++ Dockerfile | 57 +++++++++++++++++++++++++++++++ config/application.docker.yml | 64 +++++++++++++++++++++++++++++++++++ config/database.docker.yml | 20 +++++++++++ docker-compose.yml | 35 +++++++++++++++++++ 5 files changed, 180 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 config/application.docker.yml create mode 100644 config/database.docker.yml create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000..fe7cd13957 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +.git +.gitignore +log/* +tmp/* diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..37567efd8e --- /dev/null +++ b/Dockerfile @@ -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 diff --git a/config/application.docker.yml b/config/application.docker.yml new file mode 100644 index 0000000000..27710fbbc4 --- /dev/null +++ b/config/application.docker.yml @@ -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" diff --git a/config/database.docker.yml b/config/database.docker.yml new file mode 100644 index 0000000000..7ac1cede2e --- /dev/null +++ b/config/database.docker.yml @@ -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 diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000000..abc400c5e6 --- /dev/null +++ b/docker-compose.yml @@ -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: From 9df5d78f27c9bcd9f03b38cc4b591a76b470f8da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Turbelin?= Date: Thu, 23 May 2019 23:13:13 +0200 Subject: [PATCH 02/24] Add a Rake task in order to setup dev env --- lib/tasks/dev.rake | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/tasks/dev.rake b/lib/tasks/dev.rake index 4677a1786c..3b4823d3ea 100644 --- a/lib/tasks/dev.rake +++ b/lib/tasks/dev.rake @@ -1,5 +1,18 @@ namespace :ofn do namespace :dev do + desc 'Setup dev environment' + task setup: :environment do + p '== Entering setup' + + unless Spree::User.table_exists? && Spree::User.count + p '== Purge & Load sample data' + Rake::Task['db:schema:load'].invoke + end + + p '== Migrate' + Rake::Task['db:migrate'].invoke + end + desc 'load sample data' task load_sample_data: :environment do require_relative '../../spec/factories' From b4fe44510bdda8e3125934da4ca572ccc001ea98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Turbelin?= Date: Thu, 30 May 2019 10:55:14 +0200 Subject: [PATCH 03/24] Tune up the Rake task --- docker-compose.yml | 2 +- lib/tasks/dev.rake | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index abc400c5e6..756131215c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,7 +14,7 @@ services: stdin_open: true build: . ports: - - 3006:3000 + - 3000:3000 volumes: - .:/usr/src/app - gems:/bundles diff --git a/lib/tasks/dev.rake b/lib/tasks/dev.rake index 3b4823d3ea..cffda24803 100644 --- a/lib/tasks/dev.rake +++ b/lib/tasks/dev.rake @@ -3,10 +3,18 @@ namespace :ofn do desc 'Setup dev environment' task setup: :environment do p '== Entering setup' + # NOTE: Could be helpful to drop and create again the db here + #Rake::Task['db:drop'].invoke + #Rake::Task['db:create'].invoke unless Spree::User.table_exists? && Spree::User.count - p '== Purge & Load sample data' + p '== Load data schema' Rake::Task['db:schema:load'].invoke + + # TODO: Integrate the tasks loading data + # Issue to reach stdin while creating Admin account + #Rake::Task['db:seed'].invoke + #Rake::Task['ofn:sample_data'].invoke end p '== Migrate' From e5d4b216ba7826c3d4183a3cf90be9f136028d3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Turbelin?= Date: Thu, 30 May 2019 10:55:44 +0200 Subject: [PATCH 04/24] Add DOCKER.md file as documentation --- DOCKER.md | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 DOCKER.md diff --git a/DOCKER.md b/DOCKER.md new file mode 100644 index 0000000000..3c038c9ca5 --- /dev/null +++ b/DOCKER.md @@ -0,0 +1,66 @@ +### Docker + +It is possible to setup the OpenFoodnetwork app easily with Docker and Docker Compose. +The objective is to spare configuration time, in order to help people testing the app and contribute to it. +It can also be use as documentation. It is not perfect but it is used in many other projects and many devs are used to it nowadays. + +### Install Docker + +Please check the documentation here, https://docs.docker.com/install/ to install Docker. + +For Docker Compose, information are here: https://docs.docker.com/compose/install/. + +Better to have at least 2GB free on your laptop in order to download images and create containers for OpenFoodNetwork app. + + +### Use Docker with OpenFoodNetwork + +Open a terminal with a shell. + +Clone the repository: + + git clone git@github.com:openfoodfoundation/openfoodnetwork.git + +Go at the root of the app: + + cd openfoodnetwork + +Download the Docker images and build the containers: + + docker-compose build + +Run the app: + + docker-compose up + +Check the app in the browser at http:://localhost:3000. + +You will then get the trace of the containers in the terminal. You can stop the containers using Ctrl-C in the terminal. + + +When you run it for the first time, you will need to seed it with some sample data and this is not yet automated. When your containers are running, you need to do this: + +Connect to the container containing the app with an interactive terminal: + + docker exec -it openfoodnetwork_web_1 bash + +Load the seeds from Spree: + + bundle exec rake db:seed + +Load thre sample data from OpenFoodNetwork: + + bundle exec rake ofn:sample_data + +Exit and stop the container: + + exit + +You can then relaunch the app, and check that you have data. + + +### Notes + +- It was not possible to integrate the seeding part directly because we need the input of the user and Docker Compose was not allowing it. Need to fix this. + +- Check the code in the `ofn:dev:setup` Rake task for more details. \ No newline at end of file From c5addb8c1d306cfef68f8101f52a3707b60c6018 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Turbelin?= Date: Thu, 30 May 2019 11:28:41 +0200 Subject: [PATCH 05/24] Fix comment spacings, gloupsss --- lib/tasks/dev.rake | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/tasks/dev.rake b/lib/tasks/dev.rake index cffda24803..7d8e088239 100644 --- a/lib/tasks/dev.rake +++ b/lib/tasks/dev.rake @@ -4,8 +4,8 @@ namespace :ofn do task setup: :environment do p '== Entering setup' # NOTE: Could be helpful to drop and create again the db here - #Rake::Task['db:drop'].invoke - #Rake::Task['db:create'].invoke + # Rake::Task['db:drop'].invoke + # Rake::Task['db:create'].invoke unless Spree::User.table_exists? && Spree::User.count p '== Load data schema' @@ -13,8 +13,8 @@ namespace :ofn do # TODO: Integrate the tasks loading data # Issue to reach stdin while creating Admin account - #Rake::Task['db:seed'].invoke - #Rake::Task['ofn:sample_data'].invoke + # Rake::Task['db:seed'].invoke + # Rake::Task['ofn:sample_data'].invoke end p '== Migrate' From 745505387921281ff67ef76605ed254f422e5f42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Turbelin?= Date: Fri, 31 May 2019 09:32:52 +0200 Subject: [PATCH 06/24] Update DOCKER.md file --- DOCKER.md | 48 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/DOCKER.md b/DOCKER.md index 3c038c9ca5..e3d0c0a642 100644 --- a/DOCKER.md +++ b/DOCKER.md @@ -1,6 +1,6 @@ ### Docker -It is possible to setup the OpenFoodnetwork app easily with Docker and Docker Compose. +It is possible to setup the Open Food Network app easily with Docker and Docker Compose. The objective is to spare configuration time, in order to help people testing the app and contribute to it. It can also be use as documentation. It is not perfect but it is used in many other projects and many devs are used to it nowadays. @@ -10,51 +10,67 @@ Please check the documentation here, https://docs.docker.com/install/ to install For Docker Compose, information are here: https://docs.docker.com/compose/install/. -Better to have at least 2GB free on your laptop in order to download images and create containers for OpenFoodNetwork app. +Better to have at least 2GB free on your laptop in order to download images and create containers for Open Food Network app. -### Use Docker with OpenFoodNetwork +### Use Docker with Open Food Network Open a terminal with a shell. Clone the repository: - git clone git@github.com:openfoodfoundation/openfoodnetwork.git +```sh +$ git clone git@github.com:openfoodfoundation/openfoodnetwork.git +``` Go at the root of the app: - cd openfoodnetwork +```sh +$ cd openfoodnetwork +``` Download the Docker images and build the containers: - docker-compose build +```sh +$ docker-compose build +``` -Run the app: +Run the app with all the required containers: - docker-compose up +```sh +$ docker-compose up +``` -Check the app in the browser at http:://localhost:3000. +Check the app in the browser at `http:://localhost:3000`. You will then get the trace of the containers in the terminal. You can stop the containers using Ctrl-C in the terminal. -When you run it for the first time, you will need to seed it with some sample data and this is not yet automated. When your containers are running, you need to do this: +When you run it for the first time, you will need to seed it with some sample data and this is not yet automated. When your app is running, you need to do this: Connect to the container containing the app with an interactive terminal: - docker exec -it openfoodnetwork_web_1 bash +```sh +$ docker exec -it openfoodnetwork_web_1 bash +``` Load the seeds from Spree: - bundle exec rake db:seed +```sh +$ bundle exec rake db:seed +``` -Load thre sample data from OpenFoodNetwork: +Load thre sample data from Open Food Network: - bundle exec rake ofn:sample_data +```sh +$ bundle exec rake ofn:sample_data +``` Exit and stop the container: - exit +```sh +$ exit +``` You can then relaunch the app, and check that you have data. @@ -63,4 +79,4 @@ You can then relaunch the app, and check that you have data. - It was not possible to integrate the seeding part directly because we need the input of the user and Docker Compose was not allowing it. Need to fix this. -- Check the code in the `ofn:dev:setup` Rake task for more details. \ No newline at end of file +- Check the code in the `ofn:dev:setup` Rake task for more details. From 75267268d7314526d0c84b656d319895f031ee4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Turbelin?= Date: Thu, 6 Jun 2019 07:05:13 +0200 Subject: [PATCH 07/24] Update Postgres to 9.5 --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 756131215c..8eec10ffc4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,7 +2,7 @@ version: '3' services: db: - image: postgres:9.3 + image: postgres:9.5 restart: always environment: POSTGRES_PASSWORD: f00d From 4e41a73c4f951253159b6812707d24bf8d1a68a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Turbelin?= Date: Thu, 6 Jun 2019 07:05:30 +0200 Subject: [PATCH 08/24] Enhance Dockerfile --- Dockerfile | 51 +++++++++++++-------------------------------------- 1 file changed, 13 insertions(+), 38 deletions(-) diff --git a/Dockerfile b/Dockerfile index 37567efd8e..5791eed402 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,20 +1,7 @@ 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 +RUN apt-get update && apt-get install -y curl git build-essential software-properties-common wget zlib1g-dev libssl1.0-dev libreadline-dev libyaml-dev libffi-dev libxml2-dev libxslt1-dev phantomjs wait-for-it #Setup ENV variables ENV PATH /usr/local/src/rbenv/shims:/usr/local/src/rbenv/bin:$PATH @@ -22,32 +9,20 @@ 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 - +# Rbenv & Ruby part +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 && \ + echo 'eval "$(rbenv init -)"' >> /etc/profile.d/rbenv.sh && \ + rbenv install $RUBY_VERSION && \ + rbenv global $RUBY_VERSION && \ + 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 - +RUN sh -c "echo 'deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main' > /etc/apt/sources.list.d/pgdg.list" && \ + wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | apt-key add - && \ + apt-get update && \ + apt-get install -yqq --no-install-recommends postgresql-client-9.5 libpq-dev ENV BUNDLE_PATH /bundles From 9c45444ea6c9d3f995d29a1bbf6dab5d888f1c92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Turbelin?= Date: Thu, 6 Jun 2019 07:13:58 +0200 Subject: [PATCH 09/24] Clean database.docker.yml file --- config/database.docker.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/config/database.docker.yml b/config/database.docker.yml index 7ac1cede2e..9ef24edfd3 100644 --- a/config/database.docker.yml +++ b/config/database.docker.yml @@ -5,7 +5,6 @@ default: &default timeout: 5000 host: db port: 5432 - #socket: /var/run/mysqld/mysqld.sock development: <<: *default From 5712f676737fa69614ab62287976aec455ad1903 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Fri, 14 Jun 2019 23:39:50 +0100 Subject: [PATCH 10/24] Remove phantomjs from dependencies --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 5791eed402..32388fafd9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ FROM ubuntu:18.04 #Install all the requirements -RUN apt-get update && apt-get install -y curl git build-essential software-properties-common wget zlib1g-dev libssl1.0-dev libreadline-dev libyaml-dev libffi-dev libxml2-dev libxslt1-dev phantomjs wait-for-it +RUN apt-get update && apt-get install -y curl git build-essential software-properties-common wget zlib1g-dev libssl1.0-dev libreadline-dev libyaml-dev libffi-dev libxml2-dev libxslt1-dev wait-for-it #Setup ENV variables ENV PATH /usr/local/src/rbenv/shims:/usr/local/src/rbenv/bin:$PATH From 64d6ae445b2a1cbbafcd6f45e0e39152c7429009 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Fri, 14 Jun 2019 23:40:38 +0100 Subject: [PATCH 11/24] Change postgres repo from `precise` to `bionic` --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 32388fafd9..34520850f1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,7 +19,7 @@ RUN git clone https://github.com/rbenv/rbenv.git ${RBENV_ROOT} && \ gem install bundler --version=1.17.2 # Postgres -RUN sh -c "echo 'deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main' > /etc/apt/sources.list.d/pgdg.list" && \ +RUN sh -c "echo 'deb http://apt.postgresql.org/pub/repos/apt/ bionic-pgdg main' > /etc/apt/sources.list.d/pgdg.list" && \ wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | apt-key add - && \ apt-get update && \ apt-get install -yqq --no-install-recommends postgresql-client-9.5 libpq-dev From 53a0f70aa04547a15c353813d1fad0da58f0058d Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Fri, 14 Jun 2019 23:56:12 +0100 Subject: [PATCH 12/24] Add default login details via ENV vars --- docker-compose.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index 8eec10ffc4..344aa376e8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -22,6 +22,9 @@ services: - ./config/application.docker.yml:/usr/src/app/config/application.yml depends_on: - db + environment: + ADMIN_EMAIL: ofn@example.com + ADMIN_PASSWORD: ofn123 command: > bash -c "(bundle check || bundle install) && wait-for-it -t 30 db:5432 && From 60e67ae1a413c504880046c74cafb90cf824d1a3 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sat, 15 Jun 2019 00:03:27 +0100 Subject: [PATCH 13/24] Run all setup steps on startup It's a bit dirty, but it works :) --- docker-compose.yml | 3 +-- lib/tasks/dev.rake | 21 --------------------- 2 files changed, 1 insertion(+), 23 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 344aa376e8..32c7e52a63 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -28,8 +28,7 @@ services: 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 && + bundle exec rake db:setup db:test:prepare ofn:sample_data || true && rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'" diff --git a/lib/tasks/dev.rake b/lib/tasks/dev.rake index 7d8e088239..4677a1786c 100644 --- a/lib/tasks/dev.rake +++ b/lib/tasks/dev.rake @@ -1,26 +1,5 @@ namespace :ofn do namespace :dev do - desc 'Setup dev environment' - task setup: :environment do - p '== Entering setup' - # NOTE: Could be helpful to drop and create again the db here - # Rake::Task['db:drop'].invoke - # Rake::Task['db:create'].invoke - - unless Spree::User.table_exists? && Spree::User.count - p '== Load data schema' - Rake::Task['db:schema:load'].invoke - - # TODO: Integrate the tasks loading data - # Issue to reach stdin while creating Admin account - # Rake::Task['db:seed'].invoke - # Rake::Task['ofn:sample_data'].invoke - end - - p '== Migrate' - Rake::Task['db:migrate'].invoke - end - desc 'load sample data' task load_sample_data: :environment do require_relative '../../spec/factories' From e893197c491ace5f1e434de05ef18f2c80c1ca7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Turbelin?= Date: Sun, 23 Jun 2019 13:23:24 +0200 Subject: [PATCH 14/24] Use example files instead of extra Docker ones --- ...ion.docker.yml => application.example.yml} | 0 config/database.docker.yml | 19 ----------- config/database.yml | 34 ++++++------------- docker-compose.yml | 4 +-- 4 files changed, 12 insertions(+), 45 deletions(-) rename config/{application.docker.yml => application.example.yml} (100%) delete mode 100644 config/database.docker.yml diff --git a/config/application.docker.yml b/config/application.example.yml similarity index 100% rename from config/application.docker.yml rename to config/application.example.yml diff --git a/config/database.docker.yml b/config/database.docker.yml deleted file mode 100644 index 9ef24edfd3..0000000000 --- a/config/database.docker.yml +++ /dev/null @@ -1,19 +0,0 @@ -default: &default - adapter: postgresql - encoding: utf8 - pool: 5 - timeout: 5000 - host: db - port: 5432 - -development: - <<: *default - database: open_food_network_dev - username: ofn - password: f00d - -test: - <<: *default - database: open_food_network_test - username: ofn - password: f00d diff --git a/config/database.yml b/config/database.yml index d313dd74e4..9ef24edfd3 100644 --- a/config/database.yml +++ b/config/database.yml @@ -1,33 +1,19 @@ -development: +default: &default adapter: postgresql - encoding: unicode - database: open_food_network_dev + encoding: utf8 pool: 5 - host: localhost + timeout: 5000 + host: db + port: 5432 + +development: + <<: *default + database: open_food_network_dev username: ofn password: f00d test: - adapter: postgresql - encoding: unicode + <<: *default database: open_food_network_test - pool: 5 - host: localhost - username: ofn - password: f00d - -production: - adapter: postgresql - encoding: unicode - database: open_food_network_prod - pool: 5 - username: ofn - password: f00d - -staging: - adapter: postgresql - encoding: unicode - database: open_food_network_prod - pool: 5 username: ofn password: f00d diff --git a/docker-compose.yml b/docker-compose.yml index 32c7e52a63..b0825ded79 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -18,8 +18,8 @@ services: 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 + - ./config/database.yml:/usr/src/app/config/database.yml + - ./config/application.example.yml:/usr/src/app/config/application.yml depends_on: - db environment: From 79ec3d5a3ff45a740893e4ee191af9ce0cb41722 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Turbelin?= Date: Sun, 23 Jun 2019 13:24:34 +0200 Subject: [PATCH 15/24] Remove extra copy on Docker file --- Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 34520850f1..300ddfc889 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,6 +27,5 @@ RUN sh -c "echo 'deb http://apt.postgresql.org/pub/repos/apt/ bionic-pgdg main' ENV BUNDLE_PATH /bundles COPY . /usr/src/app/ -COPY Gemfile* /usr/src/app/ WORKDIR /usr/src/app From 5dcf456c90c97d3113ce0e0f843a5365f7f069d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Turbelin?= Date: Sun, 23 Jun 2019 13:25:10 +0200 Subject: [PATCH 16/24] Remove old Rake task for sample data --- lib/tasks/dev.rake | 305 --------------------------------------------- 1 file changed, 305 deletions(-) delete mode 100644 lib/tasks/dev.rake diff --git a/lib/tasks/dev.rake b/lib/tasks/dev.rake deleted file mode 100644 index 4677a1786c..0000000000 --- a/lib/tasks/dev.rake +++ /dev/null @@ -1,305 +0,0 @@ -namespace :ofn do - namespace :dev do - desc 'load sample data' - task load_sample_data: :environment do - require_relative '../../spec/factories' - task_name = "openfoodnetwork:dev:load_sample_data" - - country = Spree::Country.find_by_iso(ENV.fetch('DEFAULT_COUNTRY_CODE')) - state = country.states.first - - # -- Shipping / payment information - unless Spree::Zone.find_by_name 'Australia' - puts "[#{task_name}] Seeding shipping / payment information" - - zone = FactoryBot.create(:zone, name: 'Australia', zone_members: []) - Spree::ZoneMember.create(zone: zone, zoneable: country) - address = FactoryBot.create( - :address, - address1: "15/1 Ballantyne Street", - zipcode: "3153", - city: "Thornbury", - country: country, - state: state - ) - enterprise = FactoryBot.create(:enterprise, address: address) - - FactoryBot.create(:shipping_method, zone: zone, distributors: [enterprise]) - end - - # -- Taxonomies - unless Spree::Taxonomy.find_by_name 'Products' - puts "[#{task_name}] Seeding taxonomies" - taxonomy = Spree::Taxonomy.find_by_name('Products') || FactoryBot.create(:taxonomy, - name: 'Products') - taxonomy_root = taxonomy.root - - taxons = ['Vegetables', 'Fruit', 'Oils', 'Preserves and Sauces', 'Dairy', 'Meat and Fish'] - taxons.each do |taxon_name| - FactoryBot.create(:taxon, - name: taxon_name, - parent_id: taxonomy_root.id, - taxonomy_id: taxonomy.id) - end - end - - # -- Addresses - unless Spree::Address.find_by_zipcode "3160" - puts "[#{task_name}] Seeding addresses" - - FactoryBot.create(:address, - address1: "25 Myrtle Street", - zipcode: "3153", - city: "Bayswater", - country: country, - state: state) - FactoryBot.create(:address, - address1: "6 Rollings Road", - zipcode: "3156", - city: "Upper Ferntree Gully", - country: country, - state: state) - FactoryBot.create(:address, - address1: "72 Lake Road", - zipcode: "3130", - city: "Blackburn", - country: country, - state: state) - FactoryBot.create(:address, - address1: "7 Verbena Street", - zipcode: "3195", - city: "Mordialloc", - country: country, - state: state) - FactoryBot.create(:address, - address1: "20 Galvin Street", - zipcode: "3018", - city: "Altona", - country: country, - state: state) - FactoryBot.create(:address, - address1: "59 Websters Road", - zipcode: "3106", - city: "Templestowe", - country: country, - state: state) - FactoryBot.create(:address, - address1: "17 Torresdale Drive", - zipcode: "3155", - city: "Boronia", - country: country, - state: state) - FactoryBot.create(:address, - address1: "21 Robina CRT", - zipcode: "3764", - city: "Kilmore", - country: country, - state: state) - FactoryBot.create(:address, - address1: "25 Kendall Street", - zipcode: "3134", - city: "Ringwood", - country: country, - state: state) - FactoryBot.create(:address, - address1: "2 Mines Road", - zipcode: "3135", - city: "Ringwood East", - country: country, - state: state) - FactoryBot.create(:address, - address1: "183 Millers Road", - zipcode: "3025", - city: "Altona North", - country: country, - state: state) - FactoryBot.create(:address, - address1: "310 Pascoe Vale Road", - zipcode: "3040", - city: "Essendon", - country: country, - state: state) - FactoryBot.create(:address, - address1: "6 Martin Street", - zipcode: "3160", - city: "Belgrave", - country: country, - state: state) - end - - # -- Enterprises - if Enterprise.count < 2 - puts "[#{task_name}] Seeding enterprises" - - 3.times do - FactoryBot.create(:supplier_enterprise, - address: Spree::Address.find_by_zipcode("3160")) - end - - FactoryBot.create(:distributor_enterprise, - name: "Green Grass", - address: Spree::Address.find_by_zipcode("3153")) - FactoryBot.create(:distributor_enterprise, - name: "AusFarmers United", - address: Spree::Address.find_by_zipcode("3156")) - FactoryBot.create(:distributor_enterprise, - name: "Blackburn FreeGrossers", - address: Spree::Address.find_by_zipcode("3130")) - FactoryBot.create(:distributor_enterprise, - name: "MegaFoods", - address: Spree::Address.find_by_zipcode("3195")) - FactoryBot.create(:distributor_enterprise, - name: "Eco Butchers", - address: Spree::Address.find_by_zipcode("3018")) - FactoryBot.create(:distributor_enterprise, - name: "Western Wines", - address: Spree::Address.find_by_zipcode("3106")) - FactoryBot.create(:distributor_enterprise, - name: "QuickFresh", - address: Spree::Address.find_by_zipcode("3155")) - FactoryBot.create(:distributor_enterprise, - name: "Fooderers", - address: Spree::Address.find_by_zipcode("3764")) - FactoryBot.create(:distributor_enterprise, - name: "Food Local", - address: Spree::Address.find_by_zipcode("3134")) - FactoryBot.create(:distributor_enterprise, - name: "Green Food Trading Corporation", - address: Spree::Address.find_by_zipcode("3135")) - FactoryBot.create(:distributor_enterprise, - name: "Better Food", - address: Spree::Address.find_by_zipcode("3025")) - FactoryBot.create(:distributor_enterprise, - name: "Gippsland Poultry", - address: Spree::Address.find_by_zipcode("3040")) - end - - # -- Enterprise users - if Spree::User.count < 2 - puts "[#{task_name}] Seeding enterprise users" - - pw = "spree123" - - u = FactoryBot.create(:user, - email: "sup@example.com", - password: pw, - password_confirmation: pw) - u.enterprises << Enterprise.is_primary_producer.first - u.enterprises << Enterprise.is_primary_producer.second - - user_enterprises = u.enterprise_roles.map{ |er| er.enterprise.name }.join(", ") - puts " Supplier User created: #{u.email}/#{pw} (" + user_enterprises + ")" - - u = FactoryBot.create(:user, - email: "dist@example.com", - password: pw, - password_confirmation: pw) - u.enterprises << Enterprise.is_distributor.first - u.enterprises << Enterprise.is_distributor.second - user_enterprises = u.enterprise_roles.map{ |er| er.enterprise.name }.join(", ") - puts " Distributor User created: #{u.email}/#{pw} (" + user_enterprises + ")" - end - - # -- Enterprise fees - if EnterpriseFee.count < 2 - Enterprise.is_distributor.each do |distributor| - FactoryBot.create(:enterprise_fee, enterprise: distributor) - end - end - - # -- Enterprise Payment Methods - if Spree::PaymentMethod.count < 2 - Enterprise.is_distributor.each do |distributor| - FactoryBot.create(:payment_method, - distributors: [distributor], - name: "Cheque (#{distributor.name})", - environment: 'development') - end - end - - # -- Products - if Spree::Product.count < 1 - puts "[#{task_name}] Seeding products" - - FactoryBot.create(:product, - name: 'Garlic', - price: 20.00, - supplier: Enterprise.is_primary_producer[0], - taxons: [Spree::Taxon.find_by_name('Vegetables')]) - - FactoryBot.create(:product, - name: 'Fuji Apple', - price: 5.00, - supplier: Enterprise.is_primary_producer[1], - taxons: [Spree::Taxon.find_by_name('Fruit')]) - - FactoryBot.create(:product, - name: 'Beef - 5kg Trays', - price: 50.00, - supplier: Enterprise.is_primary_producer[2], - taxons: [Spree::Taxon.find_by_name('Meat and Fish')]) - - FactoryBot.create(:product, - name: 'Carrots', - price: 3.00, - supplier: Enterprise.is_primary_producer[2], - taxons: [Spree::Taxon.find_by_name('Meat and Fish')]) - - FactoryBot.create(:product, - name: 'Potatoes', - price: 2.00, - supplier: Enterprise.is_primary_producer[2], - taxons: [Spree::Taxon.find_by_name('Meat and Fish')]) - - FactoryBot.create(:product, - name: 'Tomatoes', - price: 2.00, - supplier: Enterprise.is_primary_producer[2], - taxons: [Spree::Taxon.find_by_name('Meat and Fish')]) - - FactoryBot.create(:product, - name: 'Potatoes', - price: 2.00, - supplier: Enterprise.is_primary_producer[2], - taxons: [Spree::Taxon.find_by_name('Meat and Fish')]) - end - - enterprise2 = Enterprise.find_by_name('Enterprise 2') - enterprise2.sells = 'any' - enterprise2.shipping_methods << FactoryBot.create(:shipping_method, - name: 'Pickup', - zone: zone, - require_ship_address: true, - calculator_type: 'Calculator::Weight', - distributors: [enterprise2]) - enterprise2.payment_methods << Spree::PaymentMethod.last - enterprise2.save! - - variants = Spree::Variant - .joins(:product) - .where('spree_products.supplier_id = ?', enterprise2.id) - - CreateOrderCycle.new(enterprise2, variants).call - - unless EnterpriseRole.where( user_id: Spree::User.first, enterprise_id: enterprise2 ).any? - EnterpriseRole.create!(user: Spree::User.first, enterprise: enterprise2) - end - display_deprecation_warning - end - - def display_deprecation_warning - behaviour = ActiveSupport::Deprecation.behavior = :stderr - ActiveSupport::Deprecation.behavior = :stderr - ActiveSupport::Deprecation.warn(< Date: Tue, 25 Jun 2019 11:44:34 +0200 Subject: [PATCH 17/24] Update DOCKER.md --- DOCKER.md | 41 +++-------------------------------------- Dockerfile | 4 ++-- 2 files changed, 5 insertions(+), 40 deletions(-) diff --git a/DOCKER.md b/DOCKER.md index e3d0c0a642..8dc231b08c 100644 --- a/DOCKER.md +++ b/DOCKER.md @@ -2,7 +2,7 @@ It is possible to setup the Open Food Network app easily with Docker and Docker Compose. The objective is to spare configuration time, in order to help people testing the app and contribute to it. -It can also be use as documentation. It is not perfect but it is used in many other projects and many devs are used to it nowadays. +It can also be used as documentation. It is not perfect but it is used in many other projects and many devs are used to it nowadays. ### Install Docker @@ -10,7 +10,7 @@ Please check the documentation here, https://docs.docker.com/install/ to install For Docker Compose, information are here: https://docs.docker.com/compose/install/. -Better to have at least 2GB free on your laptop in order to download images and create containers for Open Food Network app. +Better to have at least 2GB free on your computer in order to download images and create containers for Open Food Network app. ### Use Docker with Open Food Network @@ -41,42 +41,7 @@ Run the app with all the required containers: $ docker-compose up ``` +This command will setup the database and seed it with sample data. The default admin user is 'ofn@example.com' with 'ofn123' password. Check the app in the browser at `http:://localhost:3000`. You will then get the trace of the containers in the terminal. You can stop the containers using Ctrl-C in the terminal. - - -When you run it for the first time, you will need to seed it with some sample data and this is not yet automated. When your app is running, you need to do this: - -Connect to the container containing the app with an interactive terminal: - -```sh -$ docker exec -it openfoodnetwork_web_1 bash -``` - -Load the seeds from Spree: - -```sh -$ bundle exec rake db:seed -``` - -Load thre sample data from Open Food Network: - -```sh -$ bundle exec rake ofn:sample_data -``` - -Exit and stop the container: - -```sh -$ exit -``` - -You can then relaunch the app, and check that you have data. - - -### Notes - -- It was not possible to integrate the seeding part directly because we need the input of the user and Docker Compose was not allowing it. Need to fix this. - -- Check the code in the `ofn:dev:setup` Rake task for more details. diff --git a/Dockerfile b/Dockerfile index 300ddfc889..61a719eecd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,9 @@ FROM ubuntu:18.04 -#Install all the requirements +# Install all the requirements RUN apt-get update && apt-get install -y curl git build-essential software-properties-common wget zlib1g-dev libssl1.0-dev libreadline-dev libyaml-dev libffi-dev libxml2-dev libxslt1-dev wait-for-it -#Setup ENV variables +# 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 From c0d02c8d42e92607a90ce33cd182950383743d18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Turbelin?= Date: Tue, 25 Jun 2019 12:05:26 +0200 Subject: [PATCH 18/24] Fix errors while relauching container --- docker-compose.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index b0825ded79..4c3eaa00c9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -28,7 +28,8 @@ services: command: > bash -c "(bundle check || bundle install) && wait-for-it -t 30 db:5432 && - bundle exec rake db:setup db:test:prepare ofn:sample_data || true && + bundle exec rake db:reset db:test:prepare && + bundle exec rake ofn:sample_data || true && rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'" From ceffae2efc740b739fe7ce44102bcfff60db5923 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Turbelin?= Date: Tue, 25 Jun 2019 14:08:18 +0200 Subject: [PATCH 19/24] Delete extra example file --- config/application.yml.example | 64 ---------------------------------- 1 file changed, 64 deletions(-) delete mode 100644 config/application.yml.example diff --git a/config/application.yml.example b/config/application.yml.example deleted file mode 100644 index 27710fbbc4..0000000000 --- a/config/application.yml.example +++ /dev/null @@ -1,64 +0,0 @@ -# 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" From da3b467d479d0ffaf9cfdb090feb0ea4ff0c1a57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Turbelin?= Date: Tue, 25 Jun 2019 14:09:59 +0200 Subject: [PATCH 20/24] Use https to fetch Postgres repo --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 61a719eecd..0438bc39a5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,8 +19,8 @@ RUN git clone https://github.com/rbenv/rbenv.git ${RBENV_ROOT} && \ gem install bundler --version=1.17.2 # Postgres -RUN sh -c "echo 'deb http://apt.postgresql.org/pub/repos/apt/ bionic-pgdg main' > /etc/apt/sources.list.d/pgdg.list" && \ - wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | apt-key add - && \ +RUN sh -c "echo 'deb https://apt.postgresql.org/pub/repos/apt/ bionic-pgdg main' > /etc/apt/sources.list.d/pgdg.list" && \ + wget --quiet -O - https://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | apt-key add - && \ apt-get update && \ apt-get install -yqq --no-install-recommends postgresql-client-9.5 libpq-dev From 84389d1392771acd1b6691c4a969e89a0bb0e8d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Turbelin?= Date: Tue, 25 Jun 2019 14:38:38 +0200 Subject: [PATCH 21/24] Fix setup script with new application YAML file --- script/setup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/setup b/script/setup index 65f46d7949..7064af6f80 100755 --- a/script/setup +++ b/script/setup @@ -43,7 +43,7 @@ npm install # Set up configurable environment variables if [ ! -f config/application.yml ]; then - cp config/application.yml.example config/application.yml + cp config/application.example.yml config/application.yml printf "${YELLOW}Copied config/application.yml Make sure to fill it with the appropriate configuration values.\n\n${NO_COLOR}" fi From 2dcced88108500d79f573a7151d1a7b0bfcd286b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Turbelin?= Date: Tue, 25 Jun 2019 17:59:37 +0200 Subject: [PATCH 22/24] Put back application example file as it was --- config/application.example.yml | 64 ---------------------------------- script/setup | 2 +- 2 files changed, 1 insertion(+), 65 deletions(-) delete mode 100644 config/application.example.yml diff --git a/config/application.example.yml b/config/application.example.yml deleted file mode 100644 index 27710fbbc4..0000000000 --- a/config/application.example.yml +++ /dev/null @@ -1,64 +0,0 @@ -# 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" diff --git a/script/setup b/script/setup index 7064af6f80..65f46d7949 100755 --- a/script/setup +++ b/script/setup @@ -43,7 +43,7 @@ npm install # Set up configurable environment variables if [ ! -f config/application.yml ]; then - cp config/application.example.yml config/application.yml + cp config/application.yml.example config/application.yml printf "${YELLOW}Copied config/application.yml Make sure to fill it with the appropriate configuration values.\n\n${NO_COLOR}" fi From 623d1e028528931db387fa47fa3bc600c23b719e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Turbelin?= Date: Tue, 25 Jun 2019 20:05:55 +0200 Subject: [PATCH 23/24] Add missing file --- config/application.yml.example | 64 ++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 config/application.yml.example diff --git a/config/application.yml.example b/config/application.yml.example new file mode 100644 index 0000000000..27710fbbc4 --- /dev/null +++ b/config/application.yml.example @@ -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" From b6120a91051c5c9c26ba0e58ff10bceb530d7596 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Turbelin?= Date: Wed, 26 Jun 2019 11:02:57 +0200 Subject: [PATCH 24/24] Fix docker-compose application yml file --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 4c3eaa00c9..b29c858317 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -19,7 +19,7 @@ services: - .:/usr/src/app - gems:/bundles - ./config/database.yml:/usr/src/app/config/database.yml - - ./config/application.example.yml:/usr/src/app/config/application.yml + - ./config/application.yml.example:/usr/src/app/config/application.yml depends_on: - db environment: