Skip to content

Commit 7da46cd

Browse files
author
Martino Visintin
committed
Dockerize cloujera, update deploy
1 parent a49468c commit 7da46cd

File tree

4 files changed

+53
-12
lines changed

4 files changed

+53
-12
lines changed

Dockerfile

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM java:7
2+
3+
ADD ./target/uberjar/cloujera-0.1.0-SNAPSHOT-standalone.jar /srv/cloujera.jar
4+
5+
EXPOSE 8080
6+
7+
CMD ["java", "-jar", "/srv/cloujera.jar"]

README.md

+25-9
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,30 @@ videos on [coursera](http://coursera.org).
2020
(it will error out ridiculously with an `IndexMissingException` from
2121
elasticsearch if you don't do this!);
2222

23+
### Testing dockerized cloujera inside Vagrant VM
2324

24-
## Testing uberjar inside Vagrant
25+
```bash
26+
$ vagrant ssh
27+
$ cd /vagrant
28+
$ ./scripts/deploy.sh
29+
```
30+
31+
**NOTE:** the address to access the dockerized cloujera is
32+
`http://127.0.0.1:8081` (see `Vagrantfile`)
33+
34+
35+
### Testing uberjar inside Vagrant
2536

2637
```bash
2738
$ vagrant ssh
2839
$ cd /vagrant
2940
$ source ./scripts/prod-env.sh
30-
$ ./scripts/deploy.sh
41+
$ lein uberjar
42+
$ java -jar ./target/uberjar/cloujera-*-standalone.jar
3143
```
3244

3345
**NOTE:** the address to access the uberjarred cloujera running on port `8080`
34-
is `http://127.0.0.1:8081` (see `Vagrantfile`)
35-
36-
**FIXME**: the sourcing of prod-env.sh is just a temporary fix while we move to
37-
docker ....
46+
is `http://127.0.0.1:8082` (see `Vagrantfile`)
3847

3948

4049
## Scraping courses
@@ -76,7 +85,6 @@ $ sudo ./scripts/provision.sh
7685

7786
```bash
7887
# in the cloujera directory...
79-
$ source ./scripts/prod-env.sh
8088
$ ./scripts/deploy.sh
8189
```
8290

@@ -92,13 +100,14 @@ $ vagrant ssh
92100
$ sudo docker ps -a
93101
```
94102

95-
You should see `redis` and `elasticsearch` running
103+
You should see `redis`, `elasticsearch` and `cloujera` running
96104

97105

98106
### Checking the cloujera logs
99107

100108
```bash
101-
$ cat cloujera.log
109+
$ vagrant ssh
110+
$ sudo docker exec cloujera cat /var/cloujera.log
102111
```
103112

104113
### Checking elasticsearch health
@@ -114,6 +123,13 @@ Visit `http://localhost:9200/`, you should see `status: 200`
114123
**NOTE**: this works form the host as well as in the Vagrant VM
115124

116125

126+
### Dropping into a shell inside a container
127+
```bash
128+
$ vagrant ssh || ssh user@cloudbox
129+
$ sudo docker exec -i -t cloujera bash
130+
```
131+
132+
117133
# BUGS
118134
- `lein run` doesn't give any output initially
119135
- `lein run` doesn't reload

Vagrantfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
1515
config.vm.network "forwarded_port", guest: 6379, host: 6379
1616

1717
# Cloujera port
18-
config.vm.network "forwarded_port", guest: 8080, host: 8081 # for lein run/uberjar inside VM
18+
config.vm.network "forwarded_port", guest: 80, host: 8081 # for cloujera Docker container
19+
config.vm.network "forwarded_port", guest: 8080, host: 8082 # for lein run/uberjar inside VM
1920

2021
# provisioning: docker, elasticsearch, redis
2122
config.vm.provision "shell", path: "./scripts/provision.sh"

scripts/deploy.sh

+19-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
set -euo pipefail
33
IFS=$'\n\t'
44

5+
sudo -v
6+
7+
cloujera_container_name="cloujera"
8+
cloujera_image_tag=$cloujera_container_name
9+
10+
echo "==> Removing existing cloujera container"
11+
sudo docker rm -f $cloujera_container_name || true
12+
513
echo "==> pulling most recent version (git)"
614
# FIXME: it would be nice to checkout to avoid weird
715
# stuff happening, but it's really easy to run this
@@ -16,5 +24,14 @@ lein cljsbuild once
1624
echo "==> Uberjarring"
1725
lein uberjar
1826

19-
echo "==> Running cloujera"
20-
java -jar ./target/uberjar/cloujera-0.1.0-SNAPSHOT-standalone.jar > cloujera.log 2>&1
27+
echo "==> Building container"
28+
sudo docker build --tag $cloujera_image_tag ./
29+
30+
echo "==> Running container"
31+
sudo docker run \
32+
--detach \
33+
--publish 80:8080 \
34+
--name $cloujera_container_name \
35+
--link redis:redis \
36+
--link elasticsearch:elasticsearch \
37+
$cloujera_image_tag

0 commit comments

Comments
 (0)