|
| 1 | +# ============================================================ |
| 2 | +# Build stage 1: Builder |
| 3 | +# ============================================================ |
| 4 | + |
1 | 5 | FROM maven:3.6-jdk-8-slim as builder |
2 | 6 | ARG REVISION=dev |
3 | 7 | COPY . /build |
4 | 8 | WORKDIR /build |
| 9 | +# |
5 | 10 | # Setting Maven repository .m2 directory relative to /build folder gives the |
6 | 11 | # user to optionally use cached repository when building the image by copying |
7 | 12 | # the existing .m2 directory to $FEAST_REPO_ROOT/.m2 |
| 13 | +# |
8 | 14 | ENV MAVEN_OPTS="-Dmaven.repo.local=/build/.m2/repository -DdependencyLocationsEnabled=false" |
9 | 15 | RUN mvn --also-make --projects core,ingestion -Drevision=$REVISION \ |
10 | 16 | -DskipTests=true --batch-mode package |
| 17 | +# |
| 18 | +# Unpack the jar and copy the files into production Docker image |
| 19 | +# for faster startup time when starting Dataflow jobs from Feast Core. |
| 20 | +# This is because we need to stage the classes and dependencies when using Dataflow. |
| 21 | +# The final size of the production image will be bigger but it seems |
| 22 | +# a good tradeoff between speed and size. |
| 23 | +# |
| 24 | +# https://github.com/gojek/feast/pull/291 |
| 25 | +RUN apt-get -qq update && apt-get -y install unar && \ |
| 26 | + unar /build/core/target/feast-core-$REVISION.jar -o /build/core/target/ |
| 27 | + |
| 28 | +# ============================================================ |
| 29 | +# Build stage 2: Production |
| 30 | +# ============================================================ |
11 | 31 |
|
12 | 32 | FROM openjdk:8-jre as production |
13 | 33 | ARG REVISION=dev |
14 | 34 | COPY --from=builder /build/core/target/feast-core-$REVISION.jar /opt/feast/feast-core.jar |
| 35 | +COPY --from=builder /build/core/target/feast-core-$REVISION /opt/feast/feast-core |
15 | 36 | CMD ["java",\ |
16 | 37 | "-Xms2048m",\ |
17 | 38 | "-Xmx2048m",\ |
|
0 commit comments