Skip to content

Running Greasy Fork locally

Max Starkenburg edited this page Aug 26, 2016 · 31 revisions

Greasy Fork is a Ruby on Rails site running on Passenger/nginx. This describes one way to run it locally; alternate ways with alternate software (Apache instead of nginx, PosgreSQL instead of MySQL) probably work. Where version numbers are provided, this indicates the versions in use by greasyfork.org, which are likely not hard requirements.

Prerequisites

  • Ruby - 2.2.1 (suggested to be installed within rvm - 1.26.10)
  • MySQL, including development packages (libmysqlclient-dev) - 5.6.16
  • Sphinx - 2.2.7
  • Java - only needed to run precompilation of static files

Pull the code

The regular GitHub way.

Gem installation

From the Greasy Fork directory:

  • Install bundler - gem install bundler
  • Install required gems - bundle install
  • Install passenger - gem install passenger
  • Run passenger-install-nginx-module and do what it says

MySQL setup

Start MySQL, log in as root, and run:

CREATE USER 'yourmysqlusername'@'localhost' IDENTIFIED BY 'yourmysqluserpassword';
CREATE SCHEMA greasyfork;
GRANT ALL ON greasyfork.* TO 'yourmysqlusername'@'localhost';
CREATE SCHEMA greasyforktest;
GRANT ALL ON greasyforktest.* TO 'yourmysqlusername'@'localhost';

Now run mysql -uyourmysqlusername -p greasyfork < db/structure.sql. This gives you a blank site.

To get some real data in there, download the public data dump, then import it: gunzip -c db.sql.gz | mysql -uyourmysqlusername -p greasyfork.

Secret files

Files with passwords and such.

config/database.yml

development:
  adapter: mysql2
  database: greasyfork
  username: yourmysqlusername
  password: yourmysqlpassword
  host: 127.0.0.1
  port: '3306'
  encoding: utf8mb4
  collation: utf8mb4_unicode_ci

test:
  adapter: mysql2
  database: greasyforktest
  username: yourmysqlusername
  password: yourmysqlpassword
  host: 127.0.0.1
  port: '3306'
  encoding: utf8mb4
  collation: utf8mb4_unicode_ci

config/secrets.yml

development:
  secret_key_base:  # run rake secret
  devise_secret_key: # also rake secret, but different value than above
  detect_language_api_key:  # optional, for language detection on script update. get a free API key at http://detectlanguage.com/

# values here can be the same as above
test:
  secret_key_base:
  devise_secret_key:
  detect_language_api_key:

This is only necessary for external sign-in providers. This is a sample that includes only BrowserID.

require 'omniauth'

Rails.application.config.middleware.use OmniAuth::Builder do
        # failure_path: https://github.com/intridea/omniauth-browserid/issues/2#issuecomment-16500464
        provider :browser_id, :failure_path => '/auth/failure2'
end
Rails.application.config.available_auths = {
        'browser_id' => 'Persona'
}
OmniAuth.config.on_failure = Proc.new { |env|
  OmniAuth::FailureEndpoint.new(env).redirect_to_failure
}

Forum

Greasy Fork runs Vanilla 2.2 as its forum software. Setting this up is optional to running the rest of the site. Without it, there will be no feedback possible on scripts. If you choose to install Vanilla, configure it to use the "greasyfork" schema. The tables will already be there from running db/structure.sql. You will also need to apply some patches.

Fire it up

  • rake ts:configure - configure Sphinx
  • rake ts:start - start Sphinx
  • bin/delayed_job - start delayed_job
  • sudo /opt/nginx/sbin/nginx - start nginx

Need help?

This was written from memory and likely has errors and omissions. Please file a ticket or ask in the forum for help.

Clone this wiki locally