Skip to content

Commit

Permalink
Feature/docker settings (#37)
Browse files Browse the repository at this point in the history
* updating docker settings to play better with IDEs

* removing NODE_PORT env var and using location.origin as the default apiHost

* adding restoration instructions to the backups file

* updating docs on proxies

* updating package.js

* adding a release doc and updating the index

* fixing the sample env file
  • Loading branch information
RyanNoelk authored May 7, 2018
1 parent b704c5d commit efbb011
Show file tree
Hide file tree
Showing 13 changed files with 99 additions and 66 deletions.
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@ services:
- "8000:8000"
web:
build: openeats-web/
command: yarn start
command: yarn dev
env_file:
env_dev.list
volumes:
- ./openeats-web:/code
- node_modules:/code/node_modules
depends_on:
- api
ports:
Expand All @@ -31,8 +30,9 @@ services:
env_dev.list
volumes:
- database:/var/lib/mysql
ports:
- "3306:3306"
volumes:
database:
node_modules:
static-files:
site-media:
2 changes: 0 additions & 2 deletions docker-stage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ services:
build: openeats-web/
command: yarn start
volumes:
- node_modules:/code/node_modules
- public-ui:/code/build
depends_on:
- api
Expand Down Expand Up @@ -46,7 +45,6 @@ services:
env_stg.list
volumes:
database:
node_modules:
public-ui:
static-files:
site-media:
14 changes: 14 additions & 0 deletions docs/Creating_a_Release.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Creating a Release

1. Get an Auth token from github. See Github for details on how to do this.
2. Create a secrets folder and add a filer with the below strcuture:
```python
#!/usr/bin/env python
# encoding: utf-8

username = 'username'
password = 'token'
```
3. Create a release doc and place in the releases folder. See the release folder for examples.
4. Once you have a release file created, you can run the release script. This script takes the release file you just created as it's only arg.
- `./release x.x.x.json`
21 changes: 13 additions & 8 deletions docs/Creating_a_proxy_server_for_docker.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Serving with a proxy server and HTTPS
By default the docker application doesn't come with an https server. It is also likely that you want to server other applications.
By default the docker application doesn't come with an https server. It is also likely that you want to server other applications.

If you want to server the docker application via https or serve multiple applications via nginx/apache then you will also need a proxy server.
If you want to server the docker application via https or serve multiple applications via nginx/apache then you will also need a proxy server.

To change the port from which OpenEats is served you will need to update the left side of the port configuration.
- Open the docker-prod.override.yml (your docker-compose configuration) file.
- To serve the app via port 7000:
To change the port from which OpenEats is served you will need to update the left side of the port configuration in the `docker-prod.override.yml` file.
- Open the docker-prod.override.yml (your docker-compose configuration) file.
- To serve the app via port 7000:
``` yml
version: '2.3'
services:
Expand All @@ -14,11 +14,16 @@ services:
- "7000:80"
```
- Restart you docker containers `docker-compose -f docker-prod.yml restart`
- Restart you docker containers
- `
docker-compose -f docker-prod.yml -f docker-prod.override.yml -f docker-prod.version.yml restart`
- OR
- Just run the `quick-start` script again: `./quick-start`
- Load localhost:7000 to confirm it worked.

For free ssl crits see:
https://letsencrypt.org/getting-started/

It is highly recommended that you server your content over https. [Let's Encrypt](https://letsencrypt.org/getting-started/) provides a super easy, automated, and free process for serving your content over https. If you are using nginx, they will also automatically update your plain http vhost files.

For more info on how to use proxies, see:
https://www.nginx.com/resources/admin-guide/reverse-proxy/
11 changes: 3 additions & 8 deletions docs/Setting_up_env_file.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,11 @@ The API will use this to prevent CORS issues.

EX: `NODE_URL=localhost:8080`

#### NODE_PORT
The port node is served from.

EX: `NODE_PORT=8080`

#### NODE_API_URL
The URL and port the frontend will call the API from.
For production this should be your domain.
The hostname/port (my.example.com:8080) the frontend will call the API from.
If unset, the UI will call the API from the same hostname/port. If you are not using the default Nginx server that OpenEats comes with, you will either need to set this or configure your own proxy server to redirect all traffic that starts with `/api` or `/admin`.

EX: `NODE_API_URL=http://localhost`
EX: `NODE_API_URL=http://localhost:8080`, `NODE_API_URL=https://api.example.com`

#### NODE_LOCALE
The language the UI will be in.
Expand Down
18 changes: 0 additions & 18 deletions docs/Taking_Backups.md

This file was deleted.

45 changes: 45 additions & 0 deletions docs/Taking_and_Restoring_Backups.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Backing up Your Data

The following commands can be used to take backups of your data and restore those backups. The backup commands are automatically run when you upgrade to a newer version as well.


### Recipes Images

#### Backing up:

Replace `/dir/on/local/system/` with the location where you would like your images.
```sh
docker cp openeats_api_1:/code/site-media/ /dir/on/local/system/
```

#### Restoring:

Replace `/dir/on/local/system/` with the location where you would like your images.
```sh
docker cp /dir/on/local/system/site-media/. openeats_api_1:/code/site-media/
```

### Database

#### Backing up:

Places a sql dump of the database on your current working directory.
```sh
docker exec openeats_db_1 sh -c 'exec mysqldump openeats -uroot -p"$MYSQL_ROOT_PASSWORD"' > openeats.sql
```

#### Restoring:

First cd into the dir that contains your sql backup. Once there you need to source your env file so you don't have to type your database password on the command line. Then run the last command to start the restore.
Note: if you changed the database name then you will need to change the last word the statement below to the database name you gave OpenEats.
```sh
cd /open/eats/root/
source env_prod.list
cat openeats.sql | docker exec -i openeats_db_1 /usr/bin/mysql -u root -p"$MYSQL_ROOT_PASSWORD" openeats

```


### Sources
- [Copying Image Files to and from Docker Containers/Volumes](https://gist.github.com/spalladino/6d981f7b33f6e0afe6bb)
- [DB backups/restores](https://stackoverflow.com/questions/22907231/copying-files-from-host-to-docker-container)
22 changes: 19 additions & 3 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
# OpenEats Project

API Status:
[![API Build Status](https://travis-ci.org/open-eats/openeats-api.svg?branch=master)](https://travis-ci.org/open-eats/openeats-api)
[![Coverage Status](https://coveralls.io/repos/github/open-eats/openeats-api/badge.svg)](https://coveralls.io/github/open-eats/openeats-api)

Web Status:
[![Web Build Status](https://travis-ci.org/open-eats/openeats-web.svg?branch=master)](https://travis-ci.org/open-eats/openeats-web)
[![Coverage Status](https://coveralls.io/repos/github/open-eats/openeats-web/badge.svg)](https://coveralls.io/github/open-eats/openeats-web)

OpenEats is a recipe management site that allows users to create, share, and store their personal collection of recipes. This fork uses Django Rest Framework as a backend and React (with flux) as a front end.

The usage for the app is intended for a single user or a small group. For my personal use, I would be an admin user and a few (about 5-6) friends and family would be normal users. Admin users can add other users to the project (no open sign-ups), make changes to the available Cuisines and Courses, and add to the homepage banner. Normal users just have the ability to add recipes. Below are a few of the core features the app provides.

- Creating, viewing, and editing recipes.
- Creating, viewing, sharing, and editing recipes.
- Update Serving information on the fly.
- Browsing and searching for recipes.
- Creating grocery lists
- Creating grocery lists.
- Automatically add recipes to your grocery lists.
- Quickly print recipe.
- Linking recipes and ingredient grouping
- Linking recipes and ingredient grouping.

### [Read the docs on getting started here!](https://github.com/open-eats/OpenEats/blob/master/docs/Running_the_App.md)

### [The Update guide can be found here!](https://github.com/open-eats/OpenEats/blob/master/docs/Updating_the_App.md)

# Contributing
Please read the [contribution guidelines](https://github.com/open-eats/OpenEats/blob/master/CONTRIBUTING.md) in order to make the contribution process easy and effective for everyone involved.

For a guide on how to setup an environment for development see [this guide](https://github.com/open-eats/OpenEats/blob/master/docs/Running_the_App_in_dev.md).
2 changes: 1 addition & 1 deletion docs/samples/sample_docker_prod_override.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ version: '2.3'
services:
nginx:
ports:
- "80:80"
- "8000:80"
1 change: 0 additions & 1 deletion docs/samples/sample_env_file.list
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,5 @@ HTTP_X_FORWARDED_PROTO=true
# Node config
NODE_ENV=production
NODE_URL=localhost:8080
NODE_PORT=8080
NODE_API_URL=http://my.domain.com
NODE_LOCALE=en
21 changes: 1 addition & 20 deletions docs/samples/sample_nginx_proxy
Original file line number Diff line number Diff line change
@@ -1,33 +1,14 @@
server {
# Redirect all http calls to https'
# IE: 80 -> 443
listen 80;
server_name my.site.com;
return 301 https://$server_name$request_uri;
}

server {
listen 443 ssl;
listen 80;
server_name my.site.com;

# SSL configuration here
ssl_certificate /path/to/cert/fullchain.pem;
ssl_certificate_key /path/to/private/key/privkey.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!MD5;
add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; ";

# pass requests for dynamic content
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;

# Fix the “It appears that your reverse proxy set up is broken" error.
proxy_pass http://localhost:7000;
proxy_read_timeout 90;

proxy_redirect http://localhost:7000 http://my.site.com;
}
}
1 change: 0 additions & 1 deletion env_dev.list
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,5 @@ HTTP_X_FORWARDED_PROTO=false
# Node config
NODE_ENV=development
NODE_URL=localhost:8080
NODE_PORT=8080
NODE_API_URL=http://localhost:8000
NODE_LOCALE=en
1 change: 0 additions & 1 deletion env_stg.list
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,5 @@ HTTP_X_FORWARDED_PROTO=false
# Node config
NODE_ENV=production
NODE_URL=localhost:8080
NODE_PORT=8080
NODE_API_URL=http://localhost
NODE_LOCALE=en

0 comments on commit efbb011

Please sign in to comment.