mirror of
https://github.com/jeequan/jeepay
synced 2024-11-17 14:58:04 +08:00
添加 Docker 支持
编译命令 ``` docker buildx build . --build-arg PORT=9216 --build-arg PLATFORM=payment -t jeepay-payment:latest ``` ``` docker buildx build . --build-arg PORT=9217 --build-arg PLATFORM=manager -t jeepay-manager:latest ``` ``` docker buildx build . --build-arg PORT=9218 --build-arg PLATFORM=merchant -t jeepay-merchant:latest ``` 如果你需要多平台镜像,你可以使用 `--platform linux/amd64,linux/arm64` ``` docker buildx build . --build-arg PORT=9218 --build-arg PLATFORM=merchant -t jeepay-merchant:latest --platform linux/amd64,linux/arm64 ``` 启动命令 ``` docker run -d -p 9216:9216 jeepay-payment:latest ``` ``` docker run -d -p 9217:9217 jeepay-manager:latest ``` ``` docker run -d -p 9218:9218 jeepay-merchant:latest ``` ## Docker Compose 一次性运行所有环境 由于每个人的环境都不太一样,这里没有添加到项目内,可以放到文档里作为 demo ``` version: '3' services: mysql: hostname: mysql container_name: mysql # image: mysql:8 image: mysql/mysql-server:latest ports: - '3306:3306' environment: MYSQL_ROOT_PASSWORD: 'root' MYSQL_DATABASE: 'jeepay' volumes: - './data/mysql:/var/lib/mysql' - './data/mysql/conf.d:/etc/mysql/conf.d' - './data/mysql/log:/var/log/mysql' - './data/mysql/data:/var/lib/mysql/data' - './docs/sql/init.sql:/workspace/init.sql' # activemq 并没有官方维护的 Docker 镜像这里不推荐使用。 # activemq: # container_name: activemq # image: activemq:5.15.3 # ports: # - '61616:61616' # - '8161:8161' # environment: # ACTIVEMQ_USER: 'admin' # ACTIVEMQ_PASSWORD: 'admin' # rocketmq 配置 https://github.com/apache/rocketmq-docker # rabbitmq: # hostname: rabbitmq # container_name: rabbitmq # image: rabbitmq:latest # ports: # - "15672:15672" # - "4369:4369" # - "5672:5672" # - "25672:25672" # environment: # RABBITMQ_DEFAULT_USER: 'admin' # RABBITMQ_DEFAULT_PASS: 'admin' # RABBITMQ_DEFAULT_VHOST: 'jeepay' # volumes: # - './data/rabbitmq:/var/lib/rabbitmq' # - './data/rabbitmq/conf:/etc/rabbitmq' # - './data/rabbitmq/log:/var/log/rabbitmq' # - './data/rabbitmq/data:/var/lib/rabbitmq/data' payment: build: context: . dockerfile: Dockerfile args: PORT: 9216 PLATFORM: payment image: jeepay_payment:latest hostname: payment container_name: jeepay-payment ports: - "9216:9216" depends_on: - mysql # - rabbitmq manager: build: context: . dockerfile: Dockerfile args: PORT: 9217 PLATFORM: manager image: jeepay_manager:latest hostname: manager container_name: jeepay-manager ports: - "9217:9217" depends_on: - mysql # - rabbitmq merchant: build: context: . dockerfile: Dockerfile args: PORT: 9218 PLATFORM: merchant image: jeepay_merchant:latest hostname: merchant container_name: jeepay-merchant ports: - "9218:9218" depends_on: - mysql # - rabbitmq ```
This commit is contained in:
parent
2b04ff54de
commit
b86b55cafa
42
Dockerfile
Normal file
42
Dockerfile
Normal file
@ -0,0 +1,42 @@
|
||||
# syntax = docker/dockerfile:experimental
|
||||
# 使用了 Docker 特性 Buildx 请开启相关特性
|
||||
|
||||
# 切换 JDK 请修改后面的 17 到对应版本
|
||||
# docker build -t jeepay-deps:latest -f docs/Dockerfile .
|
||||
|
||||
# 编译依赖缓存,请先执行上方命令
|
||||
FROM jeepay-deps:latest AS builder
|
||||
|
||||
WORKDIR /workspace
|
||||
|
||||
COPY . /workspace
|
||||
|
||||
RUN mvn clean package -Dmaven.test.skip=true -Ptest
|
||||
|
||||
|
||||
# 以下为运行容器 切换 JDK 请修改后面的 17 到对应版本
|
||||
FROM mcr.microsoft.com/java/jre:17-zulu-alpine
|
||||
|
||||
ARG PLATFORM=$PLATFORM
|
||||
|
||||
WORKDIR /workspace
|
||||
|
||||
COPY --from=builder /workspace/jeepay-${PLATFORM}/target/jeepay-${PLATFORM}.jar /workspace/jeepay-app.jar
|
||||
COPY --from=builder /workspace/conf/${PLATFORM}/application.yml /workspace/application.yml
|
||||
|
||||
EXPOSE $PORT
|
||||
|
||||
CMD ["java", "-jar", "/workspace/jeepay-app.jar"]
|
||||
|
||||
# 编译命令
|
||||
# docker buildx build . --build-arg PORT=9216 --build-arg PLATFORM=payment -t jeepay-payment:latest
|
||||
# docker buildx build . --build-arg PORT=9217 --build-arg PLATFORM=manager -t jeepay-manager:latest
|
||||
# docker buildx build . --build-arg PORT=9218 --build-arg PLATFORM=merchant -t jeepay-merchant:latest
|
||||
#
|
||||
# 如果你需要多平台镜像,你可以使用 --platform linux/amd64,linux/arm64
|
||||
# 比如 docker buildx build . --build-arg PORT=9218 --build-arg PLATFORM=merchant -t jeepay-merchant:latest --platform linux/amd64,linux/arm64
|
||||
#
|
||||
# 启动命令
|
||||
# docker run -d -p 9216:9216 jeepay-payment:latest
|
||||
# docker run -d -p 9217:9217 jeepay-manager:latest
|
||||
# docker run -d -p 9218:9218 jeepay-merchant:latest
|
5
docs/Dockerfile
Normal file
5
docs/Dockerfile
Normal file
@ -0,0 +1,5 @@
|
||||
FROM maven:3-eclipse-temurin-17
|
||||
|
||||
WORKDIR /build
|
||||
COPY . .
|
||||
RUN mvn dependency:go-offline
|
Loading…
Reference in New Issue
Block a user