博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
docker 镜像构建实践pagekit CMS(docker hub/docker cloud)
阅读量:4071 次
发布时间:2019-05-25

本文共 3223 字,大约阅读时间需要 10 分钟。

需要的网站如下:

Docker Hub:

Docker Cloud:

github:

这篇博客只是一次docker 镜像的自动构建,关于Dockerfile的编写,上下文路径等请提前学习.

pagekit CMS: 开源的php内容管理系统

环境:PHP,Web(Nginx),PHP扩展(php5-fpm php5-cli php5-json php5-mysql php5-curl) 基本服务组件(ca-certificates)

思路: 将编写的文件push到github上的仓库,在docker hub 或docker cloud上设置与github的hook并触发自动构建.

代码下载:git@github.com:xiaer1921/docker_pagekit.git

一.Docker Hub自动构建

1. 配置Docker Hub,右上角头像菜单->Settings->Linked Accounts & Services->Link Github.

2.右上角Create->Create Automated Build->Link Account Github->选择github 仓库

3.创建后Build Settings可以看到Branch选择,就能理解,触发会根据你的设置对你更改的github分支进行自动构建,Build Details可以看到构建历史.Tags查看创建成功的镜像.

二.Docker cloud自动构建

1.Repositories->创建一个仓库,Link to Github后,Builds->Configure Automated Builds->Build Text为上下文路径,Dockerfile location是相对上下文来说的,一定要选Autobuild.

2.Timeline可浏览构建历史和日志.

在自动构建完成以后,docker会给邮箱里发送构建信息.

三.

Dockerfile文件代码:

FROM ubuntu:trusty  RUN apt-get update && \     apt-get -y install \     nginx \     unzip \     wget \     ca-certificates \     php5 php5-fpm php5-cli php5-json php5-mysql php5-curl ENV PAGEKIT_VERSION 1.0.2 RUN mkdir /pagekit WORKDIR /pagekit VOLUME ["/pagekit/storage", "/pagekit/app/cache"] RUN wget https://github.com/pagekit/pagekit/releases/download /$PAGEKIT_VERSION/pagekit-$PAGEKIT_VERSION.zip -O /pagekit/pagekit.zip && \     unzip /pagekit/pagekit.zip && rm /pagekit/pagekit.zip ADD /pagekit/nginx.conf /etc/nginx/nginx.conf RUN chown -R www-data:/pagekit &&\    apt-get autoremove wget unzip -y && \     apt-get autoclean -y && \     apt-get clean -y && \     rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* CMD ["sh", "-c", "service php5-fpm start && nginx"]

Nginx配置文件:

user www-data; worker_processes 4; pid /run/nginx.pid; daemon off; events {   worker_connections 768;   # multi_accept on; } http {   ##   # Basic Settings   ##   sendfile on;   tcp_nopush on;   tcp_nodelay on;   keepalive_timeout 65;   types_hash_max_size 2048;   # server_tokens off;   # server_names_hash_bucket_size 64;   # server_name_in_redirect off;   include /etc/nginx/mime.types;   default_type application/octet-stream;   ##   # Logging Settings   ##   access_log /var/log/nginx/access.log ;  error_log /var/log/nginx/error.log;   ##   # Gzip Settings   ##   gzip on;   gzip_disable "msie6";   gzip_vary on;   gzip_proxied any;   gzip_comp_level 6;   gzip_buffers 16 8k;   gzip_http_version 1.1;   gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;   server {     root /pagekit;     location / {       try_files $uri $uri/ /index.php?$args;       index index.html index.htm index.php;     }     location ~ \.php$ {       try_files $uri $uri/ /index.php?$args;      index index.html index.htm index.php;       include fastcgi_params;       fastcgi_index index.php;       fastcgi_param PATH_INFO $fastcgi_path_info;       fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;       fastcgi_param HTTP_MOD_REWRITE On;       fastcgi_pass unix:/var/run/ php5-fpm.sock;       fastcgi_split_path_info ^(.+\.php)(/.+)$;     }   } }

吐槽一句,写博客真的是耗时,想想一本书都看完了,才懒得写了一篇博客,<Docker从入门到实战>与<Kubernetes权威指南从Docker到Kubernetes实践全接触>相比,完全是小巫见大巫,慢慢来吧.

转载地址:http://qfgji.baihongyu.com/

你可能感兴趣的文章
linux之dup和dup2函数解析
查看>>
boa 流程分析
查看>>
socket编程简介
查看>>
Linux Netlink基本使用
查看>>
ModBus协议简介及移植到STM32单片机
查看>>
Apollo分布式部署Docker化和使用
查看>>
解决Python下使用pip安装Builtwith模块字符解析错误
查看>>
Window环境下安装基于Python的Scrapy网络爬虫框架
查看>>
[Note]matlab中调用java类或运行java
查看>>
启动Nginx报[10013]错误的解决方案
查看>>
SpringBoot爬坑记之Whitelabel Error Page
查看>>
Spring Boot入门学习笔记(一)
查看>>
Eclipse中使用cmd,解决乱码。
查看>>
Linux shell的一些小结
查看>>
POI读取加密Excel
查看>>
Oracle数据库IO异常:Connection reset解决方案
查看>>
Nginx烂笔头——新手指南文档翻译
查看>>
nginx烂笔头——nginx如何处理一个请求
查看>>
Spring使用tomcat连接池连接mysql报Driver class not found
查看>>
nginx烂笔头——Server names
查看>>