117 lines
4.5 KiB
TypeScript
117 lines
4.5 KiB
TypeScript
|
|
import { Alert } from '../components/common/Alert';
|
||
|
|
import { CodeBlock } from '../components/common/CodeBlock';
|
||
|
|
|
||
|
|
export default function NexusUsage() {
|
||
|
|
return (
|
||
|
|
<div className="max-w-4xl mx-auto py-12 px-6">
|
||
|
|
<h1 className="text-3xl font-bold text-text-primary mb-2">Nexus 사용법</h1>
|
||
|
|
<p className="text-text-secondary mb-8">
|
||
|
|
Maven, Gradle, npm 프록시 설정 방법과 프라이빗 패키지 배포 가이드입니다.
|
||
|
|
</p>
|
||
|
|
|
||
|
|
<Alert type="info" title="Nexus 주소">
|
||
|
|
<strong>nexus.gc-si.dev</strong> — 웹 UI에서 저장소 목록과 패키지를 확인할 수 있습니다.
|
||
|
|
</Alert>
|
||
|
|
|
||
|
|
{/* Maven */}
|
||
|
|
<h2 className="text-xl font-bold text-text-primary mt-10 mb-4">Maven 프록시 설정</h2>
|
||
|
|
<p className="text-text-secondary mb-4">
|
||
|
|
Maven 프로젝트에서 Nexus를 프록시로 사용하려면 <code className="bg-bg-tertiary px-1 rounded">~/.m2/settings.xml</code>을 설정합니다.
|
||
|
|
</p>
|
||
|
|
<CodeBlock
|
||
|
|
language="xml"
|
||
|
|
filename="~/.m2/settings.xml"
|
||
|
|
code={`<settings>
|
||
|
|
<mirrors>
|
||
|
|
<mirror>
|
||
|
|
<id>nexus</id>
|
||
|
|
<mirrorOf>*</mirrorOf>
|
||
|
|
<url>https://nexus.gc-si.dev/repository/maven-public/</url>
|
||
|
|
</mirror>
|
||
|
|
</mirrors>
|
||
|
|
<servers>
|
||
|
|
<server>
|
||
|
|
<id>nexus</id>
|
||
|
|
<username>\${env.NEXUS_USERNAME}</username>
|
||
|
|
<password>\${env.NEXUS_PASSWORD}</password>
|
||
|
|
</server>
|
||
|
|
</servers>
|
||
|
|
</settings>`}
|
||
|
|
/>
|
||
|
|
|
||
|
|
{/* Gradle */}
|
||
|
|
<h2 className="text-xl font-bold text-text-primary mt-10 mb-4">Gradle 프록시 설정</h2>
|
||
|
|
<p className="text-text-secondary mb-4">
|
||
|
|
<code className="bg-bg-tertiary px-1 rounded">build.gradle</code>의 repositories 블록에 Nexus를 추가합니다.
|
||
|
|
</p>
|
||
|
|
<CodeBlock
|
||
|
|
language="groovy"
|
||
|
|
filename="build.gradle"
|
||
|
|
code={`repositories {
|
||
|
|
maven {
|
||
|
|
url 'https://nexus.gc-si.dev/repository/maven-public/'
|
||
|
|
credentials {
|
||
|
|
username = findProperty('nexusUsername') ?: System.getenv('NEXUS_USERNAME')
|
||
|
|
password = findProperty('nexusPassword') ?: System.getenv('NEXUS_PASSWORD')
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}`}
|
||
|
|
/>
|
||
|
|
<Alert type="info">
|
||
|
|
인증 정보는 <code className="bg-bg-tertiary px-1 rounded">~/.gradle/gradle.properties</code>에 <code className="bg-bg-tertiary px-1 rounded">nexusUsername</code>/<code className="bg-bg-tertiary px-1 rounded">nexusPassword</code>로 설정할 수도 있습니다.
|
||
|
|
</Alert>
|
||
|
|
|
||
|
|
{/* npm */}
|
||
|
|
<h2 className="text-xl font-bold text-text-primary mt-10 mb-4">npm 프록시 설정</h2>
|
||
|
|
<p className="text-text-secondary mb-4">
|
||
|
|
프로젝트 루트의 <code className="bg-bg-tertiary px-1 rounded">.npmrc</code> 파일에 Nexus 레지스트리를 설정합니다.
|
||
|
|
</p>
|
||
|
|
<CodeBlock
|
||
|
|
language="ini"
|
||
|
|
filename=".npmrc"
|
||
|
|
code={`registry=https://nexus.gc-si.dev/repository/npm-public/
|
||
|
|
//nexus.gc-si.dev/repository/npm-public/:_auth=\${NPM_AUTH_TOKEN}
|
||
|
|
always-auth=true`}
|
||
|
|
/>
|
||
|
|
<Alert type="warning" title="보안 주의">
|
||
|
|
<code className="bg-bg-tertiary px-1 rounded">_auth</code> 값을 <code className="bg-bg-tertiary px-1 rounded">.npmrc</code>에 직접 하드코딩하지 마세요. 환경변수 또는 <code className="bg-bg-tertiary px-1 rounded">~/.npmrc</code>(글로벌)에 설정하고, 프로젝트 <code className="bg-bg-tertiary px-1 rounded">.npmrc</code>는 레지스트리 URL만 포함합니다.
|
||
|
|
</Alert>
|
||
|
|
|
||
|
|
{/* 패키지 배포 */}
|
||
|
|
<h2 className="text-xl font-bold text-text-primary mt-10 mb-4">프라이빗 패키지 배포</h2>
|
||
|
|
<p className="text-text-secondary mb-4">
|
||
|
|
사내 공유 라이브러리를 Nexus에 배포할 수 있습니다.
|
||
|
|
</p>
|
||
|
|
|
||
|
|
<h3 className="text-lg font-semibold text-text-primary mt-6 mb-3">Maven 배포</h3>
|
||
|
|
<CodeBlock
|
||
|
|
language="xml"
|
||
|
|
filename="pom.xml"
|
||
|
|
code={`<distributionManagement>
|
||
|
|
<repository>
|
||
|
|
<id>nexus</id>
|
||
|
|
<url>https://nexus.gc-si.dev/repository/maven-releases/</url>
|
||
|
|
</repository>
|
||
|
|
<snapshotRepository>
|
||
|
|
<id>nexus</id>
|
||
|
|
<url>https://nexus.gc-si.dev/repository/maven-snapshots/</url>
|
||
|
|
</snapshotRepository>
|
||
|
|
</distributionManagement>`}
|
||
|
|
/>
|
||
|
|
<CodeBlock language="bash" code="mvn deploy" />
|
||
|
|
|
||
|
|
<h3 className="text-lg font-semibold text-text-primary mt-6 mb-3">npm 배포</h3>
|
||
|
|
<CodeBlock
|
||
|
|
language="json"
|
||
|
|
filename="package.json"
|
||
|
|
code={`{
|
||
|
|
"publishConfig": {
|
||
|
|
"registry": "https://nexus.gc-si.dev/repository/npm-hosted/"
|
||
|
|
}
|
||
|
|
}`}
|
||
|
|
/>
|
||
|
|
<CodeBlock language="bash" code="npm publish" />
|
||
|
|
</div>
|
||
|
|
);
|
||
|
|
}
|