Skip to content

Commit 6d12dff

Browse files
committed
move build and testing into docker multi-stage
1 parent c779303 commit 6d12dff

File tree

2 files changed

+35
-4
lines changed

2 files changed

+35
-4
lines changed

Dockerfile

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
FROM groovy:jre8-alpine
2-
1+
#
2+
# Build stage
3+
#
4+
FROM groovy:jre8-alpine as builder
35
MAINTAINER "Jeremy Isikoff <jeremy+codeclimate-codenarc@cinchfinancial.com>"
46

57
USER root
@@ -8,11 +10,41 @@ RUN apk update && \
810
apk add ca-certificates wget curl jq && \
911
update-ca-certificates
1012

13+
COPY . /usr/src/app
14+
15+
WORKDIR /usr/src/app
16+
17+
RUN ./gradlew clean compileGroovy infra test --info
18+
19+
#
20+
# Runtime
21+
#
22+
FROM groovy:jre8-alpine
23+
MAINTAINER "Jeremy Isikoff <jeremy+codeclimate-codenarc@cinchfinancial.com>"
24+
25+
USER root
26+
27+
WORKDIR /usr/src/app
28+
29+
# Test and debug depedencies
30+
COPY --from=builder /usr/src/app/Dockerfile /usr/src/app/Dockerfile
31+
COPY --from=builder /usr/src/app/engine.json /usr/src/app/engine.json
32+
COPY --from=builder /usr/src/app/build.gradle /usr/src/app/build.gradle
33+
COPY --from=builder /usr/src/app/gradle /usr/src/app/gradle
34+
COPY --from=builder /usr/src/app/gradlew /usr/src/app/gradlew
35+
COPY --from=builder /usr/src/app/fixtures /usr/src/app/fixtures
36+
37+
# Runtime dependencies
38+
COPY --from=builder /usr/src/app/src /usr/src/app/src
39+
COPY --from=builder /usr/src/app/lib /usr/src/app/lib
40+
COPY --from=builder /usr/src/app/codenarc /usr/src/app/codenarc
41+
42+
1143
RUN adduser -u 9000 -D app
1244

1345
VOLUME /code
1446
WORKDIR /code
15-
COPY . /usr/src/app
47+
1648
RUN chown -R app:app /usr/src/app
1749

1850
USER app

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
IMAGE_NAME ?= codeclimate/codeclimate-codenarc
44

55
image:
6-
./gradlew clean compileGroovy infra
76
docker build --rm -t $(IMAGE_NAME) .
87

98
test: image

0 commit comments

Comments
 (0)