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/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 0000000..3d88e2d --- /dev/null +++ b/.github/workflows/format.yml @@ -0,0 +1,25 @@ +name: "Format" + +on: + pull_request: + push: + branches: [main] + +jobs: + format: + name: "Format" + 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: Format + 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 82% rename from .github/workflows/linter.yml rename to .github/workflows/lint.yml index b369dd0..9ef2d25 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: "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 956417f..ddf2003 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,9 @@ -# 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 \ + make \ + g++ \ build-base \ git @@ -11,14 +11,16 @@ ENV PNPM_HOME="/pnpm" ENV PATH="$PNPM_HOME:$PATH" RUN corepack enable +FROM base AS builder + +COPY package.json pnpm-lock.yaml /usr/src/app/ WORKDIR /usr/src/app -COPY package.json ./ -COPY pnpm-lock.yaml ./ +RUN pnpm fetch --prod -RUN pnpm --prod install +COPY . /usr/src/app -COPY . . +RUN pnpm install ARG _BUILD_GIT_URL ARG _BUILD_GIT_BRANCH @@ -32,14 +34,14 @@ 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/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='' 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 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