Skip to content

Commit 9eef628

Browse files
authored
Merge pull request #2 from Le1a/main
Add Docker
2 parents fdb3996 + 733aeaa commit 9eef628

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

Dockerfile

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# 使用 Ubuntu 20.04 基础镜像
2+
FROM ubuntu:20.04
3+
4+
# 设置环境变量以避免交互式安装提示
5+
ENV DEBIAN_FRONTEND=noninteractive
6+
7+
# 清除所有代理环境变量并设置 apt 配置禁用代理
8+
RUN unset http_proxy https_proxy ftp_proxy HTTP_PROXY HTTPS_PROXY FTP_PROXY && \
9+
echo 'Acquire::http::Proxy "false";' > /etc/apt/apt.conf.d/00proxy && \
10+
echo 'Acquire::https::Proxy "false";' >> /etc/apt/apt.conf.d/00proxy
11+
12+
# 更新系统并安装必要的依赖,包括 libc6、wget 和 openjdk-8-jdk
13+
RUN apt-get update && \
14+
apt-get install -y libc6 wget openjdk-8-jdk && \
15+
rm -rf /var/lib/apt/lists/*
16+
17+
# 设置 JAVA_HOME 环境变量
18+
ENV JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
19+
ENV PATH=$JAVA_HOME/bin:$PATH
20+
21+
# 创建应用目录
22+
RUN mkdir /app
23+
24+
# 设置工作目录
25+
WORKDIR /app
26+
27+
# 复制 JAR 文件到容器中的 /app 目录
28+
COPY web-chains-1.0.0-SNAPSHOT.jar /app/
29+
30+
# 复制配置文件目录
31+
COPY chains-config /app/chains-config
32+
33+
# 暴露应用端口
34+
EXPOSE 8011
35+
36+
# 启动命令,后台运行 Java 应用并输出日志
37+
CMD nohup java -jar /app/web-chains-1.0.0-SNAPSHOT.jar > output.log 2>&1 & \
38+
tail -f output.log

docker-compose.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# docker-compose.yml
2+
version: '3'
3+
4+
services:
5+
web-chains:
6+
build: .
7+
ports:
8+
- "8011:8011"
9+
volumes:
10+
- ./chains-config:/app/chains-config
11+
- ./web-chains-1.0.0-SNAPSHOT.jar:/app/web-chains-1.0.0-SNAPSHOT.jar

0 commit comments

Comments
 (0)