Skip to end of metadata
Go to start of metadata

You are viewing an old version of this content. View the current version.

Compare with Current View Version History

Version 1 Current »

Nexus repository 설치

  1. Nexus data 디렉토리 생성

    $ mkdir -p /srv/nexus-data
    $ chown -R 200 /srv/nexus-data

  2. Nexus data 디렉토리 mount + nexus 이미지 다운로드 & 컨테이너 실행

    $ docker run -itd \
    -p 8081:8081 \
    -p 51001:51001 \
    -v /srv/nexus-data:/nexus-data \
    --name nexus \
    sonatype/nexus3

  3. Nexus 접속 
    ID/PASSWORD : admin/(/srv/nexus-data 폴더에 초기 admin 비밀번호 위치)

PyPi repository 생성

  1. Repositories > Create repository > pypi (hosted) 선택

    이름 입력 후 저장

  2. 생성한 repository에 파일 업로드

    $ vi .pypirc
    [distutils]
    index-servers =
        nexus-pypi
    
    [nexus-pypi]
    repository: http://192.168.146.132:8081/repository/nexus-pypi/
    username = admin
    password = admin
    
    $ python3 -m twine upload --repository nexus-pypi python-packages/*

Keycloak 연동

Keycloak plugin 설치

https://github.com/flytreeleft/nexus3-keycloak-plugin/releases 에서 컴파일된 버전 다운로드 가능

  1. Plugin 빌드

    git clone https://github.com/flytreeleft/nexus3-keycloak-plugin.git
    cd nexus3-keycloak-plugin
    mvn clean install -Dmaven.test.skip=true

  2. Nexus install directory(/opt/sonatype/nexus)에 plugin 복사
    Docker로 생성하여 install 폴더 들어가려면 docker 콘솔 실행하여야 함

    $ docker exec -itu 0 nexus bash   ### root 권한으로 컨테이너 접속
    [root@1694b1a7a42d /]# mkdir -p /opt/sonatype/nexus/system/org/github/flytreeleft/nexus3-keycloak-plugin/0.5.0-SNAPSHOT/
    [root@1694b1a7a42d /]# exit
    $ docker cp ~/.m2/repository/org/github/flytreeleft/nexus3-keycloak-plugin/0.5.0-SNAPSHOT/nexus3-keycloak-plugin-0.5.0-SNAPSHOT.jar nexus:/opt/sonatype/nexus/system/org/github/flytreeleft/nexus3-keycloak-plugin/0.5.0-SNAPSHOT/

  3. startup.properties 파일에 번들 추가

    $ docker exec -itu 0 nexus bash
    [root@1694b1a7a42d /]# vi /opt/sonatype/nexus/etc/karaf/startup.properties
    reference\:file\:org/github/flytreeleft/nexus3-keycloak-plugin/0.5.0-SNAPSHOT/nexus3-keycloak-plugin-0.5.0-SNAPSHOT.jar = 200

  4. Keycloak 영역 클라이언트 구성
    Keycloak realm > clients > create > nexus3
    SettingsAccess Type: confidentialService Accounts Enabled: OnAuthorization Enabled: On

    Service Account RolesClient Roles: realm-managementAvailable Roles: view-realmview-clientsview-usersAdd selectedAssigned Roles

    Installation > Format Option: Keycloak OIDC JSON > 파일 복사

  5. keycloak.json 생성

    $ vi keycloak.json
    # 복사한 내용 붙여넣기
    $ docker cp keycloak.json nexus:/opt/sonatype/nexus/etc/

  6. Container 재시작

Keycloak 연동 (실패)

  1. Nexus에서 keycloak 영역 활성화

  2. Role 생성

참조 URL : https://github.com/flytreeleft/nexus3-keycloak-plugin

연동 안되는 이슈

Error 내용 : Keycloak에 user 생성 후 해당 user로 nexus 접근 시도 하였으나 접근 불가. nexus에 생성된 user정보가 있으면 연동 가능하나 새로운 user로 접속 시도 시 인증이 되지 않음. 하기 URL 참조: https://community.sonatype.com/t/authenticate-users-via-keycloak/652

추가 ) Nexus pro(유료 버전) 에서는 SAML 연동 구성이 가능하다고 합니다. https://help.sonatype.com/repomanager3/system-configuration/user-authentication/saml

  • No labels