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

Commit f390130

Browse files
mcritchlowhweng
authored andcommitted
Use Alpine linux for damspas image
- Change from Debian base to Alpine linux. This brings the overall image size down from 2.2G to 650M.. - Update documentation to reflect usage patterns after some feedback from Vivian and others
1 parent 0ad6cc1 commit f390130

File tree

3 files changed

+56
-18
lines changed

3 files changed

+56
-18
lines changed

Dockerfile

+25-16
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,33 @@
1-
FROM ruby:2.3.7
1+
FROM ruby:2.3.7-alpine
22

33
# Maintainer
44
MAINTAINER "Matt Critchlow <mcritchlow@ucsd.edu">
55

6-
RUN apt-get update -yqq \
7-
&& apt-get install -yqq --no-install-recommends nodejs libicu-dev libfontconfig1-dev libjpeg-dev libfreetype6 \
8-
&& apt-get clean
6+
RUN apk add --no-cache \
7+
build-base \
8+
busybox \
9+
ca-certificates \
10+
curl \
11+
git \
12+
gnupg1 \
13+
gpgme \
14+
less \
15+
libffi-dev \
16+
libxml2-dev \
17+
libxslt-dev \
18+
linux-headers \
19+
libsodium-dev \
20+
nodejs \
21+
openssh-client \
22+
postgresql-dev \
23+
tzdata \
24+
rsync \
25+
wget
926

10-
ENV PHANTOM_JS_TAG 2.1.1
11-
12-
# Downloading bin, unzipping & removing zip
13-
WORKDIR /tmp
14-
RUN wget -q http://cnpmjs.org/mirrors/phantomjs/phantomjs-${PHANTOM_JS_TAG}-linux-x86_64.tar.bz2 -O phantomjs.tar.bz2 \
15-
&& tar xjf phantomjs.tar.bz2 \
16-
&& rm -rf phantomjs.tar.bz2 \
17-
&& mv phantomjs-* phantomjs \
18-
&& mv /tmp/phantomjs/bin/phantomjs /usr/local/bin/phantomjs
19-
20-
RUN echo "phantomjs binary is located at `which phantomjs`" \
21-
&& echo "just run 'phantomjs' (version `phantomjs -v`)"
27+
# Install phantomjs
28+
RUN wget -qO- "https://github.com/dustinblackman/phantomized/releases/download/2.1.1a/dockerized-phantomjs.tar.gz" | tar xz -C / \
29+
&& npm config set user 0 \
30+
&& npm install -g phantomjs-prebuilt
2231

2332
# Trick to copy in Gemfile before other files.
2433
# This way bundle install step only runs again if THOSE files change

docker/README.md

+27-2
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,41 @@ You have two choices for running damspas with Docker:
1212

1313
Setup rails databases:
1414
- Self contained:
15-
- `docker-compose -f docker/dev/docker-compose.yml exec web bundle exec rake db:setup`
15+
- `docker-compose -f docker/dev/docker-compose.yml exec -e RAILS_ENV=test web bundle exec rake db:create db:migrate`
1616
- Dependencies only:
17-
- `bundle exec rake db:setup`
17+
- `RAILS_ENV=test bundle exec rake db:create db:migrate`
1818

1919
Run damspas test suite:
2020
- Self contained:
2121
- `docker-compose -f docker/dev/docker-compose.yml exec web bundle exec rake spec`
2222
- Dependencies only:
2323
- `bundle exec rake spec`
2424

25+
# Development Workflow
26+
If you make changes to the damspas codebase that you want to test, you will need to rebuild the `web`
27+
container which hosts the damspas application. This can be done as follows:
28+
29+
- Kill/stop the running docker-compose session
30+
- Rebuild web container: `docker-compose -f docker/dev/docker-compose.yml build`
31+
- Start docker-compose session again: `docker-compose -f docker/dev/docker-compose.yml up`
32+
- This should only rebuild what is necessary. And won't run `bundle install`
33+
unless you change the Gemfile
34+
35+
## Errors w/ the web container
36+
37+
If you get an error like:
38+
```
39+
web_1 | A server is already running. Check /usr/src/app/tmp/pids/server.pid.
40+
```
41+
42+
You probably didn't cleanly shut down the web container, leaving `tmp` files in
43+
the container and your local repo that prevent a clean start again. In this case, you should remove any files in `tmp/pids` on your local machine/host.
44+
45+
Now recreate the container so it removes the internal temp files:
46+
```
47+
docker-compose -f docker/dev/docker-compose.yml up --force-recreate
48+
```
49+
2550
# Teardown
2651
To remove all containers:
2752
`docker-compose rm`

docker/dev/docker-compose.yml

+4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ services:
1717

1818
database:
1919
image: ucsdlib/docker-postgres-damsrepo
20+
ports:
21+
- "5432:5432"
2022
# volumes:
2123
# - db-data:/var/lib/postgresql/data
2224
env_file:
@@ -37,6 +39,8 @@ services:
3739

3840
tomcat:
3941
image: ucsdlib/docker-tomcat-damsrepo
42+
ports:
43+
- "8080:8080"
4044
command: ["dockerize", "-wait", "tcp://solr:8983", "-timeout", "1m", "-wait", "tcp://database:5432", "-timeout", "1m", "catalina.sh", "run"]
4145
depends_on:
4246
- database

0 commit comments

Comments
 (0)