Docker 镜像瘦身 - 多阶段构建 作者: Chuwen 时间: 2021-06-21 分类: Docker 评论 参照了:https://zhuanlan.zhihu.com/p/161685245 然后,照猫画虎,自己写了个 `Dockerfile`,构建结果,确实比之前少了近**500MB** ```dockerfile FROM centos:centos7 AS build ENV NGINX_VERSION=1.21.0 ENV NGINX_URL=http://nginx.org/download/nginx-$NGINX_VERSION.tar.gz #安装相关依赖 RUN yum -y update && \ yum -y install gcc gcc-c++ autoconf automake make && \ yum -y install zlib zlib-devel openssl* pcre* wget #MAINTAINER 维护者信息 MAINTAINER shine09 i@nowtime.cc # 下载 Nginx 源码 ADD $NGINX_URL /tmp/ # 下载 nginx-http-concat 源码 ADD https://codeload.github.com/alibaba/nginx-http-concat/tar.gz/1.2.2 /tmp/ #切换目录 WORKDIR /tmp # 解压 http-concat 扩展 RUN tar -xzvf 1.2.2 && \ cp -r nginx-http-concat-1.2.2/ /usr/local/src/ && \ mkdir -p {/usr/local/nginx/logs,/var/lock} && \ useradd -M -s /bin/bash nginx && \ tar -zxvf nginx-$NGINX_VERSION.tar.gz && \ mkdir -p /usr/local/nginx && \ cd /tmp/nginx-$NGINX_VERSION \ && ./configure --prefix=/etc/nginx --user=nginx --group=nginx \ --conf-path=/etc/nginx/nginx.conf \ --error-log-path=/var/log/nginx/error.log \ --http-log-path=/var/log/nginx/access.log \ --pid-path=/var/run/nginx.pid \ --lock-path=/var/run/nginx.lock \ --with-http_stub_status_module \ --with-http_ssl_module \ --with-http_sub_module \ --add-module=/usr/local/src/nginx-http-concat-1.2.2 \ && make && make install && \ rm -rf /tmp && \ /etc/nginx/sbin/nginx -c /etc/nginx/nginx.conf && \ ln -s /usr/local/nginx/sbin/* /usr/local/sbin/ #第二阶段 FROM centos:centos7 COPY --from=build /etc/nginx /etc/nginx RUN mkdir -p {/var/lock,/var/log/nginx/} && \ ln -s /etc/nginx/sbin/nginx /usr/local/sbin/nginx && \ useradd -M -s/bin/bash nginx #EXPOSE 映射端口 EXPOSE 80 443 #CMD 运行以下命令 #CMD ["nginx"] CMD ["/etc/nginx/sbin/nginx","-g","daemon off;"] #构建镜像 #docker build -t shine09/nginx:v1 . ``` ```log ➜ nginx git:(master) ✗ docker history sha256:31b34e5b2e4b06756098ab0f07930f4c7d5671ef9155936bb8d0092787772f71 IMAGE CREATED CREATED BY SIZE COMMENT 31b34e5b2e4b 6 minutes ago CMD ["/etc/nginx/sbin/nginx" "-g" "daemon of… 0B buildkit.dockerfile.v0 6 minutes ago EXPOSE map[443/tcp:{} 80/tcp:{}] 0B buildkit.dockerfile.v0 6 minutes ago RUN /bin/sh -c mkdir -p {/var/lock,/var/log/… 360kB buildkit.dockerfile.v0 18 minutes ago COPY /etc/nginx /etc/nginx # buildkit 6.18MB buildkit.dockerfile.v0 7 months ago /bin/sh -c #(nop) CMD ["/bin/bash"] 0B 7 months ago /bin/sh -c #(nop) LABEL org.label-schema.sc… 0B 7 months ago /bin/sh -c #(nop) ADD file:b3ebbe8bd304723d4… 204MB ```
Vue.js 报错 [Vue warn]: Computed property "getSearchOther" was assigned to but it has no setter. 作者: Chuwen 时间: 2021-06-15 分类: Vue.js 评论 ```log [Vue warn]: Computed property "getSearchOther" was assigned to but it has no setter. ``` 我是这么写的: ```js //这里省略部分代码 watch:{ getSearchOther() { return this.SearchOther }, } //这里省略部分代码 ``` ## 解决方案 手动给予 `get`、`set` 方法 参照官方文档:[https://cn.vuejs.org/v2/guide/computed.html#计算属性的 setter](https://cn.vuejs.org/v2/guide/computed.html#%E8%AE%A1%E7%AE%97%E5%B1%9E%E6%80%A7%E7%9A%84-setter "https://cn.vuejs.org/v2/guide/computed.html#计算属性的 setter") ```js //这里省略部分代码 watch:{ getSearchOther: { get() { return this.SearchOther }, set(newVal) { this.SearchOther = newVal; } }, } //这里省略部分代码 ```
整了个小玩意-佳寓用电明细查询 作者: Chuwen 时间: 2021-06-14 分类: PHP 评论 > 虽然是个小东西,但为了做的完美些,也肝了2天空闲时间 项目地址:https://github.com/PrintNow/jiayu-hydropower-query 在线预览:https://nowtime.cc/jiayu/ ![421623676168_.pic_hd副本.jpg](https://cdn.nowtime.cc/2021/06/14/4055147831.jpg)
PHPStorm 快速预览定义的 方法/函数 代码 作者: Chuwen 时间: 2021-06-11 分类: 其他分类 评论 ### mac 下的快捷键是 `Alt + 空格` ![](https://cdn.nowtime.cc/2021/06/11/1836675584.png)
使用 Dayjs 校验日期是否符合指定的日期格式 作者: Chuwen 时间: 2021-06-10 分类: JavaScript 评论 > 参阅文档:https://day.js.org/docs/zh-CN/display/format#docsNav > > 使用本功能需先配置 [LocalizedFormat][1] 插件,才能正常运行 ```js /** * * 检查日期是否为 指定的日期格式 * @param {String} format * @param {String} datetime * @returns {boolean} */ checkDatetimeFormat(format, datetime) { const dayjs = require('dayjs') return dayjs(datetime).format(format) === datetime } ``` [1]: https://day.js.org/docs/zh-CN/plugin/localized-format "localizedFormat"