Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
java21-template
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
eazy-template
java21-template
Commits
f9dfa974
Commit
f9dfa974
authored
Sep 18, 2025
by
xiezhi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix makefile
parent
9673126d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
10 deletions
+21
-10
Dockerfile
Dockerfile
+5
-2
docker-entrypoint.sh
docker-entrypoint.sh
+16
-8
No files found.
Dockerfile
View file @
f9dfa974
...
@@ -17,8 +17,11 @@ RUN chmod +x docker-entrypoint.sh
...
@@ -17,8 +17,11 @@ RUN chmod +x docker-entrypoint.sh
# 编译Java程序
# 编译Java程序
RUN
make
install
RUN
make
install
# 创建JAR文件
# 创建JAR文件 (直接在Dockerfile中创建)
RUN
make jar
RUN
mkdir
-p
build
&&
\
cd
build
&&
\
echo
"Main-Class: com.example.HelloWorld"
>
manifest.txt
&&
\
jar cfm hello-world.jar manifest.txt
-C
classes .
# 设置环境变量
# 设置环境变量
ENV
APP_PORT_1=8080
ENV
APP_PORT_1=8080
...
...
docker-entrypoint.sh
View file @
f9dfa974
...
@@ -16,14 +16,22 @@ if ! command -v java &> /dev/null; then
...
@@ -16,14 +16,22 @@ if ! command -v java &> /dev/null; then
exit
1
exit
1
fi
fi
# 检查编译后的类文件是否存在
# 检查JAR文件或编译后的类文件
if
[
!
-d
"build/classes"
]
;
then
if
[
-f
"build/hello-world.jar"
]
;
then
echo
"使用JAR文件启动HTTP服务器..."
echo
"服务器将在端口
${
APP_PORT_1
:-
8080
}
上运行"
echo
"=========================================="
exec
java
-jar
build/hello-world.jar
elif
[
-d
"build/classes"
]
;
then
echo
"使用类文件启动HTTP服务器..."
echo
"服务器将在端口
${
APP_PORT_1
:-
8080
}
上运行"
echo
"=========================================="
exec
java
-cp
build/classes com.example.HelloWorld
else
echo
"编译Java源代码..."
echo
"编译Java源代码..."
make
install
make
install
echo
"启动HTTP服务器..."
echo
"服务器将在端口
${
APP_PORT_1
:-
8080
}
上运行"
echo
"=========================================="
exec
java
-cp
build/classes com.example.HelloWorld
fi
fi
# 运行HTTP服务器
echo
"启动HTTP服务器..."
echo
"服务器将在端口
${
APP_PORT_1
:-
8080
}
上运行"
echo
"=========================================="
exec
java
-cp
build/classes com.example.HelloWorld
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment