본문 바로가기

Development Tools/Docker

[ Docker ] Nexus 저장소 설치

# systemctl 사용을 위해 centos 8버전 설치(7버전의 경우 맥에서 실행시 D-Bus 오류 발생)
# jdk 1.8 버전 설치 시 아키텍처 에러가 발생할 경우 platform 옵션을 통해 아키텍처를 지정해 줌
# --platform linux/amd64
# 설치하는 OS와 맡는 platform을 지정해 주어야 한다.
# docker run --privileged --cap-add=SYS_TIME -d -p 8881:8881 --name nexus centos:8 init
docker run --privileged --cap-add=SYS_TIME --platform linux/arm64/v8 -d -p 8881:8881 --name nexus centos:8 init

docker exec -it nexus /bin/bash

# yum 설치를 위한 저장소 지정 1
sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-Linux-*

# yum 설치를 위한 저장소 지정 2
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-Linux-*

# 포트 확인 툴 설치
yum -y install net-tools

# java 1.8 버전 설치
yum -y install java-1.8.0-openjdk-devel

mkdir -p /app/install/ /app/server/nexus/

# nexus 저장소 다운로드
curl -L https://download.sonatype.com/nexus/3/nexus-3.68.1-02-java8-unix.tar.gz -o /app/install/nexus-3.68.tar.gz

tar xvfz /app/install/nexus-3.68.tar.gz -C /app/server/nexus/ --strip-components=1

# nexus 실행 유저를 nexus로 지정
echo run_as_user=\"nexus\" > /app/server/nexus/bin/nexus.rc

# nexus 실행시 자동으로 생성되는 데이터 폴더를 nexus 폴더 내 sonatype-work 폴더로 위치하도록 설정
sed -i 's|\.\./sonatype-work|./sonatype-work|g' /app/server/nexus/.install4j/i4jparams.conf
sed -i 's|\.\./sonatype-work|./sonatype-work|g' /app/server/nexus/bin/nexus.vmoptions
sed -i 's|\.\./\.\./\.\./sonatype-work|../../sonatype-work|g' /app/server/nexus/replicator/bin/replicator.vmoptions

# nexus 실행 포트를 8881로 지정
cat <<'NEXUS_SETTING' > /app/server/nexus/etc/nexus-default.properties
## DO NOT EDIT - CUSTOMIZATIONS BELONG IN $data-dir/etc/nexus.properties
##
# Jetty section
application-port=8881
application-host=0.0.0.0
nexus-args=${jetty.etc}/jetty.xml,${jetty.etc}/jetty-http.xml,${jetty.etc}/jetty-requestlog.xml
nexus-context-path=/

# Nexus section
nexus-edition=nexus-pro-edition
nexus-features=\
 nexus-pro-feature

nexus.hazelcast.discovery.isEnabled=true
NEXUS_SETTING

# 리눅스 nexus 실행 유저 생성
adduser nexus

# nexus 폴더에 대한 권한을 nexus 실행 유저에게 할당
chown -R nexus:nexus /app/server/nexus

# nexus 실행 및 종료 서비스 파일 생성
cat <<NEXUS_SETTING > /etc/systemd/system/nexus.service
[Unit]
Description=Nexus Repository Manager
After=network.target

[Service]
Type=forking
LimitNOFILE=65536
User=nexus
Group=nexus
ExecStart=/app/server/nexus/bin/nexus start
ExecStop=/app/server/nexus/bin/nexus stop
User=nexus
Restart=on-abort

[Install]
WantedBy=multi-user.target
NEXUS_SETTING

systemctl daemon-reload
systemctl enable nexus

# nexus 실행(실행되는 시간이 걸림)
# /app/server/nexus/bin/nexus start
systemctl start nexus

# 시작하는데 시간이 걸림
# 8881 포트가 출력될 때까지 대기
netstat -tnlp

# 기본 아이디 및 패스워드 확인
echo -e "\nID : admin\nPW : $(cat /app/server/nexus/sonatype-work/nexus3/admin.password)\n"

ID 및 비번을 확인
[ http://localhost:8881/ ] 접속
[ Sign in ] ⇨ 확인 한 [ ID/PW ] 입력
[ Next ]
변경 비밀번호 입력 ⇨ [ Next ]
[ Enable anonymous access ] 선택 ⇨ [ Next ]
[ Finish ]

 

'Development Tools > Docker' 카테고리의 다른 글

[ Docker ] Docker Volumes 관리  (0) 2024.05.23
[ Docker ] Rocket.Chat 설치  (0) 2024.05.23
[ Docker ] Nginx 헤더 취약점 방지  (0) 2024.05.10
[ Docker ] Jupyter Notebook 설치  (0) 2024.04.05
[ Docker ] Docker Compose 작성  (0) 2024.01.22