Skip to content
This repository was archived by the owner on Mar 4, 2019. It is now read-only.

Commit 4314c86

Browse files
committed
Updated README files.
1 parent 05a49f8 commit 4314c86

File tree

2 files changed

+112
-133
lines changed

2 files changed

+112
-133
lines changed

README.org

Lines changed: 32 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -3,62 +3,40 @@ Drupal installation profile for B-Translator Client.
33

44
* Installation
55

6-
Assuming that we have a minimal ubuntu server 14.04 (trusty),
7-
B-Translator Client can be installed in it like this:
6+
Installation is done inside a Docker container.
7+
8+
+ Modify and customize the settings:
9+
#+BEGIN_EXAMPLE
10+
cp btr_client/install/settings.sh cfg.sh
11+
vim cfg.sh
12+
#+END_EXAMPLE
13+
14+
+ Build a Docker image:
15+
#+BEGIN_EXAMPLE
16+
btr_client/docker-build.sh cfg.sh --git_branch=master
17+
less -r nohup-btr_client-master.out
18+
#+END_EXAMPLE
19+
This will create a docker image, named =btr_client:master= with a
20+
minimal ubuntu system and everything that is needed for the normal
21+
work of the system.
22+
23+
+ Create a Docker container like this:
24+
#+BEGIN_EXAMPLE
25+
docker images
26+
docker run -d --name=btr_client --hostname=example.org \
27+
-p 80:80 -p 443:443 btr_client:master
28+
#+END_EXAMPLE
29+
Then you can stop and start the container with =docker stop btr_client=
30+
and =docker start btr_client=.
31+
32+
If it is installed on a local machine (for testing or development),
33+
add the domain name =example.org= on ~/etc/hosts~:
834
#+BEGIN_EXAMPLE
9-
mkdir /var/chroot
10-
cd /var/chroot/
11-
git clone https://github.com/B-Translator/btr_client.git
12-
cp btr_client/install/settings.sh btr_client/bcl.sh
13-
vim btr_client/bcl.sh
14-
nohup time nice btr_client/install/chroot.sh btr_client/bcl.sh &
15-
tail -f nohup.out
16-
less -r nohup.out
17-
#+END_EXAMPLE
18-
19-
This will install in ~/var/chroot/~ a minimal ubuntu system,
20-
B-Translator Client, and everything that is needed for the normal
21-
work of the system. It will also make the neccessary common
22-
configurations of the system.
23-
24-
The installation script will also create the init script
25-
~/etc/init.d/chroot-bcl~, which can be used to start and stop the
26-
services inside the chroot:
27-
#+BEGIN_EXAMPLE
28-
/etc/init.d/chroot-bcl start
29-
/etc/init.d/chroot-bcl stop
30-
#+END_EXAMPLE
31-
32-
33-
* Installation in a docker container
34-
35-
This is almost the same as the installation above, except that
36-
instead of ~install/chroot.sh~ you call ~install/docker.sh~:
37-
#+BEGIN_EXAMPLE
38-
nohup time nice btr_client/install/docker.sh btr_client/bcl.sh &
39-
#+END_EXAMPLE
40-
41-
Then to start and stop B-Translator Client you do:
42-
#+BEGIN_EXAMPLE
43-
docker.io start bcl
44-
docker.io stop bcl
45-
#+END_EXAMPLE
46-
47-
Compared to the installation with chroot, docker has the advantage
48-
that it is platform independent (the host system does not have to be
49-
Ubuntu or Debian).
50-
51-
52-
* Building with docker
53-
54-
Another way is to use the command =docker build= to build an image
55-
and then =docker run= to create a container from this image:
56-
#+BEGIN_EXAMPLE
57-
vim btr_client/install/settings.sh
58-
docker.io build --tag=btr_client btr_client/
59-
docker.io run -d --name=bcl --hostname=example.org \
60-
-p 80:80 -p 443:443 btr_client
35+
127.0.0.1 example.org
6136
#+END_EXAMPLE
37+
This way it can be accessed by typing =https://example.org=
38+
on the browser location (not =https://127.0.0.1= or
39+
=https://localhost=).
6240

6341

6442
* What is B-Translator

dev/README.org

Lines changed: 80 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -4,59 +4,18 @@
44

55
Development Tools, Tips and Tricks
66

7-
* Installation
8-
9-
If you need to install frequently (for example for testing), a
10-
script like this can be useful:
11-
#+BEGIN_EXAMPLE
12-
#!/bin/bash -x
13-
14-
source=dbox
15-
installer=chroot
16-
git_branch=master
17-
nohup_out="nohup-$source-$git_branch-$installer.out"
18-
19-
rm -f $nohup_out
20-
nohup time nice $source/install/{$installer.sh,settings.sh} cfg.sh \
21-
--git_branch=$git_branch --reboot=true > $nohup_out &
22-
sleep 1
23-
tail -f $nohup_out
24-
#+END_EXAMPLE
25-
26-
The file ~cfg.sh~ overrides the default config settings (for example
27-
passwords):
28-
#+BEGIN_EXAMPLE
29-
apt_mirror='http://us-east-1.ec2.archive.ubuntu.com/ubuntu/'
30-
gmail_account='[email protected]'
31-
gmail_passwd=3omRoxtho
32-
development='true'
33-
#+END_EXAMPLE
34-
35-
You can also override configuration settings from the command line.
36-
37-
*Note:* The order of giving the settings is important. The last one
38-
overrides the previous settings.
39-
40-
417
* How to access the shell
428

439
When things are still in development and testing we need to access
4410
the shell of the installed system in order to check log files,
4511
debug, play with changing configurations, etc.
4612

47-
When the installation is done on a chroot directory, then you simply
48-
switch to it with the command =chroot=:
49-
#+BEGIN_EXAMPLE
50-
chroot /var/chroot/bcl/
51-
#+END_EXAMPLE
52-
53-
When the installation is done in a docker container, you have to install
54-
first the commands =nsenter= and =docker-enter= like this:
13+
For this we can install the command =docker-enter=:
5514
#+BEGIN_EXAMPLE
5615
docker run -v /usr/local/bin:/target jpetazzo/nsenter
5716
#+END_EXAMPLE
5817

59-
Then you can access the shell of a running container like this:
18+
Then access the shell of a running container like this:
6019
#+BEGIN_EXAMPLE
6120
docker-enter bcl
6221
#+END_EXAMPLE
@@ -67,19 +26,27 @@ Development Tools, Tips and Tricks
6726

6827
* Install sshd
6928

70-
In order to access the server remotely through drush, ssh-client,
71-
etc. you can install *sshd* with the script ~dev/install-sshd.sh~,
72-
like this:
29+
We want to start a sshd server on port 2201 inside the container,
30+
but when we created the container with =docker run= we did not think
31+
about forwarding this port. We have to destroy this container and
32+
create a new one, with an addition =-p= option for the
33+
port 2201. But first we should use the command =docker commit= to
34+
save to a new image any configurations and data that we already have
35+
in this container.
7336
#+BEGIN_EXAMPLE
74-
chroot /var/chroot/bcl/
75-
cd /usr/local/src/btr_client/
76-
dev/install-sshd.sh
37+
docker stop bcl
38+
docker commit bcl btr_client:1
39+
docker images
40+
docker rm bcl
41+
docker run -d --name=bcl --hostname=example.org \
42+
-p 80:80 -p 443:443 -p 2201:2201 btr_client:1
7743
#+END_EXAMPLE
7844

79-
By default it will install and run a sshd that listens on the port *2201*,
80-
but you can also give it the port number as an argument:
45+
Now we can enter the container and start the sshd server:
8146
#+BEGIN_EXAMPLE
82-
dev/install-sshd.sh 2211
47+
docker-enter bcl
48+
cd /usr/local/src/btr_client/
49+
dev/install-sshd.sh 2201
8350
#+END_EXAMPLE
8451

8552

@@ -88,12 +55,10 @@ Development Tools, Tips and Tricks
8855
There are two webservers installed, apache2 and nginx (with php5-fpm
8956
and memcached). For development Apache2 can be more suitable, while
9057
for production NGINX is supposed to be more responsive in high load.
91-
It also has built-in cache and its configuration is tweaked for DoS
92-
protection, short timeout, etc.
9358

9459
We can choose one of them like this:
9560
#+BEGIN_EXAMPLE
96-
chroot /var/chroot/bcl/
61+
docker-enter bcl
9762
cd /usr/local/src/btr_client/
9863
dev/webserver.sh apache2
9964
dev/webserver.sh nginx
@@ -104,9 +69,9 @@ Development Tools, Tips and Tricks
10469

10570
Clones of the main site can be used for development and testing.
10671

107-
Inside the chroot you can make a clone for development like this:
72+
Inside the container you can make a clone for development like this:
10873
#+BEGIN_EXAMPLE
109-
chroot /var/chroot/bcl/
74+
docker-enter bcl
11075
cd /usr/local/src/btr_client/
11176
dev/clone.sh bcl bcl_dev1
11277
dev/clone.sh bcl_dev1 bcl_test1
@@ -123,7 +88,7 @@ Development Tools, Tips and Tricks
12388
Other clones like this can be created for testing etc. To cleanup
12489
(remove/erase) a clone, you can use *clone_rm.sh* like this:
12590
#+BEGIN_EXAMPLE
126-
chroot /var/chroot/bcl/
91+
docker-enter bcl
12792
cd /usr/local/src/btr_client/
12893
dev/clone_rm.sh bcl_dev1
12994
dev/clone_rm.sh bcl_test1
@@ -134,7 +99,7 @@ Development Tools, Tips and Tricks
13499
a development copy with a live or testing one), with the script
135100
=dev/config.php=:
136101
#+BEGIN_EXAMPLE
137-
chroot /var/chroot/bcl/
102+
docker-enter bcl
138103
cd /usr/local/src/btr_client/
139104
drush @bcl_dev php-script dev/config.php dev2
140105
#+END_EXAMPLE
@@ -149,7 +114,7 @@ Development Tools, Tips and Tricks
149114

150115
It can be done with the script =dev/reinstall.sh=:
151116
#+BEGIN_EXAMPLE
152-
chroot /var/chroot/bcl/
117+
docker-enter bcl
153118
cd /usr/local/src/btr_client/
154119
nohup nice dev/reinstall.sh settings.sh &
155120
tail -f nohup.out
@@ -165,7 +130,7 @@ Development Tools, Tips and Tricks
165130
Drupal and nothing else, can be done with the script
166131
=dev/reinstall-db.sh=:
167132
#+BEGIN_EXAMPLE
168-
chroot /var/chroot/bcl/
133+
docker-enter bcl
169134
cd /usr/local/src/btr_client/
170135
nohup nice dev/reinstall-db.sh @bcl_dev &
171136
tail -f nohup.out
@@ -190,7 +155,7 @@ Development Tools, Tips and Tricks
190155
the code (the whole Drupal directory) and the database. It can be
191156
done like this:
192157
#+BEGIN_EXAMPLE
193-
chroot /var/chroot/bcl/
158+
docker-enter bcl
194159
cd /usr/local/src/btr_client/
195160
dev/snapshot.sh make @bcl
196161
dev/snapshot.sh make @bcl_dev
@@ -221,20 +186,56 @@ Development Tools, Tips and Tricks
221186
#+END_EXAMPLE
222187

223188

224-
* Accessing the code of the application from outside chroot
225-
226-
In order to access easily the code of the application from outside
227-
chroot, you can create a symbolic link like this:
228-
#+BEGIN_EXAMPLE
229-
cd /var/chroot/
230-
ln -s bcl/var/www/bcl_dev/profiles/btr_client/ \
231-
bcl_dev
232-
#+END_EXAMPLE
233-
234-
Now you can go to */var/chroot/dev/* and start /emacs/ or any other
235-
tools. This way you don't have to install /emacs/ or any other
236-
development tools inside the /chroot/ and can use the best of
237-
development tools that your host system can offer.
189+
* Accessing the code of the application from outside container
190+
191+
In general it is not possible to directly access the directories and
192+
files of of a container from the host system. However we can use
193+
the docker /volumes/ to share directories between the container and
194+
the host. It can be done like this:
195+
196+
+ First we make a backup of the directory inside the container that
197+
we want to share:
198+
#+BEGIN_EXAMPLE
199+
docker-enter bcl
200+
cd /var/www/bcl_dev/profiles/
201+
cp -a btr_client/ btr_client-bak
202+
exit
203+
#+END_EXAMPLE
204+
205+
+ Then we save the image of the container as =btr_client:dev=, in order
206+
to start a new container based on it:
207+
#+BEGIN_EXAMPLE
208+
docker stop bcl
209+
docker commit bcl btr_client:dev
210+
docker images
211+
#+END_EXAMPLE
212+
213+
+ Next we create a new container that shares a directory with the
214+
host system (using the option =-v=):
215+
#+BEGIN_EXAMPLE
216+
docker run -d --name=bcl_dev --hostname=dev.example.org \
217+
-v $(pwd)/bcl_dev:/var/www/bcl_dev/profiles/btr_client/
218+
-p 80:80 -p 443:443 btr_client:dev
219+
#+END_EXAMPLE
220+
*Note:* The container *bcl* must be stoped before we create and
221+
start the new container *bcl_dev*, otherwise the ports 80 and 443
222+
will conflict.
223+
224+
+ Finally we enter the container and move the content of the backup
225+
directory to the shared directory:
226+
#+BEGIN_EXAMPLE
227+
docker-enter bcl_dev
228+
cd /var/www/bcl_dev/profiles/btr_client/
229+
cp -a ../btr_client-bak/* .
230+
cp -a ../btr_client-bak/.* .
231+
rm -rf ../btr_client-bak/
232+
exit
233+
#+END_EXAMPLE
234+
235+
Now we can go to the directory *bcl_dev/* and start /emacs/ or any
236+
other tools. This way we don't have to install /emacs/ or any other
237+
development tools inside the container and we can use the best of
238+
development tools that the host system can offer.
238239

239240

240241
* Pushing commits
@@ -289,7 +290,7 @@ Development Tools, Tips and Tricks
289290
At some point, all the modifications on the local copy of the
290291
application (sandbox) have to be transferred to a public server,
291292
where the application is in "production", performing "live". On that
292-
public server there is the same /chroot/ environment as in the
293+
public server there is the same docker container as in the
293294
development server. The synchronization of the application can be
294295
done via git push and pull.
295296

@@ -371,8 +372,8 @@ Development Tools, Tips and Tricks
371372
option on the config file will make sure that it fails.
372373

373374
For drush commands to work remotely, *ssh* daemon has to be running
374-
on the remote server, inside the chroot environment. By default it
375-
is not installed, but it can be installed with the script
375+
on the remote server, inside the docker container. By default it is
376+
not installed, but it can be installed with the script
376377
*dev/install-sshd.sh*. This script will also take care to change the
377378
ssh port to *2201*, in order to avoid any conflicts with any
378379
existing daemon on the host environment, and also for increased

0 commit comments

Comments
 (0)