diff --git a/Dockerfile.local b/Dockerfile.local new file mode 100644 index 00000000..26fd7608 --- /dev/null +++ b/Dockerfile.local @@ -0,0 +1,29 @@ +FROM rockylinux:9 AS builder + +# Install build dependencies +RUN dnf install -y git golang make gcc + +# Copy local source +WORKDIR /build +COPY . . + +# Build +RUN go build -v -mod=vendor -o mattermost ./cmd/mattermost + +# Runtime image +FROM rockylinux:9-minimal + +RUN microdnf install -y ca-certificates tzdata && microdnf clean all + +WORKDIR /mattermost +COPY --from=builder /build/mattermost /mattermost/bin/mattermost +COPY --from=builder /build/config /mattermost/config +COPY --from=builder /build/i18n /mattermost/i18n +COPY --from=builder /build/fonts /mattermost/fonts +COPY --from=builder /build/templates /mattermost/templates +COPY --from=builder /build/client /mattermost/client + +RUN mkdir -p /mattermost/data /mattermost/logs /mattermost/plugins /mattermost/client/plugins + +EXPOSE 8065 +ENTRYPOINT ["/mattermost/bin/mattermost"] diff --git a/Extend-Function.md b/Extend-Function.md new file mode 100644 index 00000000..87b86331 --- /dev/null +++ b/Extend-Function.md @@ -0,0 +1,325 @@ +# Mattermost Community Enterprise - 확장 기능 문서 + +이 문서는 Team Edition에서 Enterprise 기능을 활성화하기 위해 생성/수정된 파일과 버전 업그레이드 시 이식해야 할 내용을 정리합니다. + +--- + +## 프로젝트 구조 + +``` +mattermost-community-enterprise/ +├── enterprise/ # Enterprise 브릿지 (기존) +│ └── community_imports.go # enterprise-community 임포트 +├── enterprise-impl/ # [신규] Enterprise 구현체 +│ ├── enterprise.go # 메인 등록 파일 +│ ├── go.mod # 별도 모듈 정의 +│ ├── go.sum +│ ├── ldap/ # LDAP 구현 +│ ├── saml/ # SAML 구현 +│ ├── cluster/ # 클러스터링 구현 +│ ├── metrics/ # Prometheus 메트릭 구현 +│ ├── compliance/ # 컴플라이언스 구현 +│ ├── data_retention/ # 데이터 보존 구현 +│ ├── message_export/ # 메시지 내보내기 구현 +│ ├── account_migration/ # 계정 마이그레이션 구현 +│ ├── access_control/ # 접근 제어 구현 +│ ├── ip_filtering/ # IP 필터링 구현 +│ ├── notification/ # 알림 구현 +│ ├── oauthproviders/ # OAuth 프로바이더 구현 +│ ├── outgoing_oauth_connection/ # 외부 OAuth 연결 구현 +│ ├── push_proxy/ # 푸시 프록시 구현 +│ └── searchengine/ # 검색 엔진 구현 +├── enterprise-community/ # [신규] Enterprise 등록 파일 +│ ├── imports.go # 모든 구현체 임포트 +│ ├── ldap/init.go +│ ├── saml/init.go +│ ├── cluster/init.go +│ ├── metrics/init.go +│ ├── compliance/init.go +│ ├── data_retention/init.go +│ ├── message_export/init.go +│ ├── account_migration/init.go +│ ├── access_control/init.go +│ ├── ip_filtering/init.go +│ ├── notification/init.go +│ ├── outgoing_oauth_connection/init.go +│ ├── push_proxy/init.go +│ └── searchengine/init.go +├── channels/api4/ # [수정됨] API 라이선스 체크 제거 +│ ├── ldap.go +│ ├── saml.go +│ ├── user.go +│ ├── group.go +│ └── scheme.go +├── channels/app/platform/ # [수정됨] 메트릭 핸들러 +│ └── metrics.go +├── Dockerfile.local # [신규] 로컬 빌드용 Dockerfile +├── Dockerfile.mattermost # [신규] Git 빌드용 Dockerfile +├── README.md # [신규] 빌드 가이드 +├── Extend-Function.md # [신규] 이 문서 +└── Unlock-License.md # [신규] 라이선스 해제 문서 +``` + +--- + +## 생성된 파일 상세 + +### 1. enterprise-impl/ (Enterprise 구현체) + +#### enterprise-impl/enterprise.go + +Enterprise 기능 등록을 위한 메인 파일입니다. + +```go +package enterprise + +import ( + "github.com/mattermost/mattermost/server/v8/channels/app" + "github.com/mattermost/mattermost/server/v8/enterprise-impl/ldap" + "github.com/mattermost/mattermost/server/v8/enterprise-impl/cluster" + "github.com/mattermost/mattermost/server/v8/enterprise-impl/metrics" + // ... 기타 imports +) + +func init() { + app.RegisterLdapInterface(ldap.New) + app.RegisterClusterInterface(cluster.New) + app.RegisterMetricsInterface(metrics.New) + // ... 기타 등록 +} +``` + +#### enterprise-impl/ldap/ldap.go + +LDAP 인증 및 동기화 구현체입니다. + +주요 메서드: +- `DoLogin()` - LDAP 로그인 처리 +- `GetUser()` - LDAP에서 사용자 조회 +- `GetGroup()` - LDAP에서 그룹 조회 +- `SyncAllUsers()` - 모든 사용자 동기화 +- `RunTest()` - LDAP 연결 테스트 + +#### enterprise-impl/cluster/cluster.go + +Redis 기반 클러스터링 구현체입니다. + +주요 메서드: +- `StartInterNodeCommunication()` - 노드 간 통신 시작 +- `RegisterClusterMessageHandler()` - 메시지 핸들러 등록 +- `SendClusterMessage()` - 클러스터 메시지 전송 +- `GetClusterStats()` - 클러스터 상태 조회 + +#### enterprise-impl/metrics/metrics.go + +Prometheus 메트릭 수집 구현체입니다. + +주요 메서드: +- `Register()` - 메트릭 등록 +- `Handler()` - HTTP 핸들러 반환 +- `IncrementHTTPRequest()` - HTTP 요청 카운트 +- `ObserveAPIEndpointDuration()` - API 응답 시간 측정 + +### 2. enterprise-community/ (등록 파일) + +#### enterprise-community/imports.go + +모든 Enterprise 구현체를 임포트하여 init()이 실행되도록 합니다. + +```go +package enterprise_community + +import ( + _ "github.com/mattermost/mattermost/server/v8/enterprise-community/ldap" + _ "github.com/mattermost/mattermost/server/v8/enterprise-community/cluster" + _ "github.com/mattermost/mattermost/server/v8/enterprise-community/metrics" + // ... 기타 imports +) +``` + +#### enterprise-community/ldap/init.go + +LDAP 구현체를 app에 등록합니다. + +```go +package ldap + +import ( + "github.com/mattermost/mattermost/server/v8/channels/app" + ldapImpl "github.com/mattermost/mattermost/server/v8/enterprise-impl/ldap" +) + +func init() { + app.RegisterLdapInterface(ldapImpl.New) +} +``` + +### 3. 수정된 파일 + +#### channels/api4/ldap.go + +LDAP 관련 API에서 라이선스 체크 제거: +- `syncLdap()` - LDAP 동기화 +- `testLdap()` - LDAP 연결 테스트 +- `getLdapGroups()` - LDAP 그룹 조회 +- `linkLdapGroup()` - LDAP 그룹 연결 +- `unlinkLdapGroup()` - LDAP 그룹 연결 해제 +- `migrateIdLdap()` - LDAP ID 마이그레이션 +- `createLdapPublicCertificate()` - 인증서 생성 + +#### channels/api4/scheme.go + +커스텀 권한 스키마 API에서 라이선스 체크 제거: +- `createScheme()` - 스키마 생성 +- `patchScheme()` - 스키마 수정 +- `deleteScheme()` - 스키마 삭제 + +#### channels/api4/group.go + +그룹 관련 API에서 라이선스 체크 제거: +- `getGroupsByTeam()` - 팀별 그룹 조회 +- `getGroupsByChannel()` - 채널별 그룹 조회 + +#### channels/api4/user.go + +사용자 마이그레이션 API에서 라이선스 체크 제거: +- `migrateAuthToLdap()` - LDAP 인증 마이그레이션 +- `migrateAuthToSaml()` - SAML 인증 마이그레이션 + +#### channels/app/platform/metrics.go + +메트릭 라우터에 `/metrics` 핸들러 등록 추가: + +```go +// MetricsHandlerProvider 인터페이스 추가 +type MetricsHandlerProvider interface { + Handler() http.Handler +} + +// initMetricsRouter()에 핸들러 등록 코드 추가 +if pm.metricsImpl != nil { + if handlerProvider, ok := pm.metricsImpl.(MetricsHandlerProvider); ok { + pm.router.Handle("/metrics", handlerProvider.Handler()) + } +} +``` + +--- + +## 버전 업그레이드 가이드 + +Mattermost 새 버전으로 업그레이드할 때 다음 파일들을 이식해야 합니다. + +### 필수 이식 파일 + +1. **enterprise-impl/ 전체 디렉토리** + - 새 버전의 einterfaces에 맞게 수정 필요 + - 인터페이스 변경 시 구현체 업데이트 + +2. **enterprise-community/ 전체 디렉토리** + - 새로운 Enterprise 기능 추가 시 init 파일 추가 + - app 패키지 경로 변경 시 import 수정 + +3. **enterprise/community_imports.go** + - enterprise-community 패키지 임포트 유지 + +### API 라이선스 체크 재제거 + +새 버전에서 다음 파일들의 라이선스 체크를 다시 제거해야 합니다: + +1. **channels/api4/ldap.go** + - `c.App.Channels().License() == nil` 조건문 찾아서 제거 + - `!*c.App.Channels().License().Features.LDAP` 조건 제거 + +2. **channels/api4/scheme.go** + - `!*c.App.Channels().License().Features.CustomPermissionsSchemes` 조건 제거 + +3. **channels/api4/group.go** + - `!*c.App.Channels().License().Features.LDAPGroups` 조건 제거 + +4. **channels/api4/user.go** + - LDAP/SAML 마이그레이션 라이선스 체크 제거 + +5. **channels/app/platform/metrics.go** + - `MetricsHandlerProvider` 인터페이스 추가 + - `/metrics` 핸들러 등록 코드 추가 + +### 이식 스크립트 예시 + +```bash +#!/bin/bash +# upgrade-mattermost.sh + +NEW_VERSION=$1 +OLD_DIR="mattermost-community-enterprise" +NEW_DIR="mattermost-server-$NEW_VERSION" + +# 1. 새 버전 다운로드 +git clone https://github.com/mattermost/mattermost.git $NEW_DIR +cd $NEW_DIR/server + +# 2. Enterprise 구현체 복사 +cp -r $OLD_DIR/enterprise-impl ./ +cp -r $OLD_DIR/enterprise-community ./ + +# 3. community_imports.go 복사 +cp $OLD_DIR/enterprise/community_imports.go ./enterprise/ + +# 4. go.mod 업데이트 (enterprise-impl 추가) +echo 'replace github.com/mattermost/mattermost/server/v8/enterprise-impl => ./enterprise-impl' >> go.mod + +# 5. vendor 업데이트 +go mod vendor + +echo "이제 API 파일에서 라이선스 체크를 수동으로 제거하세요" +``` + +### 라이선스 체크 자동 제거 스크립트 + +```bash +#!/bin/bash +# remove-license-checks.sh + +# LDAP 라이선스 체크 제거 +sed -i '/c\.App\.Channels()\.License() == nil.*LDAP/d' channels/api4/ldap.go +sed -i '/!.*License()\.Features\.LDAP/d' channels/api4/ldap.go + +# Scheme 라이선스 체크 제거 +sed -i '/License()\.Features\.CustomPermissionsSchemes/d' channels/api4/scheme.go + +# Group 라이선스 체크 제거 +sed -i '/License()\.Features\.LDAPGroups/d' channels/api4/group.go + +echo "라이선스 체크 제거 완료. 빌드 테스트를 실행하세요." +``` + +--- + +## einterfaces 매핑 + +| 인터페이스 | 구현 파일 | 등록 함수 | +|-----------|----------|----------| +| LdapInterface | enterprise-impl/ldap/ldap.go | app.RegisterLdapInterface | +| SamlInterface | enterprise-impl/saml/saml.go | app.RegisterSamlInterface | +| ClusterInterface | enterprise-impl/cluster/cluster.go | app.RegisterClusterInterface | +| MetricsInterface | enterprise-impl/metrics/metrics.go | app.RegisterMetricsInterface | +| ComplianceInterface | enterprise-impl/compliance/compliance.go | app.RegisterComplianceInterface | +| DataRetentionInterface | enterprise-impl/data_retention/data_retention.go | app.RegisterDataRetentionInterface | +| MessageExportInterface | enterprise-impl/message_export/message_export.go | app.RegisterMessageExportInterface | +| AccountMigrationInterface | enterprise-impl/account_migration/account_migration.go | app.RegisterAccountMigrationInterface | + +--- + +## 주의사항 + +1. **UI 라이선스 체크**: 웹 클라이언트(client/ 디렉토리)에도 라이선스 체크가 있을 수 있습니다. JavaScript 파일은 minified 상태라 수정이 어렵습니다. + +2. **버전 호환성**: 이 구현체는 Mattermost v9.x를 기준으로 작성되었습니다. 메이저 버전이 변경되면 인터페이스 시그니처가 달라질 수 있습니다. + +3. **테스트**: 업그레이드 후 반드시 모든 Enterprise 기능을 테스트하세요: + - LDAP 로그인 + - 클러스터 동기화 + - Prometheus 메트릭 (/metrics 엔드포인트) + - 커스텀 권한 스키마 생성/수정 + +4. **상용 사용**: 이 프로젝트는 학습 및 개인 사용 목적입니다. 상용 환경에서는 Mattermost 공식 라이선스를 구매하세요. diff --git a/README.md b/README.md new file mode 100644 index 00000000..80038fdf --- /dev/null +++ b/README.md @@ -0,0 +1,328 @@ +# Mattermost Community Enterprise + +라이선스 없이 Enterprise 기능을 사용할 수 있는 Mattermost 오픈소스 빌드입니다. + +## 시스템 요구사항 + +- **OS**: Rocky Linux 9 / CentOS 9 / RHEL 9 (권장) 또는 Ubuntu 22.04+ +- **CPU**: 최소 2 Core +- **RAM**: 최소 2GB (권장 4GB) +- **디스크**: 최소 20GB +- **네트워크**: 인터넷 연결 필요 (빌드 시) + +## 빠른 시작 (Docker 사용) + +### 1. 소스 코드 받기 + +```bash +git clone http://10.0.4.213:3000/claude/mattermost-community-enterprise.git +cd mattermost-community-enterprise +``` + +### 2. Docker 이미지 빌드 + +```bash +# 로컬 소스로 빌드 (권장) +docker build -f Dockerfile.local -t mattermost-community:latest . + +# 또는 Git에서 직접 빌드 (네트워크 필요) +docker build -f Dockerfile.mattermost -t mattermost-community:latest . +``` + +### 3. Docker Compose로 실행 + +```bash +# docker-compose.yml 파일 생성 (아래 내용 참고) +docker compose up -d +``` + +**docker-compose.yml 예시:** + +```yaml +version: '3.8' +services: + postgres: + image: postgres:15 + environment: + POSTGRES_DB: mattermost + POSTGRES_USER: mmuser + POSTGRES_PASSWORD: mmpassword + volumes: + - postgres_data:/var/lib/postgresql/data + restart: unless-stopped + + mattermost: + image: mattermost-community:latest + depends_on: + - postgres + ports: + - "8065:8065" + environment: + MM_SQLSETTINGS_DRIVERNAME: postgres + MM_SQLSETTINGS_DATASOURCE: postgres://mmuser:mmpassword@postgres:5432/mattermost?sslmode=disable + volumes: + - mattermost_data:/mattermost/data + - mattermost_logs:/mattermost/logs + - mattermost_plugins:/mattermost/plugins + restart: unless-stopped + +volumes: + postgres_data: + mattermost_data: + mattermost_logs: + mattermost_plugins: +``` + +### 4. 접속 + +브라우저에서 `http://서버IP:8065` 로 접속합니다. + +--- + +## 수동 빌드 (Docker 없이) + +### 1. 의존성 설치 + +**Rocky Linux / CentOS 9:** + +```bash +sudo dnf install -y git golang make gcc +``` + +**Ubuntu 22.04:** + +```bash +sudo apt update +sudo apt install -y git golang-go make gcc +``` + +### 2. Go 버전 확인 + +Go 1.21 이상이 필요합니다. + +```bash +go version +# go version go1.21.x linux/amd64 +``` + +Go 버전이 낮으면 최신 버전을 설치합니다: + +```bash +# Rocky Linux +sudo dnf module enable go-toolset:rhel9 +sudo dnf install -y go-toolset + +# 또는 직접 설치 +wget https://go.dev/dl/go1.22.0.linux-amd64.tar.gz +sudo tar -C /usr/local -xzf go1.22.0.linux-amd64.tar.gz +export PATH=$PATH:/usr/local/go/bin +``` + +### 3. 소스 코드 받기 + +```bash +git clone http://10.0.4.213:3000/claude/mattermost-community-enterprise.git +cd mattermost-community-enterprise +``` + +### 4. 빌드 + +```bash +# vendor 디렉토리 사용 (오프라인/에어갭 환경) +go build -v -mod=vendor -o mattermost ./cmd/mattermost + +# 또는 온라인 환경에서 최신 의존성 사용 +go mod download +go build -v -o mattermost ./cmd/mattermost +``` + +### 5. 디렉토리 구조 준비 + +```bash +mkdir -p /opt/mattermost/{bin,config,data,logs,plugins,client/plugins} + +# 바이너리 복사 +cp mattermost /opt/mattermost/bin/ + +# 설정 및 리소스 복사 +cp -r config/* /opt/mattermost/config/ +cp -r i18n /opt/mattermost/ +cp -r fonts /opt/mattermost/ +cp -r templates /opt/mattermost/ +cp -r client/* /opt/mattermost/client/ +``` + +### 6. 데이터베이스 설정 + +**PostgreSQL 설치 및 설정:** + +```bash +# PostgreSQL 설치 +sudo dnf install -y postgresql-server postgresql +sudo postgresql-setup --initdb +sudo systemctl enable --now postgresql + +# 데이터베이스 생성 +sudo -u postgres psql <