From 8f53936db7b502f16e27a3421ee4e1db3bbf47ad Mon Sep 17 00:00:00 2001 From: Maria Volkova Date: Wed, 6 Nov 2024 14:05:48 +0300 Subject: [PATCH] first commit first commit --- .github/workflows/deploy-backend.yml | 55 ++++++ .github/workflows/deploy-infra.yml | 27 +++ .gitignore | 5 + README.md | 58 ++++++ backend/Dockerfile | 15 ++ backend/packages.json | 266 +++++++++++++++++++++++++++ infra/environment.yml | 46 +++++ 7 files changed, 472 insertions(+) create mode 100644 .github/workflows/deploy-backend.yml create mode 100644 .github/workflows/deploy-infra.yml create mode 100644 .gitignore create mode 100644 README.md create mode 100644 backend/Dockerfile create mode 100644 backend/packages.json create mode 100644 infra/environment.yml diff --git a/.github/workflows/deploy-backend.yml b/.github/workflows/deploy-backend.yml new file mode 100644 index 0000000..efdcabb --- /dev/null +++ b/.github/workflows/deploy-backend.yml @@ -0,0 +1,55 @@ +name: Cloud platform deployment + +on: + workflow_dispatch: + push: + paths: + - 'backend/**' + branches: [ main ] + +jobs: + gitops: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Az config + run: | + az config set extension.use_dynamic_install=yes_without_prompt + + - name: Install vc-build + run: | + dotnet tool install --global VirtoCommerce.GlobalTool + + - name: Pack + run: | + vc-build install -PackageManifestPath ./backend/packages.json -ProbingPath ./backend/platform/app_data/modules -DiscoveryPath ./backend/platform/modules --root ./backend/platform -SkipDependencySolving + + - name: Get platfrom version + id: platform-version + run: | + echo "PLATFORM_VERSION=$(cat ./backend/packages.json | jq -r '.PlatformVersion')" >> $GITHUB_ENV + + - name: Set outputs + id: vars + run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT + + - name: Build and Publish Docker Image to Virto container registry + run: | + vc-build BuildAndPush -DockerUsername $DOCKER_LOGIN -DockerPassword $DOCKER_PASSWORD -DockerfilePath $DOCKERFILE_PATH -DockerImageName $IMAGE_REPOSITORY -DockerImageTag $TAG -DockerRegistryUrl $CONTAINER_REGISTRY + env: + DOCKER_LOGIN: virtostart + DOCKER_PASSWORD: ${{ secrets.VIRTOSTART_ACR_DOCKER_PASSWORD }} + DOCKERFILE_PATH: ./backend/Dockerfile + CONTAINER_REGISTRY: virtopaasregistrymain.azurecr.io + IMAGE_REPOSITORY: virtopaasregistrymain.azurecr.io/virtostart/platform + TAG: ${{ env.PLATFORM_VERSION }}-${{ steps.vars.outputs.sha_short }} + + - name: Update app + run: | + vc-build CloudEnvSetParameter -EnvironmentName virtostart-main -CloudToken ${{ secrets.VIRTOSTART_PLATFORM_TOKEN }} -HelmParameters platform.image.tag=$TAG + env: + TAG: ${{ env.PLATFORM_VERSION }}-${{ steps.vars.outputs.sha_short }} diff --git a/.github/workflows/deploy-infra.yml b/.github/workflows/deploy-infra.yml new file mode 100644 index 0000000..ed47a2d --- /dev/null +++ b/.github/workflows/deploy-infra.yml @@ -0,0 +1,27 @@ +name: Cloud infra deployment + +on: + workflow_dispatch: + push: + paths: + - 'infra/**' + branches: [ main ] + +jobs: + gitops: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Install vc-build + run: | + dotnet tool install --global VirtoCommerce.GlobalTool + + - name: Update app + run: | + vc-build CloudEnvUpdate -Manifest $ENV_FILE -CloudToken ${{ secrets.VIRTOSTART_PLATFORM_TOKEN }} + env: + ENV_FILE: './infra/environment.yml' diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e915029 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +################################################################################ +# This .gitignore file was automatically created by Microsoft(R) Visual Studio. +################################################################################ + +/.vs diff --git a/README.md b/README.md new file mode 100644 index 0000000..f549b30 --- /dev/null +++ b/README.md @@ -0,0 +1,58 @@ +# Overview +Initial GitOps template for Virto Cloud. + +## Features +* GitOps repository structure for Virto Commerce Platform and Virto Cloud infrastructure. +* GitHub workflows for automatic deployment of Virto Commerce Platform and Virto Cloud infrastructure. + +## Folder structure +* **.github/workflows** - GitHub workflows folder with trigger on commit to the main branch. + * **deploy-backend.yml** - GitHub workflow with Cloud platform deployment actions. + * **deploy-infra.yml** - GitHub workflow with Cloud infra deployment actions. +* **backend** - Virto Commerce Platform deployment. + * **packages.json** - defines version of Virto Commerce Platform and modules. + * **Dockerfile** - Dockerfile for Virto Commerce Platform deployment. +* **infra** - declarative description of Virto Cloud infrastructure deployment. + * environment.yml + + +## How to use + +### Pre-requirements +1. Access to Virto Cloud Portal. +1. Create and deploy new environment in Virto Cloud Portal. +1. Download environment manifest from Virto Cloud Portal. +1. Create API Key in Virto Cloud Portal (PLATFORM_TOKEN). +1. DOCKER_LOGIN +1. DOCKER_PASSWORD +1. Enable GitOps in Virto Cloud Portal for the environment. + + +### GitHub repository setup +1. Create a new repository in your GitHub account. +1. Copy content of from this branch to your repository. + +### Cloud infrastucture deployment +1. Download environment manifest from Virto Cloud and put it to the **infra** folder. + +If you use environment.yml from this repository, you need to replace the following placeholders: +1. Replace TODO_YOUR_ENVIRONMENT_NAME with your environment name in the **environment.yml** file. +1. Replace TODO_YOUR_FRONTEND_HOSTNAME with your frontend hostname in the **environment.yml** file. +1. Replace TODO_YOUR_STORE_ID with your store id in the **environment.yml** file. + +### Virto Commerce Platform deployment +1. Update **packages.json** file with the required version of Virto Commerce Platform and modules. +1. Set DOCKER_LOGIN in deploy-backend.yml + +### GitHub Actions +1. Go to the **Settings** tab of your repository. +1. Go to the **Secrets** section. +1. Add VIRTOSTART_ACR_DOCKER_PASSWORD and VIRTOSTART_PLATFORM_TOKEN secrets. + +## Do Commit to the main branch +1. Commit changes to the main branch. +1. Review GitHub Actions logs. +1. Review Virto Cloud Portal logs. + + + diff --git a/backend/Dockerfile b/backend/Dockerfile new file mode 100644 index 0000000..5c4f5cd --- /dev/null +++ b/backend/Dockerfile @@ -0,0 +1,15 @@ +FROM mcr.microsoft.com/dotnet/aspnet:8.0 + +COPY ./backend/platform /opt/virtocommerce/platform + +RUN apt-get update && apt-get install -y wget fontconfig libfreetype6 libx11-6 libxcb1 libxext6 libxrender1 xfonts-75dpi xfonts-base libjpeg62-turbo + +RUN apt-get clean autoclean \ + && apt-get autoremove --yes \ + && rm -rf /var/lib/{apt,dpkg,cache,log}/ +WORKDIR /opt/virtocommerce/platform + +EXPOSE 80 +ENV ASPNETCORE_HTTP_PORTS=80 +ENTRYPOINT ["dotnet", "VirtoCommerce.Platform.Web.dll"] +# diff --git a/backend/packages.json b/backend/packages.json new file mode 100644 index 0000000..be43405 --- /dev/null +++ b/backend/packages.json @@ -0,0 +1,266 @@ +{ + "ManifestVersion": "2.0", + "PlatformVersion": "3.852.0", + "PlatformAssetUrl": "", + "ModuleSources": [ + "https://raw.githubusercontent.com/VirtoCommerce/vc-modules/master/modules_v3.json" + ], + "Sources": [ + { + "Name": "GithubReleases", + "ModuleSources": [ + "https://raw.githubusercontent.com/VirtoCommerce/vc-modules/master/modules_v3.json" + ], + "Modules": [ + { + "Id": "VirtoCommerce.ApplicationInsights", + "Version": "3.800.0" + }, + { + "Id": "VirtoCommerce.Assets", + "Version": "3.807.0" + }, + { + "Id": "VirtoCommerce.AuthorizeNetPayment", + "Version": "3.801.0" + }, + { + "Id": "VirtoCommerce.AvalaraTax", + "Version": "3.800.0" + }, + { + "Id": "VirtoCommerce.AzureAD", + "Version": "3.801.0" + }, + { + "Id": "VirtoCommerce.AzureBlobAssets", + "Version": "3.808.0" + }, + { + "Id": "VirtoCommerce.AzureSearch", + "Version": "3.804.0" + }, + { + "Id": "VirtoCommerce.BulkActionsModule", + "Version": "3.801.0" + }, + { + "Id": "VirtoCommerce.BuilderIO", + "Version": "3.803.0" + }, + { + "Id": "VirtoCommerce.Cart", + "Version": "3.812.0" + }, + { + "Id": "VirtoCommerce.Catalog", + "Version": "3.821.0" + }, + { + "Id": "VirtoCommerce.CatalogCsvImportModule", + "Version": "3.801.0" + }, + { + "Id": "VirtoCommerce.CatalogPersonalization", + "Version": "3.801.0" + }, + { + "Id": "VirtoCommerce.CatalogPublishing", + "Version": "3.801.0" + }, + { + "Id": "VirtoCommerce.Content", + "Version": "3.822.0" + }, + { + "Id": "VirtoCommerce.Contracts", + "Version": "3.803.0" + }, + { + "Id": "VirtoCommerce.Core", + "Version": "3.807.0" + }, + { + "Id": "VirtoCommerce.Customer", + "Version": "3.816.0" + }, + { + "Id": "VirtoCommerce.CustomerExportImport", + "Version": "3.807.0" + }, + { + "Id": "VirtoCommerce.CustomerReviews", + "Version": "3.805.0" + }, + { + "Id": "VirtoCommerce.DynamicAssociationsModule", + "Version": "3.803.0" + }, + { + "Id": "VirtoCommerce.ElasticAppSearch", + "Version": "3.805.0" + }, + { + "Id": "VirtoCommerce.ElasticSearch", + "Version": "3.802.0" + }, + { + "Id": "VirtoCommerce.ElasticSearch8", + "Version": "3.809.0" + }, + { + "Id": "VirtoCommerce.EventBus", + "Version": "3.803.0" + }, + { + "Id": "VirtoCommerce.Export", + "Version": "3.802.0" + }, + { + "Id": "VirtoCommerce.FileExperienceApi", + "Version": "3.803.0" + }, + { + "Id": "VirtoCommerce.FileSystemAssets", + "Version": "3.804.0" + }, + { + "Id": "VirtoCommerce.GDPR", + "Version": "3.802.0" + }, + { + "Id": "VirtoCommerce.GoogleEcommerceAnalytics", + "Version": "4.801.0" + }, + { + "Id": "VirtoCommerce.GoogleSSO", + "Version": "3.800.0" + }, + { + "Id": "VirtoCommerce.ImageTools", + "Version": "3.805.0" + }, + { + "Id": "VirtoCommerce.Inventory", + "Version": "3.804.0" + }, + { + "Id": "VirtoCommerce.LuceneSearch", + "Version": "3.804.0" + }, + { + "Id": "VirtoCommerce.Marketing", + "Version": "3.811.0" + }, + { + "Id": "VirtoCommerce.NativePaymentMethods", + "Version": "3.801.0" + }, + { + "Id": "VirtoCommerce.Notifications", + "Version": "3.808.0" + }, + { + "Id": "VirtoCommerce.Orders", + "Version": "3.829.0" + }, + { + "Id": "VirtoCommerce.Payment", + "Version": "3.803.0" + }, + { + "Id": "VirtoCommerce.PriceExportImport", + "Version": "3.800.0" + }, + { + "Id": "VirtoCommerce.Pricing", + "Version": "3.808.0" + }, + { + "Id": "VirtoCommerce.ProfileExperienceApiModule", + "Version": "3.816.0" + }, + { + "Id": "VirtoCommerce.PushMessages", + "Version": "3.810.0" + }, + { + "Id": "VirtoCommerce.Quote", + "Version": "3.816.0" + }, + { + "Id": "VirtoCommerce.Return", + "Version": "3.803.0" + }, + { + "Id": "VirtoCommerce.Search", + "Version": "3.803.0" + }, + { + "Id": "VirtoCommerce.ShipStation", + "Version": "3.800.0" + }, + { + "Id": "VirtoCommerce.Shipping", + "Version": "3.801.0" + }, + { + "Id": "VirtoCommerce.Sitemaps", + "Version": "3.807.0" + }, + { + "Id": "VirtoCommerce.Skyflow", + "Version": "3.806.0" + }, + { + "Id": "VirtoCommerce.Store", + "Version": "3.808.0" + }, + { + "Id": "VirtoCommerce.Subscription", + "Version": "3.805.0" + }, + { + "Id": "VirtoCommerce.TaskManagement", + "Version": "3.803.0" + }, + { + "Id": "VirtoCommerce.Tax", + "Version": "3.801.0" + }, + { + "Id": "VirtoCommerce.WebHooks", + "Version": "3.804.0" + }, + { + "Id": "VirtoCommerce.WhiteLabeling", + "Version": "3.803.0" + }, + { + "Id": "VirtoCommerce.XCMS", + "Version": "3.800.0" + }, + { + "Id": "VirtoCommerce.XCart", + "Version": "3.806.0" + }, + { + "Id": "VirtoCommerce.XCatalog", + "Version": "3.812.0" + }, + { + "Id": "VirtoCommerce.XOrder", + "Version": "3.804.0" + }, + { + "Id": "VirtoCommerce.XRecommend", + "Version": "3.804.0" + }, + { + "Id": "VirtoCommerce.Xapi", + "Version": "3.807.0" + } + ] + } + ] +} \ No newline at end of file diff --git a/infra/environment.yml b/infra/environment.yml new file mode 100644 index 0000000..77982f1 --- /dev/null +++ b/infra/environment.yml @@ -0,0 +1,46 @@ +- name: TODO_YOUR_ENVIRONMENT_NAME + gitops: true + production: false + servicePlan: B1 + platform: + dbProvider: AzureSQL Database + imageRepository: virtopaasregistrymain.azurecr.io/virtostart/platform + sqlReplica: false + config: + APPINSIGHTS_INSTRUMENTATIONKEY: 26f3faa1-f3fb-4bd4-aff4-89d7241cf249 + reboot: 3 + storefront: + enabled: false + themes: + TODO_YOUR_STORE_ID: https://github.com/VirtoCommerce/vc-theme-b2b-vue/releases/download/2.5.0/vc-theme-b2b-vue-2.5.0.zip + ingress: {} + customApps: + app1: + enabled: false + app2: + enabled: false + routes: + - host: TODO_YOUR_FRONTEND_HOSTNAME + root: TODO_YOUR_STORE_ID + paths: + - path: /xapi + route: platform + - path: /files + route: platform + - path: /connect/token + route: platform + - path: /graphql + route: platform + - path: /revoke/token + route: platform + - path: /api/files + route: platform + - path: /externalsignin + route: platform + - path: /signin-oidc + route: platform + - path: /signin-google + route: platform + protectedParameters: + - platform.image.tag + version: 3.219