GitLab私有Git的安装与配置

GitLab私有Git1 GitLab简介GitLab是整个DevOps生命周期的第一个单一应用程序。只有GitLab才能启用Concurrent DevOps,从组件链的约束中解锁组织。GitLab提供无与伦比的可见性,更高的效率和全面的治理。这使得软件生命周期加快了200%,从根本上提高了业务速度。官方网站gitlab优势2 GitLab安装2.1 CentOS 7安装安装步骤:安装并配置必要的依赖项在CentOS 7(和RedHat / Oracle / Scientific Linux 7)上,以下命令还将在系统防火墙中打开HTTP和SSH访问。sudo yum install -y curl policycoreutils-python openssh-serversudo systemctl enable sshdsudo systemctl start sshdsudo firewall-cmd --permanent --add-service=httpsudo systemctl reload firewalld安装Postfix以发送通知电子邮件【可选】sudo yum install postfixsudo systemctl enable postfixsudo systemctl start postfix添加GitLab软件包存储库并安装软件包curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash接下来,安装GitLab包。将http:// gitlab.example.com更改为您要访问GitLab实例的URL。安装将自动配置并启动该URL的GitLab。HTTPS 在安装后需要其他配置sudo EXTERNAL_URL="http://gitlab.example.com" yum install -y gitlab-ce初始化配置时间比较久……,需要耐心等待….., 不要做任何操作gitlab-ctl reconfigure其他命令:# gitlab 服务操作 服务操作# 初始化配置 gitlabgitlab-ctl reconfigure# 启动 gitlab 服务gitlab-ctl start# 停止 gitlab 服务gitlab-ctl stop浏览到服务器IP并登录首次访问时,您将被重定向到密码重置屏幕。提供初始管理员帐户的密码,您将被重定向回登录屏幕。使用默认帐户的用户名root登录。==需要设置新的密码==2.2 Docker 安装拉取gitlab、redis、postgresql,gitlab依赖redis和postgresql。docker pull sameersbn/redisdocker pull sameersbn/postgresqldocker pull gitlab/gitlab-ce:latest创建postgresql、redis容器docker run --name postgresql -d ‐‐privileged=true -e 'DB_NAME=gitlabhq_production' -e'DB_USER=gitlab' -e 'DB_PASS=password' -e 'DB_EXTENSION=pg_trgm' -v/home/root/opt/postgresql/data:/var/lib/postgresql sameersbn/postgresqldocker run --name redis -d --privileged=true -v /home/root/opt/redis/data:/var/lib/redissameersbn/redis3.创建gitlab容器docker run --name gitlab -d --link postgresql:postgresql --link redis:redisio --hostname 192.168.101.64 -p 10022:22 -p 80:80 -e 'GITLAB_PORT=8899' -e 'GITLAB_SSH_PORT=10022' -e'GITLAB_SECRETS_DB_KEY_BASE=long‐and‐random‐alpha‐numeric‐string' -e'GITLAB_SECRETS_SECRET_KEY_BASE=long‐and‐random‐alpha‐numeric‐string' -e'GITLAB_SECRETS_OTP_KEY_BASE=long‐and‐random‐alpha‐numeric‐string' -e'GITLAB_HOST=192.168.101.64' ‐e 'SMTP_AUTHENTICATION=login' -v/home/root/opt/gitlab/data:/home/git/data docker.io/gitlab/gitlab-ce浏览器访问:http://[IP]:80初次访问需要等待一段时间。3 Idea集成GitLab在File => Settings => Plugins 里面 搜索 gitlab 安装,装好后点击File => Settings => Other Settings => GitLab Setting这里面主要配置GitLab Server Url和你个人的私有访问token

GitLab私有Git的安装与配置

SpringMVC访问接口显示图片

这里通过前端传的path获取图片文件实际路径并予以显示,主要还是setContentType设置为图片格式,让浏览器感知这是一张图片。 @RequestMapping(value = "/showImg") public void show(String path, HttpServletRequest request, HttpServletResponse response) { response.setContentType("image/jpeg/jpg/png/gif/bmp/tiff/svg"); try { path = request.getSession().getServletContext().getRealPath("/uploads/") + path; path = new String(path.getBytes(), "UTF-8"); File file = new File(path); if (file.exists()) { InputStream in = new FileInputStream(path); ServletOutputStream os = response.getOutputStream(); byte[] b = new byte[1024]; while (in.read(b) != -1) { os.write(b); } in.close(); os.flush(); os.close(); } } catch (IOException e) { e.printStackTrace(); } }