Docker最佳实践之部署Git
Docker本文通过一个简朴的实践先容下Docker在一般的场景的简朴高效的应用历程,我们通过Docker部署一个开源的敏捷项目治理系统。因为gitsrum项目是接纳PHP语言开发,我们需要一个mysql数据库,同时需要PHP的运行情况支撑。下面详细的形貌下整个部署历程。
联系S11竞猜
详情
本文摘要:Docker本文通过一个简朴的实践先容下Docker在一般的场景的简朴高效的应用历程,我们通过Docker部署一个开源的敏捷项目治理系统。因为gitsrum项目是接纳PHP语言开发,我们需要一个mysql数据库,同时需要PHP的运行情况支撑。下面详细的形貌下整个部署历程。

LOL全球总决赛下注

Docker本文通过一个简朴的实践先容下Docker在一般的场景的简朴高效的应用历程,我们通过Docker部署一个开源的敏捷项目治理系统。因为gitsrum项目是接纳PHP语言开发,我们需要一个mysql数据库,同时需要PHP的运行情况支撑。下面详细的形貌下整个部署历程。

S11竞猜

lOlS11全球总决赛赛事竞猜

步骤一,准备部署设置文件mkdir docker-gitscrumcd docker-gitsrummkdir config log mysql www添加Dockerfile文件,内容如下:FROM php:7.1-fpmLABEL maintainer "xiaobaoqiang "COPY ./sources.list /etc/apt/sources.listRUN apt-get updateRUN apt-get install -y git vim libz-dev libcurl4-gnutls-dev libmcrypt-dev libicu-dev zip unzip gnupg && docker-php-ext-install pdo_mysql && docker-php-ext-install iconv && docker-php-ext-install mcrypt && docker-php-ext-install intl && docker-php-ext-install opcache && docker-php-ext-install mbstring && docker-php-ext-install curl && docker-php-ext-install zip# Install nodejsRUN apt-get install -y software-properties-commonRUN curl -sL https://deb.nodesource.com/setup_7.x | bash -RUN apt-get install -y nodejs npmRUN npm config set registry https://registry.npm.taobao.orgRUN npm install --global gulp gulp-cli# Install ComposerRUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composerRUN chmod 755 /usr/local/bin/composer# Set Composer MirrorRUN composer config -g repo.packagist composer https://packagist.laravel-china.org# Install php-cs-fixer#RUN curl -L https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.0.0/php-cs-fixer.phar -o /usr/local/bin/php-cs-fixerCOPY ./php-cs-fixer.phar /usr/local/bin/php-cs-fixerRUN chmod a+x /usr/local/bin/php-cs-fixerRUN apt-get cleanEXPOSE 9200 9000 80CMD ["php-fpm"]为了加速安装包的下载,我们添加163的镜像地址vi sources.list# deb http://snapshot.debian.org/archive/debian/20190326T120000Z stretch maindeb http://mirrors.163.com/debian stretch main# deb http://mirrors.163.com/archive/debian-security/20190326T120000Z stretch/updates maindeb http://mirrors.163.com/debian-security stretch/updates main# deb http://mirrors.163.com/archive/debian/20190326T120000Z stretch-updates maindeb http://mirrors.163.com/debian stretch-updates main建立PHP的设置文件cd configvi [global]error_log = /var/log/php-fpm/fpm-error.logdaemonize = no[www]user = www-datagroup = www-datalisten = [::]:9000pm = dynamicpm.max_children = 5pm.start_servers = 2pm.min_spare_servers = 1pm.max_spare_servers = 3pm.status_path = /php/fpm/statusclear_env = noaccess.log = /var/log/php-fpm/access.logaccess.format = "%t "%m %r%Q%q" %s %{mili}dms %{kilo}Mkb %C%%"catch_workers_output = yesphp_flag[display_errors] = onphp_admin_value[date.timezone] = "Asia/Shanghai"vi php.ini[PHP]short_open_tag = off[Date]date.timezone = "Asia/Shanghai"建立Nginx的设置文件cd configvi server.confserver { listen 80; server_name app.gitscrum.dev; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; root /var/www/html/laravel-gitscrum/public; index index.php; client_max_body_size 25M; fastcgi_read_timeout 1800; location / { try_files $uri $uri/ /index.php$is_args$args; } location ~ .php$ { try_files $uri =404; fastcgi_pass phpfpm-gitscrum:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include /etc/nginx/fastcgi_params; } location /php/fpm/status { fastcgi_pass phpfpm-gitscrum:9000; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include /etc/nginx/fastcgi_params; }}建立mysql设置文件cd configvi docker.cnf[mysqld]skip-host-cacheskip-name-resolvedefault_authentication_plugin = mysql_native_password步骤二,下载gitsrum源代码cd wwwgit clone https://github.com/gitscrum-community/laravel-gitscrum.git修改gitsrum的设置文件.envcd www/laravel-gitscrumvi .envAPP_ENV=localAPP_KEY=base64:W2ToyfW8zHqtWfcZb1hp2kZgccbuy3XtERDyZywtVkE=APP_DEBUG=trueAPP_LOG_LEVEL=debugAPP_URL=http://10.0.0.50APP_TITLE=GitScrumAPP_LANG=zh_cnGITHUB_CLIENT_ID=GITHUB_CLIENT_SECRET=GITLAB_KEY=9e9bbc01d983c9bca487b468de1afd9389xxxxxxxxxxxxxxxxxxxxxxxGITLAB_SECRET=9436d9fae69e7e9ebd359c14b8e1222xxxxxxxxxxxxxxxxxxxxxxxGITLAB_INSTANCE_URI=http://10.0.0.50:9080/BITBUCKET_CLIENT_ID=BITBUCKET_CLIENT_SECRET=DB_CONNECTION=mysqlDB_HOST=mysql-gitscrumDB_PORT=3306DB_DATABASE=developDB_USERNAME=gitscrumDB_PASSWORD=123456APP_PAGINATE=10PROXY_PORT=PROXY_METHOD=PROXY_SERVER=PROXY_USER=PROXY_PASS=SLACK_CHANNEL=channel-nameSLACK_BOT_NAME=bot-nameSLACK_WEBHOOK=endpoint步骤三,开始部署建立Docker部署设置文件vi docker-compose.yml# PHPphpfpm-gitscrum: build: . restart: always environment: - DEBUG=1 volumes: - ./config/php-fpm.conf:/usr/local/etc/php-fpm.conf - ./config/php.ini:/usr/local/etc/php/php.ini - ./www:/var/www/html - ./log/php-fpm:/var/log/php-fpm links: - mysql-gitscrum# NGINXnginx-gitscrum: restart: always image: nginx ports: - "80:80" links: - phpfpm-gitscrum volumes: - ./config/server.conf:/etc/nginx/conf.d/default.conf - ./www:/var/www/html - ./log/nginx:/var/log/nginx# MYSQLmysql-gitscrum: restart: always image: mysql ports: - "3306:3306" environment: MYSQL_ROOT_PASSWORD: 123456 MYSQL_USER: gitscrum MYSQL_PASSWORD: 123456 MYSQL_DATABASE: develop volumes: - ./mysql/databases:/var/lib/mysql - ./log/mysql:/var/log/mysql - ./config/docker.cnf:/etc/mysql/conf.d/docker.cnf安装部署工具sudo curl -L "https://github.com/docker/compose/releases/download/1.24.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-composesudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-composedocker-compose --versiondocker-compose version 1.24.0, build 1110ad01开始部署docker-compose up --build..............................................Successfully built c4fe14fa3da3Successfully tagged docker-gitscrum_phpfpm-gitscrum:latestCreating docker-gitscrum_mysql-gitscrum_1 ... doneCreating docker-gitscrum_phpfpm-gitscrum_1 ... doneCreating docker-gitscrum_nginx-gitscrum_1 ... doneAttaching to docker-gitscrum_mysql-gitscrum_1, docker-gitscrum_phpfpm-gitscrum_1, docker-gitscrum_nginx-gitscrum_1mysql-gitscrum_1 | 2019-05-01T05:02:08.915841Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.mysql-gitscrum_1 | 2019-05-01T05:02:08.915918Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.16) starting as process 1mysql-gitscrum_1 | 2019-05-01T05:02:09.904586Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.mysql-gitscrum_1 | 2019-05-01T05:02:09.906606Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.mysql-gitscrum_1 | 2019-05-01T05:02:09.920529Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.16' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server - GPL.mysql-gitscrum_1 | 2019-05-01T05:02:10.170904Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: '/var/run/mysqld/mysqlx.sock' bind-address: '::' port: 33060泛起上述日志,说明gitsrum的PHP和Mysql情况已经启动乐成了步骤四,验证检察我们适才构建的gitsrum docker镜像docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEdocker-gitscrum_phpfpm-gitscrum latest c4fe14fa3da3 4 days ago 711MBphp 7.1-fpm 5bc07b7ec70a 6 days ago 358MBmysql latest d72169616e20 6 days ago 443MBgitlab/gitlab-ce latest b3a3f6564d33 7 days ago 1.77GBnginx latest 27a188018e18 2 weeks ago 109MB检察docker启动的容器docker ps -aCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES2b28667f9e2d nginx "nginx -g 'daemon of…" 4 minutes ago Up 4 minutes 0.0.0.0:80->80/tcp docker-gitscrum_nginx-gitscrum_1dd439b5982b3 docker-gitscrum_phpfpm-gitscrum "docker-php-entrypoi…" 4 minutes ago Up 4 minutes 80/tcp, 9000/tcp, 9200/tcp docker-gitscrum_phpfpm-gitscrum_170ae5d88c24c mysql "docker-entrypoint.s…" 4 minutes ago Up 4 minutes 0.0.0.0:3306->3306/tcp, 33060/tcp docker-gitscrum_mysql-gitscrum_1通过浏览器会见http://10.0.0.50测试效果泛起上面截图内容,说明我们的gitsrum启动乐成而且可以会见。由于gitsrum系统接纳Oauth登陆,它并不提供用户注册的功效,所以我们需要在laravel-gitscrum的.env设置Oauth的登陆信息,下面设置参数只是一个示例:GITLAB_KEY=9e9bbc01d983c9bca487b468de1afd9389xxxxxxxxxxxxxxxxxxxxxxxGITLAB_SECRET=9436d9fae69e7e9ebd359c14b8e1222xxxxxxxxxxxxxxxxxxxxxxxGITLAB_INSTANCE_URI=http://10.0.0.50:9080/参考:https://github.com/gitscrum-community/docker-gitscrumhttps://docs.docker.com/compose/install/文章如有不妥之处,接待指正!谢谢!。


本文关键词:Docker,lOlS11全球总决赛赛事竞猜,最佳,实践,之,部署,Git,Docker,本文,通过

本文来源:S11竞猜-www.smydh.cn