Dockerfile
FROM maven:3.6.2-jdk-8-slim AS builder
COPY digit/digit-life-service /build/
WORKDIR /build/
RUN --mount=type=cache,target=/root/.m2 mvn clean install -P test -Dmaven.test.skip=true
FROM openjdk:8-slim
WORKDIR /apps
COPY --from=builder /build/ruoyi-admin/target/ruoyi-admin.jar /apps/ruoyi-admin.jar
EXPOSE 8084
CMD ["java", "-jar", "ruoyi-admin.jar"]
构建 image
docker build -t myapp-jar:v1.0 -f Dockerfile .
docker-compose.yaml
services:
myapp-jar:
image: myapp-jar:v1.0
container_name: myapp-jar
restart: always
volumes:
- ./logs:/apps/logs
networks:
- myapp
ports:
- 8084:8084
networks:
myapp:
driver: bridge
运行 image
docker compose up -d