Forex / Dockerfile
subjectid's picture
Create Dockerfile
17189ab verified
Raw
History Blame Contribute Delete
1.44 kB
FROM gradle:9.6-jdk21 AS build
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/subjectid1/claude.git" target
WORKDIR /app/target
RUN chmod +x ./gradlew
RUN ./gradlew bootJar
FROM mongo:8.0 AS Runner
# Install Java 21 (using Debian/Ubuntu base of the Mongo image)
RUN apt-get update && apt-get install -y \
openjdk-21-jdk \
&& rm -rf /var/lib/apt/lists/*
# 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 mkdir -p /data/db
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=build 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 & java $JAVA_OPTS -jar app.jar"]
#ENTRYPOINT ["sh", "-c", "mongod --bind_ip_all&&exec java -jar app.jar --server.port=7860"]