Skip to content

Commit 6483893

Browse files
Ivan Luzyanindblandin
Ivan Luzyanin
authored andcommitted
Implement two-stage build of the Docker image
1 parent 80609af commit 6483893

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

Dockerfile

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
FROM bigtruedata/sbt:0.13.15-2.12.2 AS builder
2+
WORKDIR /code
3+
ADD project/ /code/project
4+
ADD build.sbt /code
5+
6+
## force sbt to load dependencies and compile interface
7+
RUN mkdir -p src/main/scala && \
8+
echo "object Main {}" > src/main/scala/Main.scala && \
9+
sbt compile && rm -rf src
10+
11+
## copy source code and create an assembly jar
12+
COPY . /code
13+
RUN sbt assembly
14+
15+
# Build main image
116
FROM openjdk:alpine
217

318
LABEL maintainer "Ivan Luzyanin <[email protected]>"
@@ -9,7 +24,7 @@ RUN addgroup -g 9000 -S code && \
924
adduser -S -G code app
1025
USER app
1126

12-
COPY codeclimate-scalastyle-assembly-0.1.0.jar /usr/src/app/engine-core.jar
27+
COPY --from=builder /code/target/scala-2.12/codeclimate-scalastyle-assembly-0.1.0.jar /usr/src/app/engine-core.jar
1328
COPY src/main/resources/docker /usr/src/app
1429
COPY src/main/resources/docker/engine.json /
1530

build.sbt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name := "codeclimate-scalastyle"
22
organization in ThisBuild := "codeclimate"
33
version in ThisBuild := "0.1.0"
4-
scalaVersion in ThisBuild := "2.12.4"
4+
scalaVersion in ThisBuild := "2.12.2"
55

66
concurrentRestrictions in Global += Tags.limit(Tags.Test, 1)
77
parallelExecution in Global := false
-22.4 MB
Binary file not shown.

project/build.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=0.13.16
1+
sbt.version=0.13.15

0 commit comments

Comments
 (0)