目录
1、基于Docker部署GitLab环境搭建
1.1 下载镜像文件
1.2 创建GitLab 的配置 (etc) 、 日志 (log) 、数据 (data) 放到容器之外, 便于日后升级, 因此请先准备这三个目录
1.3 运行gitlab容器
1.4 修改/mnt/gitlab/etc/gitlab.rb
2、meite-shop-service-api项目
3、meite-shop-service-member项目
4、微服务网关meite-shop-basics-springcloud-zuul
5、maven私服搭建
5.1 创建仓库
5.2 创建私服账号
5.3 本地setting.xml
5.4 maven再pom.xml配置
docker pull beginor/gitlab-ce:11.0.1-ce.0
mkdir -p /mnt/gitlab/etc
mkdir -p /mnt/gitlab/log
mkdir -p /mnt/gitlab/data
docker run \
--detach \
--publish 8443:443 \
--publish 8090:80 \
--name gitlab \
--restart unless-stopped \
-v /mnt/gitlab/etc:/etc/gitlab \
-v /mnt/gitlab/log:/var/log/gitlab \
-v /mnt/gitlab/data:/var/opt/gitlab \
beginor/gitlab-ce:11.0.1-ce.0
停止docker容器,并且删除
Docker stop 容器id
Docker rm 容器id
systemctl stop firewalld
把external_url改成部署机器的域名或者IP地址
vi /mnt/gitlab/etc/gitlab.rb
external_url 'http://192.168.212.227'
修改/mnt/gitlab/data/gitlab-rails/etc/gitlab.yml
vi /mnt/gitlab/data/gitlab-rails/etc/gitlab.yml
找到关键字 * ## Web server settings * ,将host的值改成映射的外部主机ip地址和端口,这里会显示在gitlab克隆地址。然后登陆,修改git的密码123456,如图:
新增用户,授权git访问地址:
引入maven依赖(改)
com.spring4all
swagger-spring-boot-starter
1.7.0.RELEASE
application.yml文件
####swagger相关配置
swagger:
base-package: com.mayikt.weixin.service
title: SpringCloud2.x构建微服务电商项目-微信服务接口
description: 该项目“基于SpringCloud2.x构建微服务电商项目”由每特教育|蚂蚁课堂版权所有,未经过允许的情况下,私自分享视频和源码属于违法行为。
version: 1.1
terms-of-service-url: www.mayikt.com
contact:
name: 97后互联网架构师-余胜军
email: [email protected]
@EnableSwagger2Doc 开启Swagger生成文件
org.springframework.cloud
spring-cloud-starter-netflix-zuul
com.spring4all
swagger-spring-boot-starter
1.7.0.RELEASE
启动类AppGateWay
@SpringBootApplication
@EnableEurekaClient
@EnableZuulProxy
@EnableSwagger2Doc
public class AppGateWay {
public static void main(String[] args) {
SpringApplication.run(AppGateWay.class, args);
}
// 添加文档来源
@Component
@Primary
class DocumentationConfig implements SwaggerResourcesProvider {
@Override
public List get() {
List resources = new ArrayList<>();
// app-itmayiedu-order
resources.add(swaggerResource("app-mayikt-member", "/app-mayikt-member/v2/api-docs", "2.0"));
resources.add(swaggerResource("app-mayikt-weixin", "/app-mayikt-weixin/v2/api-docs", "2.0"));
return resources;
}
private SwaggerResource swaggerResource(String name, String location, String version) {
SwaggerResource swaggerResource = new SwaggerResource();
swaggerResource.setName(name);
swaggerResource.setLocation(location);
swaggerResource.setSwaggerVersion(version);
return swaggerResource;
}
}
}
application.yml
###服务启动端口号
server:
port: 80
###服务名称(服务注册到eureka名称)
spring:
application:
name: app-mayikt-zuul
###服务注册到eureka地址
eureka:
client:
service-url:
defaultZone: http://localhost:8100/eureka
### 配置网关反向代理
zuul:
routes:
api-a:
### 以 /api-weixin/访问转发到会员服务
path: /api-weixin/**
serviceId: app-mayikt-weixin
api-b:
### 以 /api-member/访问转发到订单服务
path: /api-member/**
serviceId: app-mayikt-member
1.下载一个nexus3的镜像
docker pull sonatype/nexus3
2.将容器内部/var/nexus-data挂载到主机/root/nexus-data目录。
docker run -d -p 8081:8081 --name nexus -v /root/nexus-data:/var/nexus-data --restart=always sonatype/nexus3
关闭防火墙,访问http://ip:8081
默认登陆账号 admin admin123
创建仓库,点击Create repository,然后选择maven2(hosted)然后输入仓库名称(test-release)。在version policy中选择这个仓库的类型,这里选择release,在Deployment policy中选择Allow redeploy(这个很重要)
点击左侧菜单栏的Users菜单,然后点击Create local user.我这里创建了一个用户,账号密码都是:mayik
mayikt
mayikt
mayikt
mayikt
http://192.168.212.230:8081/repository/mayikt-release/
org.apache.maven.plugins
maven-deploy-plugin
2.7
org.apache.maven.plugins
maven-source-plugin
2.2.1
package
jar
com.mayikt
mayikt_springboot
0.0.1-RELEASE
mayikt
http://192.168.212.233:8081/repository/mayikt-release/