Skip to content

Commit 45f064a

Browse files
committed
feat: add packages and skip notices
1 parent 5521762 commit 45f064a

File tree

4 files changed

+55
-123
lines changed

4 files changed

+55
-123
lines changed

.github/workflows/packages.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Update workshop packages
2+
on:
3+
push:
4+
branches:
5+
- main
6+
7+
jobs:
8+
update_packages:
9+
name: Update
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v3
16+
- name: Create packages
17+
run: ./scripts/create-packages.sh
18+
- name: Update release
19+
uses: ncipollo/[email protected]
20+
with:
21+
name: Workshop packages
22+
tag: latest
23+
artifacts: "dist/*.tar.gz"
24+
allowUpdates: true
25+
removeArtifacts: true

docs/workshop.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,6 +1087,12 @@ After that, commit the changes to the repository to keep track of your progress.
10871087

10881088
---
10891089

1090+
<div class="info" data-title="Skip notice">
1091+
1092+
> If you want to skip the Chat website implementation and jump directly to the next section, run this command in the terminal at the root of the project to get the completed code directly: curl -fsSL https://github.com/Azure-Samples/azure-openai-rag-workshop/releases/download/latest/frontend.tar.gz | tar -xvz
1093+
1094+
<div>
1095+
10901096
## Chat website
10911097

10921098
### Intro

scripts/repo/create-github-template.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ echo "Preparing GitHub project template..."
1717
echo "(temp folder: $TEMPLATE_HOME)"
1818
rm -rf "$TEMPLATE_HOME"
1919
mkdir -p "$TEMPLATE_HOME"
20-
find . -type d -not -path '*node_modules*' -not -path '*.git/*' -not -path '*dist*' -exec mkdir -p '{}' "$TEMPLATE_HOME/{}" ';'
21-
find . -type f -not -path '*node_modules*' -not -path '*.git/*' -not -path '*dist*' -exec cp -r '{}' "$TEMPLATE_HOME/{}" ';'
20+
find . -type d -not -path '*node_modules*' -not -path '*.git/*' -not -path '*/dist' -not -path '*dist/*' -exec mkdir -p '{}' "$TEMPLATE_HOME/{}" ';'
21+
find . -type f -not -path '*node_modules*' -not -path '*.git/*' -not -path '*dist/*' -exec cp -r '{}' "$TEMPLATE_HOME/{}" ';'
2222
cd "$TEMPLATE_HOME"
2323
rm -rf .git
2424
git init -b main

scripts/repo/create-packages.sh

Lines changed: 22 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
##############################################################################
66

77
set -euo pipefail
8-
cd "$(dirname "${BASH_SOURCE[0]}")/.."
8+
cd "$(dirname "${BASH_SOURCE[0]}")/../.."
99

1010
target_folder=dist
1111

@@ -44,142 +44,43 @@ makeArchive() {
4444

4545
echo "Creating solution package..."
4646
copyFolder . solution
47+
rm -rf "$target_folder/solution/.azure"
48+
rm -rf "$target_folder/solution/.env"
4749
rm -rf "$target_folder/solution/docs"
48-
rm -rf "$target_folder/solution/scripts"
49-
rm -rf "$target_folder/solution/.github/workflows/packages.yml"
50-
rm -rf "$target_folder/solution/.github/workflows/template.yml"
50+
rm -rf "$target_folder/solution/trainer"
51+
rm -rf "$target_folder/solution/scripts/repo"
52+
rm -rf "$target_folder/solution/.github"
5153
rm -rf "$target_folder/solution/TODO"
5254
rm -rf "$target_folder/solution/SUPPORT.md"
5355
rm -rf "$target_folder/solution/CODE_OF_CONDUCT.md"
5456
rm -rf "$target_folder/solution/SECURITY.md"
5557
makeArchive . solution solution
5658

5759
##############################################################################
58-
# Settings API, without database implementation
60+
# Backend Dockerfile
5961
##############################################################################
6062

61-
echo "Creating settings-api package..."
62-
copyFolder packages/settings-api
63-
perl -i -pe "s/^.*azure\/cosmos.*?\n//" "$target_folder/packages/settings-api/package.json"
64-
65-
echo -e "import fp from 'fastify-plugin'
66-
67-
// the use of fastify-plugin is required to be able
68-
// to export the decorators to the outer scope
69-
70-
export default fp(async function (fastify, opts) {
71-
fastify.decorate('db', new MockDatabase());
72-
});
73-
74-
class MockDatabase {
75-
constructor() {
76-
this.db = {};
77-
}
78-
79-
async saveSettings(userId, settings) {
80-
await this.#delay();
81-
this.db[userId] = settings;
82-
}
83-
84-
async getSettings(userId) {
85-
await this.#delay();
86-
return this.db[userId];
87-
}
88-
89-
async #delay() {
90-
return new Promise(resolve => setTimeout(resolve, 10));
91-
}
92-
}
93-
" > "$target_folder/packages/settings-api/plugins/database.js"
94-
95-
makeArchive packages settings-api
96-
97-
##############################################################################
98-
# Dice API, without database implementation
99-
##############################################################################
100-
101-
echo "Creating dice-api package..."
102-
copyFolder packages/dice-api
103-
perl -i -pe "s/^.*azure\/cosmos.*?\n//" "$target_folder/packages/dice-api/package.json"
104-
105-
echo -e "import { Injectable } from '@nestjs/common';
106-
107-
export interface Roll {
108-
sides: number;
109-
result: number;
110-
timestamp: number;
111-
}
112-
113-
@Injectable()
114-
export class DbService {
115-
private mockDb: Roll[] = [];
116-
117-
async addRoll(roll: Roll) {
118-
await this.delay();
119-
this.mockDb.push(roll);
120-
this.mockDb.sort((a, b) => a.timestamp - b.timestamp);
121-
}
122-
123-
async getLastRolls(max: number, sides: number) {
124-
await this.delay();
125-
return this.mockDb.filter((roll) => roll.sides === sides).slice(-max);
126-
}
127-
128-
private async delay() {
129-
return new Promise((resolve) => setTimeout(resolve, 10));
130-
}
131-
}
132-
" > "$target_folder/packages/dice-api/src/db.service.ts"
133-
134-
echo -e "import { Module } from '@nestjs/common';
135-
import { LoggerModule } from 'nestjs-pino';
136-
import { AppController } from './app.controller';
137-
import { AppService } from './app.service';
138-
import { DbService } from './db.service';
139-
import { RollsController } from './rolls.controller';
140-
141-
@Module({
142-
imports: [LoggerModule.forRoot()],
143-
controllers: [AppController, RollsController],
144-
providers: [AppService, DbService],
145-
})
146-
export class AppModule {}
147-
" > "$target_folder/packages/dice-api/src/app.module.ts"
148-
149-
makeArchive packages dice-api
150-
151-
##############################################################################
152-
# Gateway API
153-
##############################################################################
154-
155-
echo "Creating gateway-api package..."
156-
copyFolder packages/gateway-api
157-
makeArchive packages gateway-api
158-
159-
##############################################################################
160-
# Website
161-
##############################################################################
162-
163-
echo "Creating website package..."
164-
copyFolder packages/website
165-
makeArchive packages website
63+
echo "Creating backend-dockerfile package..."
64+
mkdir -p "$target_folder/src/backend"
65+
cp -R src/backend/Dockerfile "$target_folder/src/backend/Dockerfile"
66+
makeArchive src backend-dockerfile
16667

16768
##############################################################################
168-
# docker-compose.yml
69+
# Frontend
16970
##############################################################################
17071

171-
echo "Creating docker-compose package..."
172-
cp docker-compose.yml "$target_folder/docker-compose.yml"
173-
makeArchive docker-compose.yml docker-compose
72+
echo "Creating frontend package..."
73+
copyFolder src/frontend
74+
makeArchive src frontend
17475

17576
##############################################################################
17677
# Deployment
17778
##############################################################################
17879

179-
echo "Creating deploy package..."
180-
mkdir -p "$target_folder/deploy/.github/workflows"
181-
mkdir -p "$target_folder/deploy/.azure"
182-
cp .github/workflows/deploy.yml "$target_folder/deploy/.github/workflows/deploy.yml"
183-
cp .azure/build.sh "$target_folder/deploy/.azure/build.sh"
184-
cp .azure/deploy.sh "$target_folder/deploy/.azure/deploy.sh"
185-
makeArchive . deploy deploy
80+
# echo "Creating deploy package..."
81+
# mkdir -p "$target_folder/deploy/.github/workflows"
82+
# mkdir -p "$target_folder/deploy/.azure"
83+
# cp .github/workflows/deploy.yml "$target_folder/deploy/.github/workflows/deploy.yml"
84+
# cp .azure/build.sh "$target_folder/deploy/.azure/build.sh"
85+
# cp .azure/deploy.sh "$target_folder/deploy/.azure/deploy.sh"
86+
# makeArchive . deploy deploy

0 commit comments

Comments
 (0)