docker_compose_deploy 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +138 -1
- data/lib/docker_compose_deploy/version.rb +1 -1
- data/template/Vagrantfile +1 -0
- data/template/ssh_config_overrides +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d9dcaa86394d8c24329b214fb239286ff77c0ac
|
4
|
+
data.tar.gz: d7643624e310fbd8305031e50187448a5688fd0b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 914b2cb664887b55b8331a0b8d472c7b671b19662d9cafe008b0b00fe9fa93a3f45d78d79a544f105d774d6189ccfe12d1f435a3a43cab875d2597aca484c998
|
7
|
+
data.tar.gz: bb5c8425e50700e879e9b77d5176f744f3b822b79ddea3ab760280017e12be711a15db98e4cf3471f9b7fc08fb1e9d4704f98c326f9e0f2bb4b4916b010437aa
|
data/README.md
CHANGED
@@ -12,4 +12,141 @@ While these scripts are great for your personal projects, they will not help you
|
|
12
12
|
|
13
13
|
This doesn't provide much over using docker-machine, but it will simplify working with volumes and allow you to test your deployment in a realistic environment.
|
14
14
|
|
15
|
-
### The
|
15
|
+
### The big picture
|
16
|
+
|
17
|
+
For my homepage, I serve up multiple applications from the same machine. For this reason, I have nginx to inspect incoming requests and route them to the correct application. As I add new applications, I need to change this setup. So I need to push a new nginx config file as part of my deployment process.
|
18
|
+
|
19
|
+
Some of my deployed applications generate data as they run. I want a simple way to download a snapshot of that data as backup. So I want to consolidate all of my data in one place.
|
20
|
+
|
21
|
+
While I want to keep the log files that my apps generate, I don't see a need to include those in the backup snapshots that I download. So I want to consolidate my logs somewhere separate from the important data.
|
22
|
+
|
23
|
+
DockerComposeDeploy scripts help me:
|
24
|
+
|
25
|
+
- push configuration for applications
|
26
|
+
- create data and log directories for applications
|
27
|
+
- backup data directories
|
28
|
+
|
29
|
+
As I add new apps I must update my nginx config. Testing this can be tricky, since nginx will make routing decisions based on the requested url. It's hard to really test this config when everything is hosted on `http://localhost`. This tool will also:
|
30
|
+
|
31
|
+
- Push your project to a vagrant machine
|
32
|
+
- Create entries in `/etc/hosts` on the vagrant machine to help you test your nginx config
|
33
|
+
|
34
|
+
|
35
|
+
### Installation
|
36
|
+
|
37
|
+
```
|
38
|
+
gem install 'docker_compose_deploy'
|
39
|
+
```
|
40
|
+
|
41
|
+
This will add the executable `dcd`
|
42
|
+
|
43
|
+
In order to test your project using vagrant, you need to have vagrant installed: https://www.vagrantup.com/
|
44
|
+
|
45
|
+
### Creating a new project
|
46
|
+
|
47
|
+
We will generate a new project in the 'homepage' directory:
|
48
|
+
|
49
|
+
```
|
50
|
+
dcd new homepage
|
51
|
+
```
|
52
|
+
|
53
|
+
You should see the following output:
|
54
|
+
|
55
|
+
```
|
56
|
+
To see the skeleton app in action, run the following commands
|
57
|
+
|
58
|
+
# Move into the directory
|
59
|
+
1. cd homepage
|
60
|
+
|
61
|
+
# Use vagrant to create the virtual machine for testing (it will open a window and will display Ubuntu's desktop)
|
62
|
+
2. vagrant up
|
63
|
+
|
64
|
+
# Install docker and docker-compose on the vagrant machine
|
65
|
+
3. dcd provision
|
66
|
+
|
67
|
+
# Deploy the skeleton app to the vagrant machine
|
68
|
+
4. dcd deploy
|
69
|
+
|
70
|
+
# See the server in action:
|
71
|
+
5. Open firefox on the vagrant machine and visit http://www.test
|
72
|
+
```
|
73
|
+
|
74
|
+
Follow those steps! When you visit `www.test` in the vagrant machine, you should see a page that says "site 1 or site 2"
|
75
|
+
|
76
|
+
### The Project Structure
|
77
|
+
|
78
|
+
Let's investigate each file, one by one.
|
79
|
+
|
80
|
+
---
|
81
|
+
|
82
|
+
__docker-compose.yml__
|
83
|
+
|
84
|
+
A natural place to start to inspect the `docker-compose.yml` file. You will see three sites defined: proxy, site1, site2.
|
85
|
+
|
86
|
+
Each site that is deployed with `dcd` will be provided three directories to mount:
|
87
|
+
|
88
|
+
- `./sites/[app_name]/config`: This directory is pushed from your localhost to the remote. Each time you run `dcd deploy` the config directory for each application will be __removed and replaced__ by the directory found on your localhost (if any). Notice that there is a file on your localhost at `./sites/proxy/config/nginx.conf`. This file will be copied to your host at deployment time.
|
89
|
+
|
90
|
+
- `./sites/[app_name]/data`: This directory is the permanent storage for your application. When running `dcd backup`, each application's `data` directory will be zipped up and downloaded for safekeeping.
|
91
|
+
|
92
|
+
- `./sites/[app_name]/log`: This directory is for storing logs. It is never removed, but it is also not included in backups. To see what's inside, you'll have to ssh to your server.
|
93
|
+
|
94
|
+
Although none of the sites in the skeleton make use of their data directories, the volume maps are included to indicate what mounts are available. Understanding how nginx is configured is beyond the scope of this project, but the configuration found at `./sites/proxy/config/nginx.conf` should be a good template to follow.
|
95
|
+
|
96
|
+
---
|
97
|
+
|
98
|
+
__config.yml__
|
99
|
+
|
100
|
+
This is where we configure what machines `dcd` will connect with. I only need two environments: 'test' and 'production'. The 'test' environment is the vagrant box, the 'production' environment uses my virtual machine on DigitalOcean.
|
101
|
+
|
102
|
+
When using the `dcd` command, you can specify the environment using the `-e` flag. If the `-e` is not set, it will default to 'test'. Here is an example:
|
103
|
+
|
104
|
+
```
|
105
|
+
dcd deploy -e production
|
106
|
+
```
|
107
|
+
|
108
|
+
You can also configure the `hosts` entry. These will be placed in the `/etc/hosts` file of the remote machine. This is only used on test machines so that we can have fake dns entries. Having these hosts entries allows us to trigger nginx rules that are hard to trigger when using `localhost`. For example:
|
109
|
+
```
|
110
|
+
server {
|
111
|
+
listen 80;
|
112
|
+
server_name site1.*;
|
113
|
+
...
|
114
|
+
}
|
115
|
+
```
|
116
|
+
Using a hosts entry allows us to visit `site.test` and trigger that handler.
|
117
|
+
|
118
|
+
You can read the comments in `config.yml` for more info.
|
119
|
+
|
120
|
+
__Vagrantfile__
|
121
|
+
|
122
|
+
Nothing special here. Note that a high port is forwarded to port 22 only to make the configuration for ssh-ing to the machine more predictable.
|
123
|
+
|
124
|
+
If you get locked out of your Ubuntu machine the password is `vagrant`.
|
125
|
+
|
126
|
+
__ssh_config_overrides__
|
127
|
+
|
128
|
+
The Controlmaster stuff at the top helps improve the performance of the multiple ssh commands that are run in quick succession.
|
129
|
+
|
130
|
+
The host at the bottom is the connection info for your vagrant machine. If you want to manually ssh to your vagrant machine you can do the following:
|
131
|
+
|
132
|
+
```
|
133
|
+
vagrant ssh
|
134
|
+
```
|
135
|
+
or
|
136
|
+
|
137
|
+
```
|
138
|
+
ssh -F ssh_config_overrides vagrant@default
|
139
|
+
```
|
140
|
+
|
141
|
+
If `dcd` cannot connect to your vagrant machine, you can run:
|
142
|
+
|
143
|
+
```
|
144
|
+
vagrant ssh-config >> ssh_config_overrides
|
145
|
+
```
|
146
|
+
|
147
|
+
This will update the ssh connection info to work with your vagrant machine.
|
148
|
+
|
149
|
+
|
150
|
+
### Issues/Questions
|
151
|
+
|
152
|
+
If you have any questions or problems using these scripts or somethings just not clear, please open an issue! I'm happy to try to help.
|
data/template/Vagrantfile
CHANGED