Skip to content

Commit

Permalink
Features/reduce image size of bq extractor (#279)
Browse files Browse the repository at this point in the history
* Change from openjdk to alpine, reduce image size from 600 something to 40 something mb

* Make a smaller, quicker java image

* Copy from the test dockerfile to the prod dockerfile

* Fixing typo
  • Loading branch information
la3lma authored Sep 12, 2018
1 parent 56bc645 commit c5723d1
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 8 deletions.
24 changes: 21 additions & 3 deletions bq-metrics-extractor/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
FROM openjdk:8u171
FROM alpine:3.7

MAINTAINER CSI "[email protected]"

#
# Copy the files we need
#

COPY script/start.sh /start.sh
COPY config/config.yaml /config/config.yaml

COPY build/libs/bq-metrics-extractor-uber.jar /bq-metrics-extractor.jar

CMD ["/start.sh"]
#
# Load, then dump the standard java classes into the
# image being built, to speed up java load time
# using Class Data Sharing. The "quit" command will
# simply quit the program after it's dumped the list of
# classes that should be cached.
#

CMD ["java", "-Dfile.encoding=UTF-8", "-Xshare:on", "-Xshare:dump", "-jar", "/bq-metrics-extractor.jar", "quit", "config/config.yaml"]


#
# Finally the actual entry point
#

ENTRYPOINT ["/start.sh"]
24 changes: 21 additions & 3 deletions bq-metrics-extractor/Dockerfile.test
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
FROM openjdk:8u171
FROM alpine:3.7

MAINTAINER CSI "[email protected]"

#
# Copy the files we need
#

COPY script/start.sh /start.sh
COPY config/pantel-prod.json /secret/pantel-prod.json
COPY config/config.yaml /config/config.yaml

COPY build/libs/bq-metrics-extractor-uber.jar /bq-metrics-extractor.jar

CMD ["/start.sh"]
#
# Load, then dump the standard java classes into the
# image being built, to speed up java load time
# using Class Data Sharing. The "quit" command will
# simply quit the program after it's dumped the list of
# classes that should be cached.
#

CMD ["java", "-Dfile.encoding=UTF-8", "-Xshare:on", "-Xshare:dump", "-jar", "/bq-metrics-extractor.jar", "quit", "config/config.yaml"]


#
# Finally the actual entry point
#

ENTRYPOINT ["/start.sh"]
5 changes: 3 additions & 2 deletions bq-metrics-extractor/script/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@

# Start app
exec java \
-Dfile.encoding=UTF-8 \
-jar /bq-metrics-extractor.jar query --pushgateway pushgateway:8080 config/config.yaml
-Dfile.encoding=UTF-8 \
-Xshare:on \
-jar /bq-metrics-extractor.jar query --pushgateway pushgateway:8080 config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -310,4 +310,14 @@ private class CollectAndPushMetrics : ConfiguredCommand<BqMetricsExtractorConfig
.required(true)
.help("The pushgateway to report metrics to, format is hostname:portnumber")
}

private class CollectAndPushMetrics : ConfiguredCommand<BqMetricsExtractorConfig>(
"quit",
"Do nothing, only used to prime caches") {
override fun run(bootstrap: Bootstrap<BqMetricsExtractorConfig>?,
namespace: Namespace?,
configuration: BqMetricsExtractorConfig?) {
// Doing nothing, as advertised.
}
}
}

0 comments on commit c5723d1

Please sign in to comment.