From eab7011b89d5784d3a9391aa5dfcc934803596ac Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Fri, 17 Jan 2025 17:09:06 +0000 Subject: [PATCH 1/7] fix: build --- .github/workflows/build.yml | 43 +++++++++++++++++++++++++++++++++++++ Dockerfile | 32 +++++++++++++-------------- README.md | 4 ++-- 3 files changed, 61 insertions(+), 18 deletions(-) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..66e5802 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,43 @@ +name: "Build" + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + build: + name: Build + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: appwrite/assistant + tags: type=sha,prefix=pr- + + - name: Build image + uses: docker/build-push-action@v5 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: false # Don't push, just build to verify + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + _BUILD_WEBSITE_URL=https://appwrite.io + _BUILD_WEBSITE_VERSION=1.6.x + _BUILD_GIT_URL=https://github.com/appwrite/website.git + _BUILD_GIT_BRANCH=main \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 956417f..85f010b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,24 +1,25 @@ -# Stage 1: Build -FROM node:18-alpine AS build +FROM node:18-alpine AS base -RUN apk update && apk add --no-cache \ +RUN apk add --no-cache \ python3 \ - py3-pip \ - build-base \ - git + make \ + g++ \ + build-base ENV PNPM_HOME="/pnpm" ENV PATH="$PNPM_HOME:$PATH" RUN corepack enable -WORKDIR /usr/src/app +FROM base AS builder + +COPY package.json pnpm-lock.yaml /app/ +WORKDIR /app -COPY package.json ./ -COPY pnpm-lock.yaml ./ +RUN pnpm fetch --prod -RUN pnpm --prod install +COPY . /app -COPY . . +RUN pnpm install ARG _BUILD_GIT_URL ARG _BUILD_GIT_BRANCH @@ -32,14 +33,13 @@ ENV _BUILD_WEBSITE_VERSION=${_BUILD_WEBSITE_VERSION} RUN pnpm run fetch-sources -# Stage 2: Runtime -FROM node:18-alpine AS runtime +FROM base WORKDIR /usr/src/app -COPY --from=build /usr/src/app . - -RUN rm -rf /usr/src/app/node_modules/.cache +COPY --from=builder /usr/src/app/node_modules /usr/src/app/node_modules +COPY --from=builder /usr/src/app/index /usr/src/app/index +COPY --from=builder /usr/src/app/package.json /usr/src/app/ ENV _APP_ASSISTANT_OPENAI_API_KEY='' diff --git a/README.md b/README.md index 846d309..4eab641 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ If you want to pull from a different branch or repository, you can set the `_BUI First, retrieve an API key from OpenAI. You can sign up for an API key at [OpenAI](https://beta.openai.com/signup/). Once you have an API key, set it as the `_APP_ASSISTANT_OPENAI_API_KEY` environment variable. -To run the server, execute the `dev` command. By default, the server will be available at `http://localhost:3000` +To run the server, execute the `dev` command. By default, the server will be available at `http://localhost:3003` ```bash pnpm run dev @@ -41,7 +41,7 @@ The server exposes a POST endpoint at `/`. The endpoint expects a raw text body Use cURL to test the server, for example: ```bash -curl -X POST -H "Content-Type: application/json" -d "{\"prompt\": \"How do I create a new user?\"}" http://localhost:3000/v1/models/assistant/prompt +curl -X POST -H "Content-Type: application/json" -d "{\"prompt\": \"How do I create a new user?\"}" http://localhost:3003/v1/models/assistant/prompt ``` ## Contributing From 62b8ad9c15e9d4bf1134a095f40e949e998dec51 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Fri, 17 Jan 2025 17:12:16 +0000 Subject: [PATCH 2/7] refactor: actions --- .github/workflows/format.yml | 25 ++++++++++++++++++++++ .github/workflows/formatter.yml | 25 ---------------------- .github/workflows/{linter.yml => lint.yml} | 6 +++--- 3 files changed, 28 insertions(+), 28 deletions(-) create mode 100644 .github/workflows/format.yml delete mode 100644 .github/workflows/formatter.yml rename .github/workflows/{linter.yml => lint.yml} (88%) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 0000000..914ff8e --- /dev/null +++ b/.github/workflows/format.yml @@ -0,0 +1,25 @@ +name: "Format" + +on: + pull_request: + push: + branches: [main] + +jobs: + format: + name: "Run ESLint" + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Node.js + uses: actions/setup-node@v2 + with: + node-version: '18' + + - name: Install dependencies + run: npm install + + - name: Run Prettier + run: npm run format \ No newline at end of file diff --git a/.github/workflows/formatter.yml b/.github/workflows/formatter.yml deleted file mode 100644 index 833d332..0000000 --- a/.github/workflows/formatter.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: "Formatter" - -on: - pull_request: - push: - branches: [main] - -jobs: - prettier: - name: Prettier Check - runs-on: ubuntu-latest - steps: - - name: Checkout Repository - uses: actions/checkout@v2 - - - name: Run Prettier - id: prettier-run - uses: rutajdash/prettier-cli-action@v1.0.0 - - - name: Prettier Output - if: ${{ failure() }} - shell: bash - run: | - echo "The following files are not formatted:" - echo "${{steps.prettier-run.outputs.prettier_output}}" \ No newline at end of file diff --git a/.github/workflows/linter.yml b/.github/workflows/lint.yml similarity index 88% rename from .github/workflows/linter.yml rename to .github/workflows/lint.yml index b369dd0..fde3ecf 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/lint.yml @@ -1,4 +1,4 @@ -name: "Linter" +name: "Lint" on: pull_request: @@ -6,8 +6,8 @@ on: branches: [main] jobs: - eslint: - name: "Eslint Check" + lint: + name: "Run ESLint" runs-on: ubuntu-latest steps: - name: Checkout code From 4fd4ec514fc834edc521e783a09992ab2b9fbe08 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Fri, 17 Jan 2025 17:13:45 +0000 Subject: [PATCH 3/7] fix: add git --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 85f010b..e243811 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,8 @@ RUN apk add --no-cache \ python3 \ make \ g++ \ - build-base + build-base \ + git ENV PNPM_HOME="/pnpm" ENV PATH="$PNPM_HOME:$PATH" From cf8c0adfb656d1e4a3de87712c951dac193b7395 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Fri, 17 Jan 2025 17:19:50 +0000 Subject: [PATCH 4/7] fix: build --- .github/workflows/format.yml | 4 ++-- .github/workflows/lint.yml | 4 ++-- Dockerfile | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 914ff8e..3d88e2d 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -7,7 +7,7 @@ on: jobs: format: - name: "Run ESLint" + name: "Format" runs-on: ubuntu-latest steps: - name: Checkout code @@ -21,5 +21,5 @@ jobs: - name: Install dependencies run: npm install - - name: Run Prettier + - name: Format run: npm run format \ No newline at end of file diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index fde3ecf..9ef2d25 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -7,7 +7,7 @@ on: jobs: lint: - name: "Run ESLint" + name: "Lint" runs-on: ubuntu-latest steps: - name: Checkout code @@ -21,5 +21,5 @@ jobs: - name: Install dependencies run: npm install - - name: Run ESLint + - name: Lint run: npm run lint \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index e243811..8dc83c6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,12 +13,12 @@ RUN corepack enable FROM base AS builder -COPY package.json pnpm-lock.yaml /app/ -WORKDIR /app +COPY package.json pnpm-lock.yaml /usr/src/app/ +WORKDIR /usr/src/app RUN pnpm fetch --prod -COPY . /app +COPY . /usr/src/app RUN pnpm install From ad2422c93da06f9f254606bc644555ada594472f Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Fri, 17 Jan 2025 17:22:59 +0000 Subject: [PATCH 5/7] fix: build --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 8dc83c6..5f7466f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -39,7 +39,7 @@ FROM base WORKDIR /usr/src/app COPY --from=builder /usr/src/app/node_modules /usr/src/app/node_modules -COPY --from=builder /usr/src/app/index /usr/src/app/index +COPY --from=builder /usr/src/app/sources /usr/src/app/sources COPY --from=builder /usr/src/app/package.json /usr/src/app/ ENV _APP_ASSISTANT_OPENAI_API_KEY='' From 27dbd22b72cfa1e7596072286973e5d99951545e Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Fri, 17 Jan 2025 17:36:17 +0000 Subject: [PATCH 6/7] fix: docker compose --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 0cf336c..5f6ec83 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,6 +4,6 @@ services: ports: - 3003:3003 volumes: - - ./docs:/app/docs + - ./sources:/usr/src/app/sources environment: - _APP_ASSISTANT_OPENAI_API_KEY From 9170e89da7a4262ea6aa1208dc9db984cfb2bf98 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Fri, 17 Jan 2025 17:38:41 +0000 Subject: [PATCH 7/7] fix: build --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 5f7466f..ddf2003 100644 --- a/Dockerfile +++ b/Dockerfile @@ -41,6 +41,7 @@ WORKDIR /usr/src/app COPY --from=builder /usr/src/app/node_modules /usr/src/app/node_modules COPY --from=builder /usr/src/app/sources /usr/src/app/sources COPY --from=builder /usr/src/app/package.json /usr/src/app/ +COPY --from=builder /usr/src/app/src /usr/src/app/src ENV _APP_ASSISTANT_OPENAI_API_KEY=''