feat: 初始化笔记项目
- 新建后端项目 biji-houdaun,使用 Spring Boot 和 SQLite - 新建前端项目 biji-qianduan,使用 Vue3 - 添加 Dockerfile 用于构建后端镜像 -配置 .gitignore 和 .gitattributes 文件
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
package com.test.bijihoudaun;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class BijiHoudaunApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(BijiHoudaunApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
40
biji-houdaun/src/main/java/com/test/docker/Dockerfile
Normal file
40
biji-houdaun/src/main/java/com/test/docker/Dockerfile
Normal file
@@ -0,0 +1,40 @@
|
||||
# 使用轻量级Alpine基础镜像 (Java 17 JRE)
|
||||
FROM eclipse-temurin:17-jre-alpine
|
||||
|
||||
# 更换Alpine镜像源为国内源(解决网络问题)
|
||||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
|
||||
|
||||
# 安装SQLite动态库和时区数据 (关键步骤)
|
||||
RUN apk add --no-cache sqlite tzdata && \
|
||||
# 设置中国时区
|
||||
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
|
||||
echo "Asia/Shanghai" > /etc/timezone && \
|
||||
# 清理时区缓存
|
||||
apk del tzdata && \
|
||||
rm -rf /var/cache/apk/*
|
||||
|
||||
# 设置工作目录
|
||||
WORKDIR /app
|
||||
|
||||
# 复制构建好的jar文件(修正路径)
|
||||
COPY *.jar app.jar
|
||||
|
||||
# 创建数据目录并确保可写
|
||||
RUN mkdir -p /data && chmod a+rw /data
|
||||
|
||||
# 复制数据库文件(来自构建上下文)
|
||||
COPY data/mydatabase.db /data/mydatabase.db
|
||||
|
||||
# 设置环境变量,test 激活测试环境
|
||||
ENV SPRING_PROFILES_ACTIVE=test \
|
||||
JAVA_OPTS="-Xmx512m -XX:MaxRAMPercentage=75"
|
||||
|
||||
# 暴露应用端口
|
||||
EXPOSE 8083
|
||||
|
||||
# 添加健康检查
|
||||
HEALTHCHECK --interval=30s --timeout=3s \
|
||||
CMD wget --quiet --tries=1 --spider http://localhost:8082/actuator/health || exit 1
|
||||
|
||||
# 启动应用 (使用exec形式支持JVM参数)
|
||||
ENTRYPOINT exec java $JAVA_OPTS -jar app.jar
|
||||
Reference in New Issue
Block a user