-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
first commit
- Loading branch information
Maria Volkova
committed
Nov 6, 2024
0 parents
commit 8f53936
Showing
7 changed files
with
472 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
################################################################################ | ||
# This .gitignore file was automatically created by Microsoft(R) Visual Studio. | ||
################################################################################ | ||
|
||
/.vs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"] | ||
# |
Oops, something went wrong.