Skip to content

Commit 5761688

Browse files
committed
添加编译脚本
1 parent 9d5d156 commit 5761688

3 files changed

Lines changed: 60 additions & 1 deletion

File tree

‎Dockerfile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
FROM eclipse-temurin:24-jre-alpine
1212
LABEL org.opencontainers.image.authors="yanglb <dev@yanglb.com>"
1313

14-
COPY ./target/code-generator-*-jar-with-dependencies.jar /usr/local/lib/cg/bin/cg.jar
14+
COPY ./cg.jar /usr/local/lib/cg/bin/cg.jar
1515
COPY ./cg /usr/local/bin/cg
1616

1717
CMD [ "cg" ]

‎build-docker.sh‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env bash
2+
3+
# Build Script for cg project.
4+
# Author: me@yanglb.com
5+
# Date: 2026/10/26
6+
7+
set -euo pipefail
8+
9+
function printUsage {
10+
echo "Build cg docker image."
11+
echo "Usage: ./build-docker.sh [TAG] [options]"
12+
echo ""
13+
echo "TAG image version default is latest"
14+
echo ""
15+
echo "Options"
16+
echo " -h --help Print usage."
17+
}
18+
19+
TAG=${1:-"latest"}
20+
if [ $TAG = '-h' ] || [ $TAG = '--help' ];then
21+
printUsage
22+
exit 0
23+
fi
24+
25+
echo "Build docker image for yanglibing/code-generator:${TAG}"
26+
27+
# build docker
28+
docker buildx build . \
29+
--tag yanglibing/code-generator:${TAG} \
30+
--provenance=false \
31+
--output type=docker \
32+
--platform linux/amd64,linux/arm64
33+
34+
# publish
35+
docker push yanglibing/code-generator:${TAG}

‎build.sh‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6+
POM="$PROJECT_DIR/pom.xml"
7+
VERSION="$(mvn -q -f "$POM" -DforceStdout help:evaluate -Dexpression=project.version)"
8+
JAR="$PROJECT_DIR/target/code-generator-$VERSION-jar-with-dependencies.jar"
9+
10+
if [ -z "$VERSION" ]; then
11+
echo "Could not determine project version from pom.xml." >&2
12+
exit 1
13+
fi
14+
15+
echo "Building project..."
16+
mvn -f "$POM" clean package
17+
18+
if [ ! -f "$JAR" ]; then
19+
echo "Expected build artifact not found: $JAR" >&2
20+
exit 1
21+
fi
22+
23+
cp "$JAR" "$PROJECT_DIR/cg.jar"
24+
echo "Built ${JAR##*/} and copied it to cg.jar."

0 commit comments

Comments
 (0)