-
Notifications
You must be signed in to change notification settings - Fork 1
Feat: DB proxy #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
353a2e7
Implement DB proxy
Meldiron 2a8fb48
linter fix
Meldiron 1fb9ad2
Remove leftover
Meldiron 767361d
Add tests, address PR comments
Meldiron 496ff76
Rename endpoints, add pool
Meldiron 9a64f76
Remove memory limit
Meldiron bd8c0c2
Improve tests
Meldiron 3146380
More auth roles tests
Meldiron 02a45e6
PR review changes
Meldiron eeedcfc
PR review changes
Meldiron 2b56bf9
Remove unnessessary endpoints
Meldiron 2f54840
getDocument queries as string
fogelito c0cd587
Merge remote-tracking branch 'origin/dev' into dev
fogelito 6fa0086
json_encode queries
fogelito 0caa0a1
json_encode queries
fogelito 6fb801b
json_encode queries
fogelito 9a28cf2
Count endpoints.php
fogelito adcd7d3
Error exceptions
fogelito df736a6
No reference
fogelito 43cc75c
Build command
fogelito 9f76dee
composer.lock
fogelito 0477586
PR review changes
Meldiron 9755039
Fix failinig tests
Meldiron a8ae3a3
Changes after HTTP and Auth refactor
Meldiron c8adf31
Rename to data API
Meldiron b12bc38
Update readme
Meldiron 4ea8dc1
Rework to have 1 endpoint only
Meldiron 6aa2492
Fix CI/CD tests
Meldiron c42c4ae
Fix document convertion
Meldiron b44c0e9
Add support for Query
Meldiron a369456
WIP: Update to raw queries
Meldiron 44a8f0b
Fix timeouts and serialize params
Meldiron 8b194dc
Fix code quality
Meldiron File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| UTOPIA_DATA_API_ENV=development | ||
| UTOPIA_DATA_API_SECRET=proxy-secret-key | ||
| UTOPIA_DATA_API_SECRET_CONNECTION=mariadb://root:password@mariadb:3306/appwrite?pool_size=256 | ||
| UTOPIA_DATA_API_LOGGING_PROVIDER= | ||
| UTOPIA_DATA_API_LOGGING_CONFIG= |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| name: "CodeQL" | ||
|
|
||
| on: [pull_request] | ||
| jobs: | ||
| lint: | ||
| name: CodeQL | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Check out the repo | ||
| uses: actions/checkout@v2 | ||
|
|
||
| - name: Run CodeQL | ||
| run: | | ||
| docker run --rm -v $PWD:/app composer sh -c \ | ||
| "composer install --profile --ignore-platform-reqs && composer check" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| name: "Linter" | ||
|
|
||
| on: [pull_request] | ||
| jobs: | ||
| lint: | ||
| name: Linter | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Check out the repo | ||
| uses: actions/checkout@v2 | ||
|
|
||
| - name: Run Linter | ||
| run: | | ||
| docker run --rm -v $PWD:/app composer sh -c \ | ||
| "composer install --profile --ignore-platform-reqs && composer lint" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| name: "Release" | ||
|
|
||
| on: | ||
| release: | ||
| types: [published] | ||
|
|
||
| env: | ||
| IMAGE_NAME: utopia-php/database-proxy | ||
| TAG: ${{ github.event.release.tag_name }} | ||
| USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} | ||
| PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Check out the repo | ||
| uses: actions/checkout@v2 | ||
|
|
||
| - name: Set up QEMU | ||
| uses: docker/setup-qemu-action@v2 | ||
|
|
||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v2 | ||
|
|
||
| - name: Login to DockerHub | ||
| uses: docker/login-action@v2 | ||
| with: | ||
| registry: ${{ env.REGISTRY }} | ||
| username: ${{ env.USERNAME }} | ||
| password: ${{ env.PASSWORD }} | ||
|
|
||
| - name: Build and push | ||
| uses: docker/build-push-action@v4 | ||
| with: | ||
| build-args: | | ||
| UTOPIA_DATA_API_VERSION=${{ env.TAG }} | ||
| platforms: linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7 | ||
| context: . | ||
| push: true | ||
| tags: ${{ env.IMAGE_NAME }}:latest,${{ env.IMAGE_NAME }}:${{ env.TAG }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| name: "Tests" | ||
|
|
||
| on: [pull_request] | ||
| jobs: | ||
| tests: | ||
| name: Tests | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Check out the repo | ||
| uses: actions/checkout@v2 | ||
|
|
||
| - name: Start Test Stack | ||
| run: | | ||
| export COMPOSE_INTERACTIVE_NO_CLI | ||
| export DOCKER_BUILDKIT=1 | ||
| export COMPOSE_DOCKER_CLI_BUILD=1 | ||
| export BUILDKIT_PROGRESS=plain | ||
| docker pull composer:2.0 | ||
| docker compose build | ||
| docker compose up -d | ||
| sleep 60 | ||
|
|
||
| - name: Doctor | ||
| run: | | ||
| docker compose logs | ||
| docker ps | ||
| docker network ls | ||
|
|
||
| - name: Run Tests | ||
| run: | | ||
| docker run --rm -v $PWD:/app --network data-api_database -w /app phpswoole/swoole:4.8.12-php8.1-alpine sh -c \ | ||
| "composer install --profile --ignore-platform-reqs && composer test" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| /vendor/ | ||
| /.idea/ | ||
| .phpunit.cache |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {"version":1,"defects":{"Tests\\ProxyTest::testSecret":8,"Tests\\ProxyTest::testDefaultDatabase":7,"Tests\\ProxyTest::testNamespace":7,"Tests\\ProxyTest::testTimeout":7,"Tests\\ProxyTest::testAuth":7,"Tests\\ProxyTest::testMock":8,"Tests\\ProxyTest::testPing":7,"Tests\\ProxyTest::testExists":7},"times":{"Tests\\ProxyTest::testSecret":0.005,"Tests\\ProxyTest::testDefaultDatabase":0.009,"Tests\\ProxyTest::testNamespace":0.018,"Tests\\ProxyTest::testTimeout":0.005,"Tests\\ProxyTest::testAuth":0.056,"Tests\\ProxyTest::testMock":0.043,"Tests\\ProxyTest::testPing":0.003,"Tests\\ProxyTest::testExists":0.022}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| # Install PHP libraries | ||
| FROM composer:2.0 as composer | ||
|
|
||
| WORKDIR /usr/local/src/ | ||
|
|
||
| COPY composer.lock /usr/local/src/ | ||
| COPY composer.json /usr/local/src/ | ||
|
|
||
| RUN composer install --ignore-platform-reqs --optimize-autoloader \ | ||
| --no-plugins --no-scripts --prefer-dist | ||
|
|
||
| # Prepare generic compiler | ||
| FROM php:8.1.25-cli-alpine3.16 as compile | ||
|
|
||
| ENV PHP_SWOOLE_VERSION="v5.1.0" \ | ||
| PHP_MONGODB_VERSION="1.16.1" | ||
|
|
||
| RUN \ | ||
| apk add --no-cache --virtual .deps \ | ||
| make \ | ||
| automake \ | ||
| autoconf \ | ||
| gcc \ | ||
| g++ \ | ||
| git \ | ||
| openssl-dev | ||
|
|
||
| RUN docker-php-ext-install sockets | ||
|
|
||
| # Compile Swoole | ||
| FROM compile AS swoole | ||
|
|
||
| RUN \ | ||
| git clone --depth 1 --branch $PHP_SWOOLE_VERSION https://github.com/swoole/swoole-src.git && \ | ||
| cd swoole-src && \ | ||
| phpize && \ | ||
| ./configure --enable-sockets --enable-http2 --enable-openssl && \ | ||
| make && make install && \ | ||
| cd .. | ||
|
|
||
| # Mongodb Extension | ||
| FROM compile as mongodb | ||
| RUN \ | ||
| git clone --depth 1 --branch $PHP_MONGODB_VERSION https://github.com/mongodb/mongo-php-driver.git && \ | ||
| cd mongo-php-driver && \ | ||
| git submodule update --init && \ | ||
| phpize && \ | ||
| ./configure && \ | ||
| make && make install | ||
|
|
||
| # Proxy | ||
| FROM php:8.1.25-cli-alpine3.16 as final | ||
|
|
||
| ARG UTOPIA_DATA_API_VERSION | ||
| ENV UTOPIA_DATA_API_VERSION=$UTOPIA_DATA_API_VERSION | ||
|
|
||
| LABEL maintainer="team@appwrite.io" | ||
|
|
||
| RUN \ | ||
| apk update \ | ||
| && apk add --no-cache --virtual .deps \ | ||
| make \ | ||
| automake \ | ||
| autoconf \ | ||
| gcc \ | ||
| g++ \ | ||
| curl-dev \ | ||
| && apk add --no-cache \ | ||
| libstdc++ \ | ||
| postgresql-dev \ | ||
| && docker-php-ext-install sockets pdo_mysql pdo_pgsql \ | ||
| && apk del .deps \ | ||
| && rm -rf /var/cache/apk/* | ||
|
|
||
| WORKDIR /usr/local/ | ||
|
|
||
| # Source code | ||
| COPY ./app /usr/local/app | ||
|
|
||
| # Extensions and libraries | ||
| COPY --from=composer /usr/local/src/vendor /usr/local/vendor | ||
| COPY --from=swoole /usr/local/lib/php/extensions/no-debug-non-zts-20210902/swoole.so /usr/local/lib/php/extensions/no-debug-non-zts-20210902/ | ||
| COPY --from=mongodb /usr/local/lib/php/extensions/no-debug-non-zts-20210902/mongodb.so /usr/local/lib/php/extensions/no-debug-non-zts-20210902/ | ||
|
|
||
| RUN echo extension=swoole.so >> /usr/local/etc/php/conf.d/swoole.ini | ||
|
|
||
| EXPOSE 80 | ||
|
|
||
| CMD [ "php", "app/http.php" ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,4 @@ | ||
| # Utopia PHP Database Proxy | ||
| # Utopia PHP Data API | ||
|
|
||
| Build: | ||
| docker build -t data-api . |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.