Skip to content

Commit c2120c4

Browse files
committed
Slim down the image
Don't package test deps, tests and a few other support files.
1 parent 7d380c3 commit c2120c4

File tree

6 files changed

+35
-13
lines changed

6 files changed

+35
-13
lines changed

.dockerignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1-
.git
1+
.*
2+
Makefile
3+
Dockerfile
4+
README.md
5+
spec
6+
circle.yml

Dockerfile

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
FROM ruby:2.4-alpine
22
LABEL maintainer="Code Climate <[email protected]>"
33

4-
RUN apk --update add grep
5-
64
WORKDIR /usr/src/app
75

8-
COPY Gemfile* ./
9-
RUN gem install -g
10-
116
RUN adduser -u 9000 -D app
12-
RUN chown -R app:app /usr/src/app
13-
USER app
7+
8+
RUN apk --no-cache add grep
9+
10+
COPY Gemfile* ./
11+
RUN bundler install --no-cache --without=test --system && \
12+
chown -R app:app /usr/local/bundle && \
13+
rm -r ~/.bundle
1414

1515
COPY . ./
1616

17+
RUN chown -R app:app . && \
18+
ln engine.json /
19+
20+
USER app
1721
VOLUME /code
1822
WORKDIR /code
1923

Dockerfile.test

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM codeclimate/codeclimate-grep
2+
3+
WORKDIR /usr/src/app
4+
5+
RUN bundler install --no-cache --with=test --system && \
6+
chown -R app:app /usr/local/bundle && \
7+
rm -r ~/.bundle

Makefile

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@
33
IMAGE_NAME ?= codeclimate/codeclimate-grep
44

55
image:
6-
docker build --rm -t $(IMAGE_NAME) .
6+
docker build --tag $(IMAGE_NAME) .
77

8-
test: image
9-
docker run --rm --workdir /usr/src/app $(IMAGE_NAME) sh -c "rspec"
8+
test-image: image
9+
docker build --tag $(IMAGE_NAME)-test --file Dockerfile.test .
10+
11+
test: test-image
12+
docker run --rm \
13+
--volume $(PWD)/spec:/usr/src/app/spec \
14+
$(IMAGE_NAME)-test \
15+
sh -c "bundle exec rspec"

circle.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ dependencies:
1212
--env GCR_JSON_KEY
1313
--volume /var/run/docker.sock:/var/run/docker.sock
1414
codeclimate/patrick pull || true
15-
- make image
15+
- make test-image
1616

1717
test:
1818
override:

engine.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
"email": "[email protected]"
77
},
88
"languages" : ["*"],
9-
"version": "0.1",
9+
"version": "0.1.1",
1010
"spec_version": "0.3.1"
1111
}

0 commit comments

Comments
 (0)