-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactors build to use a parent pom and not rely on Docker Build Kit
This simplifies the build a lot by using a parent pom (as suggested by @trustin) This simplifies further by moving some configuration management to `build_image`.
- Loading branch information
adriancole
committed
Oct 9, 2020
1 parent
7860a66
commit ed1c9b7
Showing
21 changed files
with
316 additions
and
453 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
**/target | ||
|
||
**/.idea | ||
**/*.iml | ||
**/*.md | ||
|
||
**/Dockerfile | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,8 @@ | ||
# docker rationale | ||
|
||
## Why do we set `--build-arg target` to the same value as `--target`? | ||
## Why does `build_image` manually parse XML? | ||
|
||
There are very few differences in our docker images from a scripting point of | ||
view. However, each has different contents, and most have a different base | ||
layer. We need to know the target stage before we create it, so that we can | ||
build the right contents. There's no known way to read the value of the | ||
`--target` parameter. Hence, we duplicate it as a build argument. | ||
|
||
One impact of doing this is `DOCKER_BUILDKIT=1` or similar is required to skip | ||
unused phases present in the process of building the image. | ||
`build_image` is a script used to build Docker images per project. We need | ||
some details from the pom file for build arguments. Rather than require | ||
installing an XML parser or invoking Maven, this uses `sed` which is commonly | ||
present on developer laptions and CI nodes. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#!/bin/sh | ||
set -eu | ||
|
||
mkdir install | ||
mkdir -p install/bin | ||
|
||
# extract the exec jar | ||
cd install && jar xf ../target/*-exec.jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
#!/bin/sh | ||
set -eu | ||
|
||
mkdir -p install/bin | ||
|
||
# Copy dependencies and compiled classes | ||
mvn -q --batch-mode dependency:copy-dependencies -DoutputDirectory=install/lib | ||
cp -r target/classes install/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,8 @@ | ||
#!/bin/sh | ||
|
||
set -eu | ||
|
||
case "$1" in | ||
f|frontend|Frontend ) | ||
CLASS_NAME=Frontend | ||
PORT=8081 | ||
;; | ||
b|backend|Backend ) | ||
CLASS_NAME=Backend | ||
PORT=9000 | ||
;; | ||
* ) | ||
echo "Invalid argument: specify frontend or backend" | ||
exit 1 | ||
esac | ||
|
||
# write the docker-healthcheck url to a file | ||
IP="$(hostname -i || echo '127.0.0.1')" | ||
echo http://${IP}:${PORT}/health > health_url | ||
JAVA_OPTS=${JAVA_OPTS:-"-Xms32m -Xmx64m -XX:+ExitOnOutOfMemoryError"} | ||
|
||
exec java ${JAVA_OPTS} -cp . \ | ||
-Dzipkin.endpoint=${ZIPKIN_ENDPOINT:=http://zipkin:9411/api/v2/spans} \ | ||
-Dzipkin.supportsJoin=${ZIPKIN_SUPPORTS_JOIN:=true} \ | ||
-Dbackend.endpoint=${BACKEND_ENDPOINT:=http://backend:9000/api} \ | ||
-Dloader.main=brave.webmvc.${CLASS_NAME} org.springframework.boot.loader.PropertiesLauncher \ | ||
--server.port=${PORT} | ||
-Dloader.main=brave.webmvc.$(echo "${ZIPKIN_SERVICE}" | sed 's/.*/\u&/') \ | ||
org.springframework.boot.loader.PropertiesLauncher --server.port=${PORT} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/sh | ||
|
||
set -eu | ||
|
||
case "$1" in | ||
frontend ) | ||
ZIPKIN_SERVICE=frontend | ||
PORT=8081 | ||
;; | ||
backend ) | ||
ZIPKIN_SERVICE=backend | ||
PORT=9000 | ||
;; | ||
* ) | ||
echo "Invalid argument: specify frontend or backend" | ||
exit 1 | ||
esac | ||
|
||
# write the docker-healthcheck url to a file | ||
IP="$(hostname -i || echo '127.0.0.1')" | ||
echo http://${IP}:${PORT}/health > health_url |
Oops, something went wrong.