Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitbook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,4 @@ redirects:
products/extensions/migration-assistant/concept.html: products/extensions/migration-assistant/concept/index.html
products/extensions/migration-assistant/guides.html: products/extensions/migration-assistant/guides/index.html
products/cli/project-commands/project-config-sync.html: resources/tooling/fixture-bundle/index.html
products/sales-agent/deployment.html: products/sales-agent/best-practices/app-deployment/hosted-with-ubuntu-server.html
27 changes: 27 additions & 0 deletions products/sales-agent/best-practices/app-deployment/aws.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
nav:
title: AWS
position: 20
---

# Deploy with AWS Amplify

In this chapter, you will learn how to deploy the frontend source code to [AWS Amplify](https://aws.amazon.com/amplify/).

## Prerequisites

- Register an AWS account.
- Clone the frontend source code and push it to your Git repository (for example, GitHub).

## Deploy

- Login to the AWS Amplify Hosting Console.
- Create a new app in AWS Amplify.
- Select and authorize access to your Git repository provider and select the main branch (it will auto-deploy when there are some changes in the main branch).
- Choose a name for your app and make sure build settings are auto-detected.
- Set Environment variables which are declared in `.env.template` under the Advanced Settings section.
- Confirm the configuration and click on "Save and Deploy".

## Custom domain

After deploying your code to AWS Amplify, you may wish to point custom domains (or subdomains) to your site. AWS has an [instruction](https://docs.aws.amazon.com/amplify/latest/userguide/custom-domains.html).
126 changes: 126 additions & 0 deletions products/sales-agent/best-practices/app-deployment/cloudflare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
---
nav:
title: Cloudflare
position: 30
---

# Deploy with Cloudflare

In this chapter you will learn how to deploy the frontend source code to [Cloudflare Pages](https://pages.cloudflare.com/).

## Prerequisites

- Register a Cloudflare account.
- Clone the frontend source code and push to your GitHub repository.

## Deploy from a local machine

- Due to this [issue](https://github.com/nuxt/nuxt/issues/28248), just make sure your `.npmrc` file has the following content:

```bash
shamefully-hoist=true
strict-peer-dependencies=false
```

- Install Wrangler

```bash
pnpm install wrangler --save-dev
```

- Make sure the Frontend app has already [generated an .env file](../../installation.md#create-a-env-file)
- Build your project for Cloudflare Pages:

```bash
npx nuxi build --preset=cloudflare_pages
```

- Then deploy. However, for the first time, it will ask you to create a project:

```bash
wrangler pages deploy dist/
```

## Automation with GitHub Actions

### Setup GitHub Secrets & variables

- In GitHub Secrets, add `CLOUDFLARE_API_TOKEN` with API token value.
- [Create an API token](https://developers.cloudflare.com/fundamentals/api/get-started/create-token/) in the Cloudflare dashboard with the "Cloudflare Pages — Edit" permission.
- In GitHub environment variables, create new environment named `production` and fill it with all environment variables in `.env.template`.
- Besides `production`, we can add new values for the same variable names in multiple environments such as `development`, `staging`.

### Setup pipeline

To trigger the deployment automatically, we can attach the GitHub Actions.

- Create a `.github/workflows/publish.yml` file in your repository with the below sample content.

Check warning on line 57 in products/sales-agent/best-practices/app-deployment/cloudflare.md

View workflow job for this annotation

GitHub Actions / LanguageTool

[LanguageTool] products/sales-agent/best-practices/app-deployment/cloudflare.md#L57

The official name of this software platform is spelled with a capital “H”. (GITHUB[1]) Suggestions: `GitHub` URL: https://en.wikipedia.org/wiki/GitHub Rule: https://community.languagetool.org/rule/show/GITHUB?lang=en-US&subId=1 Category: CASING
Raw output
products/sales-agent/best-practices/app-deployment/cloudflare.md:57:11: The official name of this software platform is spelled with a capital “H”. (GITHUB[1])
 Suggestions: `GitHub`
 URL: https://en.wikipedia.org/wiki/GitHub 
 Rule: https://community.languagetool.org/rule/show/GITHUB?lang=en-US&subId=1
 Category: CASING

::: warning
Please note that this pipeline is just a sample. There are some points need to update for a specific purpose
:::

```yml
on:
push:
# Specify the pipeline trigger
branches:
- main

jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
deployments: write
name: Cloudflare Pages Deployment
# Specify the environment name
environment: production
steps:
- name: Checkout
uses: actions/checkout@v3

- uses: pnpm/action-setup@v4
name: Install pnpm
with:
version: 8
run_install: false

- name: Install dependencies
run: |
pnpm install

- name: Build env file
run: |
touch .env
echo COMPANY_NAME=${{ vars.COMPANY_NAME }} >> .env
echo ORIGIN=${{ vars.ORIGIN }} >> .env

Check warning on line 97 in products/sales-agent/best-practices/app-deployment/cloudflare.md

View workflow job for this annotation

GitHub Actions / LanguageTool

[LanguageTool] products/sales-agent/best-practices/app-deployment/cloudflare.md#L97

If a new sentence starts here, add a space and start with an uppercase letter. (LC_AFTER_PERIOD[1]) Suggestions: ` ORIGIN` Rule: https://community.languagetool.org/rule/show/LC_AFTER_PERIOD?lang=en-US&subId=1 Category: CASING
Raw output
products/sales-agent/best-practices/app-deployment/cloudflare.md:97:29: If a new sentence starts here, add a space and start with an uppercase letter. (LC_AFTER_PERIOD[1])
 Suggestions: ` ORIGIN`
 Rule: https://community.languagetool.org/rule/show/LC_AFTER_PERIOD?lang=en-US&subId=1
 Category: CASING
echo REDIS_CACHE=${{ vars.REDIS_CACHE }} >> .env
echo REDIS_HOST=${{ vars.REDIS_HOST }} >> .env
echo REDIS_PORT=${{ vars.REDIS_PORT }} >> .env
echo REDIS_PASSWORD=${{ vars.REDIS_PASSWORD }} >> .env
echo REDIS_TLS=${{ vars.REDIS_TLS }} >> .env
echo APP_NAME=${{ vars.APP_NAME }} >> .env
echo APP_SECRET=${{ vars.APP_SECRET }} >> .env
echo DATABASE_URL=${{ vars.DATABASE_URL }} >> .env

- name: Build code
run: |
npx nuxi build --preset=cloudflare_pages

- name: Publish to Cloudflare Pages
uses: cloudflare/pages-action@v1.5.0
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: YOUR_ACCOUNT_ID
projectName: YOUR_PROJECT_NAME
directory: dist
wranglerVersion: "3"
```

- Replace `YOUR_ACCOUNT_ID` with your account ID. Get it from the dashboard URL. E.g: `https://dash.cloudflare.com/<ACCOUNT_ID>/pages`.
- Replace `YOUR_PROJECT_NAME` with the appropriate value.

## Custom domain

When deploying your Pages project, you may wish to point custom domains (or subdomains) to your site. Cloudflare has an [instruction](https://developers.cloudflare.com/pages/configuration/custom-domains/).
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
nav:
title: Ubuntu Server with PM2
position: 10
---

# Deploy with Ubuntu Server with PM2

This guide will walk you through the steps to deploy Sales Agent frontend web application to an Ubuntu server using [PM2](https://nuxt.com/docs/getting-started/deployment#pm2), a process manager for Node.js applications. PM2 will help you keep your app running in the background, restart it automatically when it crashes, and manage logs for easier troubleshooting.

## Prerequisites

- **Ubuntu Server**: This guide assumes you have an Ubuntu server running, and you can access it via SSH.
- **Node.js & npm**: Make sure Node.js and npm (Node package manager) are installed on your server.
- **PM2**: PM2 should be installed globally.

```bash
npm install -g pm2
```

- **pnpm**

```bash
npm install -g pnpm
```

- **Frontend Application**: Clone the frontend source code and push to your GitHub repository.

## Build code

- Please follow instructions here to [set up all necessary things and build the code](../../installation.md#setup-app-server)

## Start the Application with PM2

Now that your app is built, create a file named `ecosystem.config.cjs` in the root of your project with the following content. Ensure that the script path points to your app's build output directory (e.g., `.output/server/index.mjs` for Nuxt 3)

```js

Check warning on line 37 in products/sales-agent/best-practices/app-deployment/hosted-with-ubuntu-server.md

View workflow job for this annotation

GitHub Actions / LanguageTool

[LanguageTool] products/sales-agent/best-practices/app-deployment/hosted-with-ubuntu-server.md#L37

File types are normally capitalized. (FILE_EXTENSIONS_CASE[1]) Suggestions: `JS` URL: https://languagetool.org/insights/post/spelling-capital-letters/ Rule: https://community.languagetool.org/rule/show/FILE_EXTENSIONS_CASE?lang=en-US&subId=1 Category: CASING
Raw output
products/sales-agent/best-practices/app-deployment/hosted-with-ubuntu-server.md:37:3: File types are normally capitalized. (FILE_EXTENSIONS_CASE[1])
 Suggestions: `JS`
 URL: https://languagetool.org/insights/post/spelling-capital-letters/ 
 Rule: https://community.languagetool.org/rule/show/FILE_EXTENSIONS_CASE?lang=en-US&subId=1
 Category: CASING
module.exports = {
apps: [
{
name: "SalesAgentApp",
port: "3000",
exec_mode: "cluster",
instances: "max",
script: "./.output/server/index.mjs",
},
],
};
```

Once saved, you can start the app with:

```bash
pm2 start ecosystem.config.cjs
```
13 changes: 13 additions & 0 deletions products/sales-agent/best-practices/app-deployment/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
nav:
title: Frontend App Deployment
position: 10
---

# Frontend App Deployment

According to [Shopware Frontends deployment document](https://frontends.shopware.com/best-practices/deployment.html), all the templates which were generated by Shopware Frontends can be deployed in multiple ways, depending on the setup you are using. Most likely you will be using either a static hosting service or a server with a Node.js runtime.

You may find the different approaches as described in [Nuxt instruction](https://nuxt.com/deploy).

Alternatively, we will show some best practices of _Sales Agent_ frontend app deployment.
5 changes: 5 additions & 0 deletions products/sales-agent/best-practices/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
nav:
title: Best practices
position: 40
---
21 changes: 0 additions & 21 deletions products/sales-agent/deployment.md

This file was deleted.

27 changes: 16 additions & 11 deletions products/sales-agent/installation.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
---
nav:
title: Local installation
position: 20

title: Local installation
position: 20
---

# Local installation
Expand All @@ -11,9 +10,9 @@ nav:

Obtain all the credentials to connect to the following services:

* Database (MySQL).
- Database (MySQL).

* Cache layer (Redis).
- Cache layer (Redis).

## Setup App Server

Expand All @@ -26,7 +25,7 @@ cd swagsalesagent

### Create a `.env` File

* Use the provided `.env.template` file as an example.
- Use the provided `.env.template` file as an example.

```shell
cp .env.template .env
Expand All @@ -44,13 +43,13 @@ pnpm install --frozen-lockfile --prefer-offline

Choose one of the following commands based on your needs:

* Execute existing migrations without creating new files:
- Execute existing migrations without creating new files:

```bash
pnpm db:migration:deploy
```

* Execute & create new migration files if there are schema changes:
- Execute & create new migration files if there are schema changes:

```bash
pnpm db:migration:dev
Expand All @@ -62,16 +61,22 @@ Choose one of the following commands based on your needs:
pnpm dev
```

### Build code for Production

```shell
pnpm build
```

## Connect App to Shopware Instance

* Build zip
- Build zip

```bash
pnpm app:build
```

* Upload zip from `bundle/swagsalesagent.zip` into Shopware Extensions.
- Upload zip from `bundle/swagsalesagent.zip` into Shopware Extensions.

* Verify the Installed App: after installation, you should see the Sales Agent menu item appear in the Settings.
- Verify the Installed App: after installation, you should see the Sales Agent menu item appear in the Settings.

![ ](../../assets/sales-agent-item.png)