Skip to content

Commit

Permalink
Merge pull request #29 from appwrite/fix-build
Browse files Browse the repository at this point in the history
fix: build
  • Loading branch information
loks0n authored Jan 17, 2025
2 parents f80b310 + 9170e89 commit 9618f50
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 45 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -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
25 changes: 25 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -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
25 changes: 0 additions & 25 deletions .github/workflows/formatter.yml

This file was deleted.

8 changes: 4 additions & 4 deletions .github/workflows/linter.yml → .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
name: "Linter"
name: "Lint"

on:
pull_request:
push:
branches: [main]

jobs:
eslint:
name: "Eslint Check"
lint:
name: "Lint"
runs-on: ubuntu-latest
steps:
- name: Checkout code
Expand All @@ -21,5 +21,5 @@ jobs:
- name: Install dependencies
run: npm install

- name: Run ESLint
- name: Lint
run: npm run lint
28 changes: 15 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
# 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

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
Expand All @@ -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=''

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ services:
ports:
- 3003:3003
volumes:
- ./docs:/app/docs
- ./sources:/usr/src/app/sources
environment:
- _APP_ASSISTANT_OPENAI_API_KEY

0 comments on commit 9618f50

Please sign in to comment.