Skip to content

Commit

Permalink
2
Browse files Browse the repository at this point in the history
  • Loading branch information
YiRanCN committed Feb 27, 2024
1 parent 5613934 commit 46a8376
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 0 deletions.
5 changes: 5 additions & 0 deletions docs/study/back/spring/SpringBoot.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Spring Boot

### 常看文档

- [V3.2.0 官方参考文档,没事多看看](https://docs.spring.io/spring-boot/docs/3.2.0/reference/html/)
15 changes: 15 additions & 0 deletions docs/study/back/spring/SpringFramework.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Spirng Framework

### 特性

- Core technologies: dependency injection, events, resources, i18n, validation, data binding, type conversion, SpEL, AOP.

- Testing: mock objects, TestContext framework, Spring MVC Test, WebTestClient.

- Data Access: transactions, DAO support, JDBC, ORM, Marshalling XML.

- Spring MVC and Spring WebFlux web frameworks.

- Integration: remoting, JMS, JCA, JMX, email, tasks, scheduling, cache and observability.

- Languages: Kotlin, Groovy, dynamic languages.
50 changes: 50 additions & 0 deletions docs/study/docker/Dockerfile使用详解.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,56 @@

- [官方参考文档-英文版本](https://docs.docker.com/reference/dockerfile/)

### SpringBoot Dockerfile 示例

```shell
# JDK17环境
FROM ubuntu:23.10 as ujdk17
WORKDIR /root/jdk
ADD jdk-17_linux-x64_bin.tar.gz ./
ENV JAVA_HOME=/root/jdk/jdk-17.0.8
ENV PATH=$JAVA_HOME/bin:$PATH
RUN java --version
# 直接运行SpringBoot Jar包模式
FROM ujdk17 as xxx
WORKDIR /root/application
ARG JAR_FILE=target/*.jar
COPY ${JAR_FILE} application.jar
EXPOSE 8080
ENTRYPOINT java -jar application.jarca
```

没有成功!!(原因是 SpringBoot 的版本用的是 3.0.3)

成功!!(原因是 SpringBoot 的版本用的是 3.2.3)

一定要看清 SpringBoot 的版本号,差异还是很大的

```shell
# JDK17环境
FROM ubuntu:23.10 as ujdk17
WORKDIR /root/jdk
ADD jdk-17_linux-x64_bin.tar.gz ./
ENV JAVA_HOME=/root/jdk/jdk-17.0.8
ENV PATH=$JAVA_HOME/bin:$PATH
RUN java --version
# 构建环境 主要是想利用Docker的分层缓存概念达到快速构建的目的 jarmode模式
FROM ujdk17 as builder
WORKDIR /root/application
ARG JAR_FILE=target/*.jar
COPY ${JAR_FILE} application.jar
RUN java -Djarmode=layertools -jar application.jar extract
# jarmode模式启动
FROM ujdk17 as xxx
WORKDIR /root/application
COPY --from=builder /root/application/dependencies/ ./
COPY --from=builder /root/application/spring-boot-loader/ ./
COPY --from=builder /root/application/snapshot-dependencies/ ./
COPY --from=builder /root/application/application/ ./
EXPOSE 8080
ENTRYPOINT ["java", "org.springframework.boot.loader.launch.JarLauncher"]
```

### 参考文档

- [简书-Dockerfile 详解(超详细)](https://www.jianshu.com/p/4508784f6ddc)
38 changes: 38 additions & 0 deletions docs/study/docker/Docker的使用总结.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,44 @@ docker system prune
docker system prune -a
```

### 版本太低 需要升级

```shell
# docker build 报错如下
is not a valid repository/tag: invalid reference format
# 检查版本 docker 版本太低
docker version


# 卸载旧版本
yum -y remove docker*
# 安装需要的软件包, yum-util 提供yum-config-manager功能,另外两个是devicemapper驱动依赖的
sudo yum install -y yum-utils
# 设置yum源
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
# 安装docker
yum install docker-ce docker-ce-cli containerd.io
# 配置国内docker镜像源
mkdir -p /etc/docker
tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": [
"https://kfwkfulq.mirror.aliyuncs.com",
"https://2lqq34jg.mirror.aliyuncs.com",
"https://pee6w651.mirror.aliyuncs.com",
"https://registry.docker-cn.com",
"http://hub-mirror.c.163.com"
],
"dns": ["8.8.8.8","8.8.4.4"]
}
EOF
# 重启docker
systemctl daemon-reload
systemctl restart docker
# 验证docker版本
docker version
```

### 参考

[参考 1](https://developer.aliyun.com/article/272173)

0 comments on commit 46a8376

Please sign in to comment.