File size: 1,446 Bytes
3bd8a27
42bd693
a3c6e68
 
ed3f81f
5d0391a
287ebad
 
1a35679
287ebad
9101a4e
287ebad
 
 
45c2f9a
287ebad
 
9101a4e
287ebad
 
 
5d0391a
287ebad
 
 
 
45c2f9a
287ebad
 
 
 
 
 
 
 
5d0391a
287ebad
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
FROM gradle:9.6-jdk21 AS builder
WORKDIR /app
RUN --mount=type=secret,id=TOKEN,target=/run/secrets/TOKEN \
    export SECRET_VALUE=$(cat /run/secrets/TOKEN) && \
    git clone "https://subjectid1:${SECRET_VALUE}@github.com/subjectid65/sms.git" target
WORKDIR /app/target
     RUN chmod +x ./gradlew
    RUN ./gradlew bootJar
FROM mongo:latest AS Runner
# Install Java 21 (using Debian/Ubuntu base of the Mongo image)
RUN apt-get update && apt-get install -y openjdk-21-jre && mkdir -p /data/db
# Copy the built JAR from the builder stage
# WORKDIR /app
# COPY --from=builder /app/target/*.jar app.jar

# Expose Java (8080) and MongoDB (27017) ports
# EXPOSE 8080 27017
 
RUN chown -R 10014:10014 /data/db
USER 10014
 

# Start MongoDB and the Java application concurrently
# CMD ["sh", "-c", "mongod --bind_ip_all & java -jar app.jar"]

 
ENV JAVA_OPTS="-Dserver.port=7860 -XX:InitialRAMPercentage=50.0 -XX:MaxRAMPercentage=75.0"
COPY --from=builder app/target/build/libs/*.jar app/app.jar
 
 
WORKDIR app
 
 
 
#USER ROOT

EXPOSE 7860 27017
 
# 赋予执行权限
#RUN chmod +x /entrypoint.sh
# 设置入口
# ENTRYPOINT ["/entrypoint.sh"]

#ENTRYPOINT ["sh", "-c", "mongod --bind_ip_all","&&java", "-jar", "app.jar", "--server.port=7860"]
#CMD ["sh", "-c", "mongod --bind_ip_all"]
CMD ["sh", "-c", "mongod --bind_ip_all & java $JAVA_OPTS -jar app.jar"]
#ENTRYPOINT ["sh", "-c", "mongod --bind_ip_all&&exec java -jar app.jar --server.port=7860"]