From b4c2cec043a91368a9cfea03f24d1b7fa71c6c36 Mon Sep 17 00:00:00 2001 From: 05412 <2738076308@qq.com> Date: Tue, 23 Jul 2024 17:54:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=B9=E5=99=A8=E5=8C=96=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 5 +++++ README.MD | 3 +++ docker-compose.yml | 33 ++++++++++++++++++++++++++++++ src/main/resources/application.yml | 4 ++-- 4 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..061d0e6 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,5 @@ +FROM amazoncorretto:21 +COPY . /usr/src/surl +WORKDIR /usr/src/surl +RUN chmod 754 ./gradlew && ./gradlew build -x test +CMD ["java", "-jar", "./build/libs/surl-0.0.1-SNAPSHOT.jar"] diff --git a/README.MD b/README.MD index b0e88a6..65dca56 100644 --- a/README.MD +++ b/README.MD @@ -8,6 +8,9 @@ ### 环境变量 +- `PROTOCOL`: 外链协议 +- `HOST`: 主机 +- `PORT`: 端口 - `DB_HOST`: 数据库主机, 必选 - `DB_PORT`: 数据库主机端口, 可选 - `DB_PASS`: 数据库密码, 必选 diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..d036612 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,33 @@ +version: '3' +networks: + surl-network: + external: true +services: + surl: + image: surl + restart: no + ports: + - "127.0.0.1:1888:1888" + networks: + - surl-network + environment: + PROTOCOL: http + HOST: localhost + PORT: 18888 + DB_HOST: postgres_forsurl + DB_PORT: 5432 +# DB_PASS: PASSWORD4DB + REDIS_HOST: redis_forsurl +# SECRET_KEY: ne09xhakcvoi13$>":<[]. + redis_forsurl: + image: redis:latest + restart: no + networks: + - surl-network + postgres_forsurl: + image: postgres:latest + restart: no + networks: + - surl-network +# environment: +# POSTGRES_PASSWORD: "PASSWORD4DB" diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 2a66683..53d7157 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,5 +1,5 @@ server: - port: 18888 # 端口 + port: ${PORT:18888} # 端口 spring: profiles: active: default # 激活配置 @@ -47,7 +47,7 @@ logging: # 基础配置: dev.surl.surl.cfg.BaseConfig base: configs: - site: http://localhost:${server.port} # 站点 + site: ${PROTOCOL:http}://${HOST:localhost}:${server.port} # 站点 expire: 6 # 过期时间 unit: hours # 单位 secret: ${SECRET_KEY:} # 密钥