@@ -144,6 +144,126 @@ Bu qismda o'zimizga kerak tanlovni tanlaymiz.
144144Sizda `admin` user bilan kirganingizdan keyin sizda quyidagicha dastlabki sahifa ochiladi.
145145
146146
147+ # # Nexusga domen ulash.
148+
149+ Bu bo'limda biz **Nexus**ni domen orqali ulashni va Letsencrypt sertifikat orqali SSL olishni ko'rib chiqamiz.
150+
151+ <Tabs>
152+ <TabList>
153+ <Tab>Debian Based</Tab>
154+ <Tab>Red Had Based</Tab>
155+ </TabList>
156+ <TabPanel>
157+ **1->** Nginx va certbotni o'rnatamiz.
158+
159+ ` ` ` bash
160+ sudo apt update
161+ sudo apt install nginx certbot python3-certbot-nginx -y
162+ ` ` `
163+
164+ **2->** Nexusga bo'glamoqchigan bo'lgan domenimiz DNS serveridan A record ochib serverimiz IP manzilini qo'shib qo'yamiz. Rasmda ahost misolida **helm.uz** domeniga **nexus** subdomen qo'shib ko'rsatilgan.
165+ 
166+ **3->** Bog'lamoqchi bo'lgan domenimiz nomi bilan nginx konfiguratsiyasini yaratamiz.
167+
168+ ` ` ` bash
169+ sudo nano /etc/nginx/sites-available/nexus.helm.uz
170+ ` ` `
171+ Quyidagicha konfiguratsiyani yozamiz.
172+
173+ ` ` ` nginx /etc/nginx/sites-available/nexus
174+ server {
175+ listen 80;
176+ max_body_size 100M;
177+ server_name nexus.helm.uz;
178+ location / {
179+ proxy_pass http://localhost:8081;
180+ proxy_set_header Host $host;
181+ proxy_set_header X-Real-IP $remote_addr;
182+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
183+ proxy_set_header X-Forwarded-Proto $scheme;
184+ }
185+ }
186+ ` ` `
187+
188+ **4->** Konfiguratsiyani `sites-enabled` papkasiga joylaymiz.
189+
190+ ` ` ` bash
191+ sudo ln -s /etc/nginx/sites-available/nexus.helm.uz /etc/nginx/sites-enabled/
192+ ` ` `
193+ **5->** Nginxga restart beramiz.
194+ ` ` ` bash
195+ sudo systemctl restart nginx
196+ ` ` `
197+ **6->** certbot orqali Letsencrypt sertifikatni olish uchun quyidagi buyruqni yozamiz.
198+
199+ ` ` ` bash
200+ sudo certbot
201+ ` ` `
202+ Bunda siz certbot uchun email yozasiz va **Terms of Service** ni qabul qilishingiz kerak bo'ladi `y` bosib o'tib ketasiz.
203+ 
204+ Bu qismda sizning domenlaringizni ko'rsatadi siz kerakli domenlarni tanlab `Enter` bosib o'tib ketasiz, bizning holatda 1.
205+ 
206+ Sertifikat muvaffaqiyatli olinganidan keyin nginxni restart qilamiz.
207+ ` ` ` bash
208+ sudo systemctl restart nginx
209+ ` ` `
210+ </TabPanel>
211+ <TabPanel>
212+ **1->** Nginx va certbotni o'rnatamiz.
213+ ` ` ` bash
214+ sudo yum install epel-release -y
215+ sudo yum install nginx certbot python3-certbot-nginx -y
216+ ` ` `
217+ **2->** Nexusga bo'glamoqchigan bo'lgan domenimiz DNS serveridan A record ochib serverimiz IP manzilini qo'shib qo'yamiz. Rasmda ahost misolida **helm.uz** domeniga **nexus** subdomen qo'shib ko'rsatilgan.
218+ 
219+
220+ **3->** Bog'lamoqchi bo'lgan domenimiz nomi bilan nginx konfiguratsiyasini yaratamiz.
221+
222+ ` ` ` bash
223+ sudo nano /etc/nginx/conf.d/nexus.helm.uz.conf
224+ ` ` `
225+ Quyidagicha konfiguratsiyani yozamiz.
226+
227+ ` ` ` nginx /etc/nginx/conf.d/nexus.helm.uz.conf
228+ server {
229+ listen 80;
230+ max_body_size 100M;
231+ server_name nexus.helm.uz;
232+ location / {
233+ proxy_pass http://localhost:8081;
234+ proxy_set_header Host $host;
235+ proxy_set_header X-Real-IP $remote_addr;
236+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
237+ proxy_set_header X-Forwarded-Proto $scheme;
238+ }
239+ }
240+ ` ` `
241+
242+ **4->** Nginxga restart beramiz.
243+ ` ` ` bash
244+ sudo systemctl restart nginx
245+ ` ` `
246+ **5->** certbot orqali Letsencrypt sertifikatni olish uchun quyidagi buyruqni yozamiz.
247+
248+ ` ` ` bash
249+ sudo certbot
250+ ` ` `
251+ Bunda siz certbot uchun email yozasiz va **Terms of Service** ni qabul qilishingiz kerak bo'ladi `y` bosib o'tib ketasiz.
252+ 
253+ Bu qismda sizning domenlaringizni ko'rsatadi siz kerakli domenlarni tanlab `Enter` bosib o'tib ketasiz, bizning holatda 1.
254+ 
255+ **6->** Sertifikat muvaffaqiyatli olinganidan keyin nginxni restart qilamiz.
256+ ` ` ` bash
257+ sudo systemctl restart nginx
258+ ` ` `
259+
260+ </TabPanel>
261+ </Tabs>
262+
263+ Tekshirib ko'rish uchun brauzerda **https://nexus.helm.uz** manzilini ochganimizda Nexus https bilan ochilishi kerak.
264+
265+ 
266+
147267# # Nexus bilan tanishuv
148268
149269Nexus Repository Manager **APT, Cargo, Bower CocoaPods, Composer, Conan, Conda, Docker, Git LFS, Go, Helm, Hugging Face, Maven, npm, NuGet, p2, PyPI, R, Raw, RubyGems, Yum(RPM)** kabi texnologiyalar uchun repositorylar yaratish va boshqarishni qo'llab-quvvatlaydi.
@@ -498,10 +618,218 @@ jobs:
498618 ${{ env.REGISTRY }}/${{ env.REPO_NAME }}:${{ github.sha }}
499619` ` `
500620
501- **6->** keling endi loyiha CI/CD'da ishga tushirib uni tekshirib ko'ramiz, loyihamiz barcha package va dependencylarni Nexus orqali yuklab olishi kerak.
621+ **6->** Keling endi loyiha CI/CD'da ishga tushirib uni tekshirib ko'ramiz, loyihamiz barcha package va dependencylarni Nexus orqali yuklab olishi kerak.
502622
503623Gitlab CI'da ko'rib turganinigizdek barcha package va dependencylarni **nexus.helm.uz/repository/maven-public/** manzili orqali yuklab olyapti.
504624
505625Github Actionsda
506626
507627
628+ Nexusga brazuerdan kirib ko'rganimzida ham o'zgarishlarni sezishimiz mumkin.
629+ 
630+
631+ Nexusdan **maven-central** repositoryni ko'rib chiqadigan bo'lsak nexus o'zida saqlayotgan local package va dependencylarni ko'rishimiz mumkin.
632+
633+ 
634+
635+ # ## .NET NuGet
636+
637+ **.NET Core** loyihalarni **Sonatype Nexus Repository Manager** bilan integratsiya qilish uchun quyidagicha bosqichlarni bajaramiz.
638+
639+ **1->** Loyihamizda `NuGet.Config` faylini yaratamiz va quyidagicha configuratsiya qilamiz.
640+
641+ ` ` ` bash filename="NuGet.Config"
642+ <configuration>
643+ <packageSources>
644+ <clear />
645+ <add key="Nexus" value="https://nexus.helm.uz/repository/nuget-group/index.json" />
646+ </packageSources>
647+ <packageSourceCredentials>
648+ <Nexus>
649+ <add key="Username" value="__NEXUS_USER__" />
650+ <add key="ClearTextPassword" value="__NEXUS_PASSWORD__" />
651+ </Nexus>
652+ </packageSourceCredentials>
653+ </configuration>
654+ ` ` `
655+
656+ **2->** `__NEXUS_USER__` va `__NEXUS_PASSWORD__` environment variablelarni agar sizda Gitlab bo'lsa Gitlab variablesga yoki Githubda bo'lsa Github Secretsga qo'shib qo'yishimiz kerak bo'ladi.
657+
658+ Gitlabda **Settings -> CI/CD -> Variables** bo'limiga o'tib quyidagicha variablelarni qo'shib qo'yamiz.
659+
660+ ` NEXUS_USER` - Nexusga kirish uchun foydalanuvchi nomi.
661+ 
662+ ` NEXUS_PASSWORD` - Nexusga kirish uchun foydalanuvchi paroli.
663+ 
664+
665+ Githubda esa **Settings -> Secrets -> New repository secret** bo'limiga o'tib quyidagicha secretlarni qo'shib qo'yamiz.
666+
667+ ` NEXUS_USER` - Nexusga kirish uchun foydalanuvchi nomi.
668+ 
669+ ` NEXUS_PASSWORD` - Nexusga kirish uchun foydalanuvchi paroli.
670+ 
671+
672+ **3->** Dockerfile faylini quyidagicha yangilaymiz.
673+ ` ` ` bash
674+ COPY NuGet.Config /root/.nuget/NuGet/NuGet.Config
675+ ` ` `
676+ qatorini Dockerfilega qo'shib qo'yamiz.
677+
678+ ` ` ` bash filename="Dockerfile" {4}
679+ FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build-env
680+ WORKDIR /app
681+
682+ COPY NuGet.Config /root/.nuget/NuGet/NuGet.Config
683+ COPY . .
684+ WORKDIR "/app/GitHub.Actions.API"
685+ RUN dotnet publish "GitHub.Actions.API.csproj" -o /app/build -c Release
686+
687+ FROM mcr.microsoft.com/dotnet/aspnet:7.0
688+ WORKDIR /app
689+ ENV ASPNETCORE_ENVIRONMENT=Development
690+ ENV TZ="Asia/Tashkent"
691+ COPY --from=build-env /app/build .
692+ ENTRYPOINT ["dotnet", "GitHub.Actions.API.dll", "--urls=http://0.0.0.0:4001"]
693+ ` ` `
694+
695+ **4->** Loyihamiz CI/CD'dasida ham o'zgarishlar kiritishimiz kerak bo'ladi.
696+
697+ Github Actions `.github/workflows/ci-cd.yml` faylini quyidagicha yangilaymiz.
698+
699+ ` ` ` yaml filename=".github/workflows/ci-cd.yml"
700+ - name: Replace Nexus Credentials in NuGet.Config
701+ run: |
702+ sed -i "s|__NEXUS_USER__|${{ secrets.NEXUS_USER }}|g" NuGet.Config
703+ sed -i "s|__NEXUS_PASSWORD__|${{ secrets.NEXUS_PASSWORD }}|g" NuGet.Config
704+ ` ` `
705+ To'liq Github Actions `ci-cd` fayli quyidagicha ko'rinishda bo'ladi.
706+
707+ ` ` ` yaml filename=".github/workflows/ci-cd.yml" {43-46}
708+ name: Docker CI/CD
709+
710+ on:
711+ push:
712+ branches: [ main ]
713+ pull_request:
714+ branches: [ main ]
715+
716+ env:
717+ API_IMAGE_NAME: github-api
718+ API_CONTAINER_NAME: github-api
719+ UI_IMAGE_NAME: github-ui
720+ UI_CONTAINER_NAME: github-ui
721+ UI_PORT: 4000:4000
722+ API_PORT: 4001:4001
723+
724+ REPO_NAME: ${{ github.repository }}
725+ REGISTRY: ghcr.io
726+ SSH_HOST: ${{ secrets.SERVER_IP }}
727+ SSH_USER: ${{ secrets.SERVER_USERNAME }}
728+ SSH_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
729+
730+ jobs:
731+ build_and_push:
732+ runs-on: ubuntu-latest
733+ permissions:
734+ contents: read
735+ packages: write
736+ steps:
737+ - name: Checkout code
738+ uses: actions/checkout@v3
739+
740+ - name: Set up Docker Buildx
741+ uses: docker/setup-buildx-action@v3
742+
743+ - name: Log in to the Container registry
744+ uses: docker/login-action@v3
745+ with:
746+ registry: ${{ env.REGISTRY }}
747+ username: ${{ github.actor }}
748+ password: ${{ secrets.GITHUB_TOKEN }}
749+
750+ - name: Replace Nexus Credentials in NuGet.Config
751+ run: |
752+ sed -i "s|__NEXUS_USER__|${{ secrets.NEXUS_USER }}|g" NuGet.Config
753+ sed -i "s|__NEXUS_PASSWORD__|${{ secrets.NEXUS_PASSWORD }}|g" NuGet.Config
754+
755+ - name: Build and push API Docker image
756+ uses: docker/build-push-action@v5
757+ with:
758+ context: .
759+ file: ./API.Dockerfile
760+ push: true
761+ tags: ${{ env.REGISTRY }}/${{ env.REPO_NAME}}/${{ env.API_IMAGE_NAME }}:${{ github.sha }}
762+ cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.REPO_NAME}}/${{ env.API_IMAGE_NAME }}:buildcache
763+ cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.REPO_NAME}}/${{ env.API_IMAGE_NAME }}:buildcache,mode=max
764+
765+ - name: Build and push UI Docker image
766+ uses: docker/build-push-action@v5
767+ with:
768+ context: .
769+ file: ./UI.Dockerfile
770+ push: true
771+ tags: ${{ env.REGISTRY }}/${{ env.REPO_NAME}}/${{ env.UI_IMAGE_NAME }}:${{ github.sha }}
772+ cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.REPO_NAME}}/${{ env.UI_IMAGE_NAME }}:buildcache
773+ cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.REPO_NAME}}/${{ env.UI_IMAGE_NAME }}:buildcache,mode=max
774+
775+ deploy:
776+ needs: build_and_push
777+ runs-on: ubuntu-latest
778+ permissions:
779+ contents: read
780+ packages: write
781+ steps:
782+ - name: Executing remote SSH commands to deploy
783+ uses: appleboy/ssh-action@master
784+ with:
785+ host: "${{ env.SSH_HOST }}"
786+ username: "${{ env.SSH_USER }}"
787+ key: "${{ env.SSH_KEY }}"
788+ script: |
789+ echo ${{ secrets.GITHUB_TOKEN }} | docker login -u ${{ github.actor }} --password-stdin ${{ env.REGISTRY }}
790+ docker pull "${{ env.REGISTRY }}/${{ env.REPO_NAME}}/${{ env.API_IMAGE_NAME }}:${{ github.sha }}"
791+ docker pull "${{ env.REGISTRY }}/${{ env.REPO_NAME}}/${{ env.UI_IMAGE_NAME }}:${{ github.sha }}"
792+ docker stop "${{ env.UI_CONTAINER_NAME }}" || true
793+ docker stop "${{ env.API_CONTAINER_NAME }}" || true
794+ docker rm "${{ env.UI_CONTAINER_NAME }}" || true
795+ docker rm "${{ env.API_CONTAINER_NAME }}" || true
796+ docker run -d --name "${{ env.API_CONTAINER_NAME }}" --restart=always -p "${{ env.API_PORT }}" "${{ env.REGISTRY }}/${{ env.REPO_NAME}}/${{ env.API_IMAGE_NAME }}:${{ github.sha }}"
797+ docker run -d --name "${{ env.UI_CONTAINER_NAME }}" --restart=always -p "${{ env.UI_PORT }}" "${{ env.REGISTRY }}/${{ env.REPO_NAME}}/${{ env.UI_IMAGE_NAME }}:${{ github.sha }}"
798+ ` ` `
799+
800+ **5->** Keling endi loyiha CI/CD'da ishga tushirib uni tekshirib ko'ramiz, loyihamiz barcha package va dependencylarni Nexus orqali yuklab olishi kerak.
801+
802+ Ko'rib turganingizdek Github Actions CI/CD muvaffaqiyatli yakunlangan.
803+ 
804+ 
805+
806+ Nexusga brazuerdan kirib ko'rganimzida ham o'zgarishlarni sezishimiz mumkin.
807+ 
808+
809+ Nexusdan **nuget-group** repositoryni ko'rib chiqadigan bo'lsak nexus o'zida saqlayotgan local package va dependencylarni ko'rishimiz mumkin.
810+
811+ 
812+
813+
814+ # # Qo'shimcha
815+ <Callout type="info" emoji="">
816+
817+ Qo'shimcha Resurslar
818+ * [**Gitlab Server o'rnatish va sozlash**](https://devops-journey.uz/guides/ci-cd/gitlab-server)
819+ * [**Gitlab CI | Releaselar va Integrationlar**](https://devops-journey.uz/guides/ci-cd/gitlab-ci-release-integrations)
820+ * [**Github Actions bilan Flutter CI/CD**](https://devops-journey.uz/guides/ci-cd/flutter-github-action)
821+ * [**Github Actions CI/CD**](https://devops-journey.uz/guides/ci-cd/github-actions-ci-cd)
822+ * [**Linux Serverlarga Jenkins o'rnatish**](https://devops-journey.uz/guides/ci-cd/jenkins-ornatish)
823+ * [**Koddan Servergacha: Jenkins bilan Docker CI/CD va Discord bilan integratsiya**](https://devops-journey.uz/guides/ci-cd/jenkins-docker-ci-cd)
824+ * [**Kubernetes CI/CD | GitHub Actions + Argo CD | GitOps**](https://devops-journey.uz/guides/ci-cd/github-actions-argocd-cicd)
825+
826+ **Sana:** 2025.02.08(2025-yil 8-fevral)
827+
828+ **Oxirgi yangilanish:** 2025.02.08(2025-yil 8-fevral)
829+
830+ **Muallif: Otabek Ismoilov**
831+
832+ | [Telegram](https://t.me/Otabek_Ismoilov) | [GitHub](https://github.com/ismoilovdevml) | [LinkedIn](https://www.linkedin.com/in/otabek-ismoilov/) |
833+ | - | - | - |
834+
835+ </Callout>
0 commit comments