docbrown/docs/installation/docker.md
Michael Kohl 8b5e66ca0e
Docker fixes (#6803)
* Try out parallel Travis builds

* Add more Bundler options

* Appease the spec gods

I don't think we actually need Timecop.freeze in this spec

* Try inlining factories

* Make sure the time has actually changed

* Add CodeClimate coverage for parallel build

* Explicitly list jobs, don't rely on matrix expansion

* Merge master and move storybook to after_script

* Add missing environment variable

* Remove old cc-test-reporter config

* Move yarn build-storybook back to script, remove conditional coverage upload

* Update yarn constraint and Docker docs

Co-authored-by: rhymes <rhymesete@gmail.com>
2020-03-24 13:15:04 -04:00

3.5 KiB

title
Docker

Installing DEV with Docker [Beta]

Our docker implementation is incomplete and may not work smoothly. Please, kindly report any issues!

Installing prerequisites

These prerequisites assume you're working on an operating system supported by Docker.

Docker and Docker Compose

Docker is available for many different operating systems. We recommend you follow the Docker CE install guide, which illustrates multiple installation options for each OS.

You're also going to need Docker Compose, to start multiple containers. We recommend you follow the Docker Compose install guide as well.

Installing DEV

  1. Fork DEV's repository, e.g. https://github.com/thepracticaldev/dev.to/fork

  2. Clone your forked repository, eg. git clone https://github.com/<your-username>/dev.to.git

  3. Set up your environment variables/secrets

    • Take a look at Envfile. This file lists all the ENV variables we use and provides a fake default for any missing keys. You'll need to get your own free Algolia credentials to get your development environment running.

    • The backend guide will show you how to get free API keys for additional services that may be required to run certain parts of the app.

    • For any key that you wish to enter/replace:

      1. Create config/application.yml by copying from the provided template (i.e. with bash: cp config/sample_application.yml config/application.yml). This is a personal file that is ignored in git.
      2. Obtain the development variable and apply the key you wish to enter/replace. i.e.:
      GITHUB_KEY: "SOME_REAL_SECURE_KEY_HERE"
      GITHUB_SECRET: "ANOTHER_REAL_SECURE_KEY_HERE"
      
    • Update the redis url variables by adding the following lines into config/application.yml:

       REDIS_URL: "redis://redis:6379"
       REDIS_SESSIONS_URL: "redis://redis:6379"
      
    • You do not need "real" keys for basic development. Some features require certain keys, so you may be able to add them as you go.

Running the Docker app (basic)

Docker compose will by default use postgres:9.6 as the database version, should you want to update that set the POSTGRES_VERSION variable in your environment and start the container again

  1. run docker-compose build
  2. run docker-compose run web rails db:setup db:migrate search:setup
  3. run docker-compose up
  4. That's it! Navigate to http://localhost:3000

Running the Docker app (advanced)

DEV provides a docker-run.sh script which can be used to run the Docker app with custom options.

Please execute the script itself to view all additional options:

./docker-run.sh

Known Problems & Solutions

  • Should you experience problems with the Elasticsearch container, try to increase the memory and/or swap allocation for Docker. On macOS this can be done via the GUI:

    docker gui

  • In case rails server doesn't start with the following message:

    Data update scripts need to be run before you can start the application. Please run rails data_updates:run (RuntimeError)
    

    run the following command:

    docker-compose run web rails data_updates:run