diff --git a/.air.toml b/.air.toml new file mode 100644 index 0000000..49468ed --- /dev/null +++ b/.air.toml @@ -0,0 +1,46 @@ +root = "." +testdata_dir = "testdata" +tmp_dir = "tmp" + +[build] + args_bin = [] + bin = "./tmp/main" + cmd = "go build -o ./tmp/main ." + delay = 1000 + exclude_dir = ["assets", "tmp", "vendor", "testdata"] + exclude_file = [] + exclude_regex = ["_test.go"] + exclude_unchanged = false + follow_symlink = false + full_bin = "" + include_dir = [] + include_ext = ["go", "tpl", "tmpl", "html"] + include_file = [] + kill_delay = "0s" + log = "build-errors.log" + poll = false + poll_interval = 0 + post_cmd = [] + pre_cmd = [] + rerun = false + rerun_delay = 500 + send_interrupt = false + stop_on_error = false + +[color] + app = "" + build = "yellow" + main = "magenta" + runner = "green" + watcher = "cyan" + +[log] + main_only = false + time = false + +[misc] + clean_on_exit = false + +[screen] + clear_on_rebuild = false + keep_scroll = true diff --git a/.github/workflows/build-docker-image.yml b/.github/workflows/build-docker-image.yml index b6b09f9..60c8379 100644 --- a/.github/workflows/build-docker-image.yml +++ b/.github/workflows/build-docker-image.yml @@ -62,8 +62,8 @@ jobs: push: ${{ github.event_name != 'pull_request' }} # 给清单打上多个标签 tags: | - ${{ secrets.DOCKERHUB_USERNAME }}/go-ldap-admin-server:latest - ${{ secrets.DOCKERHUB_USERNAME }}/go-ldap-admin-server:${{ steps.date.outputs.today }} + ${{ secrets.DOCKERHUB_USERNAME }}/go-ldap-admin:latest + ${{ secrets.DOCKERHUB_USERNAME }}/go-ldap-admin:${{ steps.date.outputs.today }} # 镜像推送到 阿里云仓库 - name: Login to the Ali Registry @@ -80,5 +80,5 @@ jobs: push: true platforms: linux/amd64,linux/arm64 tags: | - registry.cn-hangzhou.aliyuncs.com/${{ secrets.ALIHUB_USERNAME }}/go-ldap-admin-server:${{ env.GITHUB_REF_NAME }} - registry.cn-hangzhou.aliyuncs.com/${{ secrets.ALIHUB_USERNAME }}/go-ldap-admin-server:latest \ No newline at end of file + registry.cn-hangzhou.aliyuncs.com/${{ secrets.ALIHUB_USERNAME }}/go-ldap-admin:${{ env.GITHUB_REF_NAME }} + registry.cn-hangzhou.aliyuncs.com/${{ secrets.ALIHUB_USERNAME }}/go-ldap-admin:latest \ No newline at end of file diff --git a/.gitignore b/.gitignore index c5274f0..2802ccd 100644 --- a/.gitignore +++ b/.gitignore @@ -8,11 +8,7 @@ .vscode .token -build.sh -logs -go-web-mini go-ldap-admin -go-ldap-admin.db # Test binary, built with `go test -c` *.test @@ -24,4 +20,5 @@ go-ldap-admin.db # vendor/ tmp docs/docker-compose/data -dist \ No newline at end of file +dist +data \ No newline at end of file diff --git a/config.yml b/config.yml index 2b045a9..b023e84 100644 --- a/config.yml +++ b/config.yml @@ -13,7 +13,7 @@ logs: # 日志等级(-1:Debug, 0:Info, 1:Warn, 2:Error, 3:DPanic, 4:Panic, 5:Fatal, -1<=level<=5, 参照zap.level源码) level: -1 # 日志路径 - path: logs + path: data/logs # 文件最大大小, M max-size: 50 # 备份数 @@ -27,7 +27,7 @@ database: # 数据库类型 mysql sqlite3 driver: mysql # 数据库连接sqlite3数据文件的路径 - source: go-ldap-admin.db + source: data/go-ldap-admin.db mysql: # 用户名 diff --git a/docs/custom-openldap-dockerfile/Dockerfile b/docs/custom-openldap-dockerfile/Dockerfile new file mode 100644 index 0000000..0a72872 --- /dev/null +++ b/docs/custom-openldap-dockerfile/Dockerfile @@ -0,0 +1,5 @@ +FROM registry.cn-hangzhou.aliyuncs.com/ali_eryajf/openldap:1.4.0 + +LABEL maintainer https://github.com/eryajf + +ADD init.ldif /container/service/slapd/assets/config/bootstrap/ldif/custom/ \ No newline at end of file diff --git a/docs/custom-openldap-dockerfile/build.sh b/docs/custom-openldap-dockerfile/build.sh new file mode 100644 index 0000000..71ea8ac --- /dev/null +++ b/docs/custom-openldap-dockerfile/build.sh @@ -0,0 +1,3 @@ +#!/bin/bash +docker build --no-cache . -t registry.cn-hangzhou.aliyuncs.com/ali_eryajf/openldap:1.4.1 +docker push registry.cn-hangzhou.aliyuncs.com/ali_eryajf/openldap:1.4.1 \ No newline at end of file diff --git a/docs/docker-compose/config/init.ldif b/docs/custom-openldap-dockerfile/init.ldif similarity index 62% rename from docs/docker-compose/config/init.ldif rename to docs/custom-openldap-dockerfile/init.ldif index f75ef82..0f2b7d8 100644 --- a/docs/docker-compose/config/init.ldif +++ b/docs/custom-openldap-dockerfile/init.ldif @@ -1,28 +1,29 @@ -dn: ou=people,dc=eryajf,dc=net +dn: ou=people,{{ LDAP_BASE_DN }} ou: people description: 用户根目录 objectClass: organizationalUnit -dn: ou=dingtalkroot,dc=eryajf,dc=net +dn: ou=dingtalkroot,{{ LDAP_BASE_DN }} ou: dingtalkroot description: 钉钉根部门 objectClass: top objectClass: organizationalUnit -dn: ou=wecomroot,dc=eryajf,dc=net +dn: ou=wecomroot,{{ LDAP_BASE_DN }} ou: wecomroot description: 企业微信根部门 objectClass: top objectClass: organizationalUnit -dn: ou=feishuroot,dc=eryajf,dc=net +dn: ou=feishuroot,{{ LDAP_BASE_DN }} ou: feishuroot description: 飞书根部门 objectClass: top objectClass: organizationalUnit -dn: cn=group,dc=eryajf,dc=net +dn: cn=group,{{ LDAP_BASE_DN }} cn: group description: 默认分组 objectClass: top -objectClass: groupOfUniqueNames \ No newline at end of file +objectClass: groupOfUniqueNames +uniqueMember: cn=admin,{{ LDAP_BASE_DN }} \ No newline at end of file diff --git a/docs/docker-compose/config/my.cnf b/docs/docker-compose/config/my.cnf deleted file mode 100644 index ac5a924..0000000 --- a/docs/docker-compose/config/my.cnf +++ /dev/null @@ -1,40 +0,0 @@ -[client] -port = 3306 -socket = /var/lib/mysql/data/mysql.sock -[mysqld] - # 针对5.7版本执行group by字句出错问题解决 -sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' - # 一般配置选项 -basedir = /var/lib/mysql -datadir = /var/lib/mysql/data -port = 3306 -socket = /var/lib/mysql/data/mysql.sock -lc-messages-dir = /usr/share/mysql # 务必配置此项,否则执行sql出错时,只能显示错误代码而不显示具体错误消息 -character-set-server=utf8mb4 -back_log = 300 -max_connections = 3000 -max_connect_errors = 50 -table_open_cache = 4096 -max_allowed_packet = 32M -#binlog_cache_size = 4M -max_heap_table_size = 128M -read_rnd_buffer_size = 16M -sort_buffer_size = 16M -join_buffer_size = 16M -thread_cache_size = 16 -query_cache_size = 64M -query_cache_limit = 4M -ft_min_word_len = 8 -thread_stack = 512K -#tx_isolation = READ-COMMITTED -tmp_table_size = 64M -#log-bin=mysql-bin -long_query_time = 6 -server_id=1 -innodb_buffer_pool_size = 1024M -innodb_thread_concurrency = 16 -innodb_log_buffer_size = 16M -wait_timeout= 31536000 -interactive_timeout= 31536000 -lower_case_table_names = 1 -bind-address = 0.0.0.0 \ No newline at end of file diff --git a/docs/docker-compose/docker-compose.yaml b/docs/docker-compose/docker-compose.yaml index d5eddd9..87b0ae4 100644 --- a/docs/docker-compose/docker-compose.yaml +++ b/docs/docker-compose/docker-compose.yaml @@ -6,7 +6,7 @@ networks: services: mysql: - image: registry.cn-hangzhou.aliyuncs.com/ali_eryajf/mysql-server:5.7 + image: registry.cn-hangzhou.aliyuncs.com/ali_eryajf/mysql:8.3 container_name: go-ldap-admin-mysql # 指定容器名称,如果不设置此参数,则由系统自动生成 hostname: go-ldap-admin-mysql restart: always # 设置容器自启模式 @@ -18,16 +18,12 @@ services: MYSQL_ROOT_HOST: "%" MYSQL_DATABASE: go_ldap_admin volumes: - # 数据挂载目录自行修改哦! - - /etc/localtime:/etc/localtime:ro # 设置容器时区与宿主机保持一致 - - ./data/mysql:/var/lib/mysql/data # 映射数据库保存目录到宿主机,防止数据丢失 - - ./config/my.cnf:/etc/mysql/my.cnf # 映射数据库配置文件 - command: --default-authentication-plugin=mysql_native_password #解决外部无法访问 + - ./data/mysql:/var/lib/mysql # 映射数据库保存目录到宿主机,防止数据丢失 networks: - go-ldap-admin openldap: - image: registry.cn-hangzhou.aliyuncs.com/ali_eryajf/openldap:1.4.0 + image: registry.cn-hangzhou.aliyuncs.com/ali_eryajf/openldap:1.4.1 container_name: go-ldap-admin-openldap hostname: go-ldap-admin-openldap restart: always @@ -40,7 +36,6 @@ services: volumes: - ./data/openldap/database:/var/lib/ldap - ./data/openldap/config:/etc/ldap/slapd.d - - ./config/init.ldif:/container/service/slapd/assets/config/bootstrap/ldif/custom/init.ldif ports: - 388:389 networks: @@ -66,17 +61,17 @@ services: networks: - go-ldap-admin - go-ldap-admin-server: - image: registry.cn-hangzhou.aliyuncs.com/ali_eryajf/go-ldap-admin-server - container_name: go-ldap-admin-server - hostname: go-ldap-admin-server + go-ldap-admin: + image: registry.cn-hangzhou.aliyuncs.com/ali_eryajf/go-ldap-admin + container_name: go-ldap-admin + hostname: go-ldap-admin restart: always environment: WAIT_HOSTS: mysql:3306, openldap:389 ports: - 8888:8888 - # volumes: # 可按需打开此配置,将配置文件挂载到本地 可在服务运行之后,执行 docker cp go-ldap-admin-server:/app/config.yml ./config 然后再取消该行注释 - # - ./config/config.yml:/app/config.yml + volumes: + - ./data/go-ldap-admin:/app/data depends_on: - mysql - openldap