Added readme
[discourse_docker.git] / README.md
1 ##Discourse Docker
2
3 A toolkit for building and managing Docker images for Discourse.
4
5 ### About
6
7 The Discourse docker templates were designed by Sam Saffron. See the following introduction: http://samsaffron.com/archive/2013/11/07/discourse-in-a-docker-container
8
9 These templates are agnostic, you may run Discourse in multiple containers or a single container.
10
11 The templates and base image take care of configuring Discourse with best practices in mind. The latest version of Ruby 2.0 is included as is fairly extensive memory and GC tuning. The web template uses unicorn which helps cut down on overall memory usage making this very suitable for VPS type installs.
12
13 ### Directory Structure
14
15 - cids
16
17 Contains container ids for currently running Docker containers. cids are Docker's "equivalent" of pids. Each container will have a unique git like hash.
18
19 - containers
20
21 This directory is to contain container definitions for your various Discourse containers. You are in charge of this directory, it ships empty.
22
23 - samples
24
25 Sample container definitions you may use to bootstrap your environment. You can copy and amend templates here into the containers directory.
26
27 - shared
28
29 Placeholder spot for shared volumes with various Discourse containers. You may elect to store certain persistent information outside of a container, in our case we keep various logfiles and upload directory outside. This allows you to rebuild containers easily without losing important information. Keeping uploads outside of the container allows you to share them between multiple web instances.
30
31 - templates
32
33 [pups](https://github.com/samsaffron/pups) managed pups templates you may use to bootstrap your environment.
34
35 - image
36
37 Dockerfile for both the base image `samsaffron/discoruse_base` and discourse image `samsaffron/discourse`.
38
39 `samsaffron/discourse_base` contains all the OS dependencies including sshd, runit, postgres, nginx, ruby.
40
41 `samsaffron/discourse` builds on the base image and configures a discourse user and `/var/www/discourse` directory for the Discourse source.
42
43 The Docker repository will always contain the latest built version at: https://index.docker.io/u/samsaffron/discourse/ , you should not need to build the base image.
44
45 ###launcher
46
47 The base directory contains a single bash script which is used to manage containers. You can use it to "bootstrap" a new container, ssh in, start, stop and destroy a container.
48
49 ```
50 Usage: launcher COMMAND CONFIG
51 Commands:
52 start: Start/initialize a container
53 stop: Stop a running container
54 restart: Restart a container
55 destroy: Stop and remove a container
56 ssh: Start a bash shell in a running container
57 logs: Docker logs for container
58 bootstrap: Bootstrap a container for the config based on a template
59 ```
60
61 ###Getting started
62
63 The simplest (though slightly more fragile) way of getting started is using the standalone template.
64
65 - `cp samples/standalone.yml containers/app.yml`
66 - Edit app.yml with your environment specific information
67 - `./launcher bootstrap app`
68 - `./launcher start app`
69
70 ###About the container configuration
71
72 The beggining of the container definition will contain 3 "special" sections:
73
74 - templates:
75
76 ```
77 templates:
78 - "templates/cron.template.yml"
79 - "templates/postgres.template.yml"
80 ```
81
82 This template is "composed" out of all these child templates, this allows for a very flexible configuration struture. Further more you may add specific hooks that extend the templates you reference.
83
84 - expose:
85
86 ```
87 expose:
88 - "2222:22"
89 ```
90
91 Expose port 22 inside the container on port 2222 on ALL local host interfaces.
92
93
94 - volumes:
95
96 ```
97 volumes:
98 - volume:
99 host: /var/docker/data
100 guest: /shared
101
102 ```
103
104 Expose a directory inside the host inside the container.
105
106 *short note about security* Directory permissions in Linux are sid based, if your sids on the host do not match the sids in the guest, permissions will mismatch. On clean installs you can ensure they are in sync by looking at `/etc/passwd` and `/etc/group`, the discourse account will have the sid 1000.
107
108
109
110
111