Moved contents of DOCKER.md to docker/README.md; removed DOCKER.md; updated link to Docker page in GETTING_STARTED.md

This commit is contained in:
Jason Hsu
2020-09-25 00:49:44 -05:00
parent 97a38865a2
commit d2523abe34
5 changed files with 44 additions and 66 deletions

View File

@@ -1,62 +0,0 @@
### Docker
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 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
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 computer in order to download images and create containers for Open Food Network app.
### Use Docker with Open Food Network
Open a terminal with a shell.
Clone the repository. If you're planning on contributing code to the project (which we [LOVE](CONTRIBUTING.md)), it is a good idea to begin by forking this repo using the Fork button in the top-right corner of this screen. You should then be able to use git clone to copy your fork onto your local machine.
```sh
$ git clone https://github.com/YOUR_GITHUB_USERNAME_HERE/openfoodnetwork
```
Otherwise, if you just want to get things running, clone from the OFN main repo:
```sh
$ git clone git@github.com:openfoodfoundation/openfoodnetwork.git
```
Go at the root of the app:
```sh
$ cd openfoodnetwork
```
Download the Docker images and build the containers:
```sh
$ docker-compose build
```
Setup the database and seed it with sample data:
```sh
$ docker-compose run web bundle exec rake db:reset
$ docker-compose run web bundle exec rake db:test:prepare
$ docker-compose run web bundle exec rake ofn:sample_data
```
Finally, run the app with all the required containers:
```sh
$ docker-compose up
```
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.
You can find some useful tips and commands [here](https://github.com/openfoodfoundation/openfoodnetwork/wiki/Docker:-useful-tips-and-commands).

View File

@@ -4,7 +4,7 @@ This is a general guide to setting up an Open Food Network **development environ
### Requirements
The fastest way to make it work locally is to use Docker, you only need to setup git, see the [Docker setup guide](DOCKER.md).
The fastest way to make it work locally is to use Docker, you only need to setup git, see the [Docker setup guide](docker/README.md).
Otherwise, for a local setup you will need:
* Ruby 2.3.7 and bundler
* PostgreSQL database

View File

@@ -1,3 +1,43 @@
# Docker Scripts
Use the scripts in this directory to execute tasks in Docker. Please note that these scripts are intended to be executed from this app's root directory.
## What's the point?
* Setting up the Open Food Network app on your local machine is quick and easy with the aid of Docker and Docker Compose.
* Docker provides a common virtual environment available to all developers and resolves the infamous "but it works on my machine" problem.
* Use the scripts in this directory to execute tasks in Docker. Please note that these scripts are intended to be executed from this app's root directory. These scripts allow you to bypass the need to keep typing "docker-compose run --rm web".
## Installing Docker
* You should have at least 2 GB free on your local machine to download Docker images and create Docker containers for this app.
* Docker installation instructions are at https://docs.docker.com/install/.
* Docker Compose installation instructions are at https://docs.docker.com/compose/install/.
* To run Docker commands as a regular user instead of as root (with sudo), follow the instructions at https://docs.docker.com/engine/install/linux-postinstall/.
## Getting Started
* Open a terminal with a shell.
* Clone the repository. If you're planning on contributing code to the project (which we [LOVE](CONTRIBUTING.md)), begin by forking this repo with the Fork button in the top-right corner of this screen.
* Use git clone to copy your fork onto your local machine.
```sh
$ git clone https://github.com/YOUR_GITHUB_USERNAME_HERE/openfoodnetwork
```
* Otherwise, if you just want to get things running, clone from the OFN main repo:
```sh
$ git clone git@github.com:openfoodfoundation/openfoodnetwork.git
```
* Go at the root of the app:
```sh
$ cd openfoodnetwork
```
* Download the Docker images, build the Docker containers, seed the database with sample data, AND log the screen output from these tasks:
```sh
$ docker/build
```
* Run the Rails server and its required Docker containers:
```sh
$ docker/server
```
* The default admin user is 'ofn@example.com' with the password 'ofn123'.
* View 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.
* You can find some useful tips and commands [here](https://github.com/openfoodfoundation/openfoodnetwork/wiki/Docker:-useful-tips-and-commands).

View File

@@ -1,7 +1,7 @@
#!/bin/bash
set -e
# This script builds the Docker container, seeds the app with simulated data, and logs the screen output.
# This script builds the Docker container, seeds the app with sample data, and logs the screen output.
DATE=`date +%Y%m%d-%H%M%S-%3N`
docker/build-log 2>&1 | tee log/build-$DATE.log

View File

@@ -6,7 +6,7 @@ wait
echo '###########################'
echo 'BEGIN: docker-compose build'
echo '###########################'
docker-compose build
docker-compose build # Set up the Docker containers
echo '##############################'
echo 'FINISHED: docker-compose build'
echo '##############################'