-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Dockerfile and build image flow (#567)
* Add Dockerfile * Make ibis version same as java engine * Add CI Install python dependencies in the CI * Make python dependencies install in the Docker If we install the dependencies in the CI, may cause platform issue * Use docker/build-push-action * Fix tag name * Add docker/metadata-action * Fix Dockerfile path * Fix context * Fix tag * Update README * Remove invalid default working-directory * Fix pyproject.toml path * Use step.working-directory * Use poetry version * Add empty line in the end of file * Edit title
- Loading branch information
1 parent
c251242
commit c278311
Showing
7 changed files
with
235 additions
and
16 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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 |
---|---|---|
|
@@ -8,7 +8,7 @@ on: | |
description: Specific version number (Optional). Default will be the current version plus 0.0.1. | ||
|
||
jobs: | ||
prepare-release: | ||
stable-release-wren-engine: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
@@ -62,3 +62,65 @@ jobs: | |
--tag ghcr.io/canner/wren-engine:latest \ | ||
--push -f ./Dockerfile \ | ||
--build-arg "WREN_VERSION=${WREN_VERSION}" . | ||
prepare-ibis-version: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
token: ${{ secrets.GHCR_TOKEN }} | ||
- name: Set up Git | ||
run: | | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "stable-release-bot" | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version-file: ./ibis-server/pyproject.toml | ||
- uses: abatilo/actions-poetry@v3 | ||
with: | ||
poetry-version: 1.7.1 | ||
- name: Prepare next version | ||
id: next_version | ||
working-directory: ibis-server | ||
run: | | ||
if [ -n "${{ github.event.inputs.specific_version }}" ]; then | ||
poetry version --next-phase ${{ github.event.inputs.specific_version }} | ||
else | ||
poetry version patch | ||
fi | ||
git add pyproject.toml | ||
git commit -m "Upgrade ibis version to $version" | ||
git push | ||
version=$(poetry version | awk '{print $2}') | ||
echo "value=$version" >> $GITHUB_OUTPUT | ||
outputs: | ||
next_version: ${{ steps.next_version.outputs.value }} | ||
stable-release-ibis: | ||
needs: prepare-ibis-version | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ghcr.io/canner/wren-engine-ibis | ||
tags: | | ||
type=raw,value=${{ needs.prepare-ibis-version.outputs.next_version }} | ||
type=raw,value=latest | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Build and push | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: ./ibis-server | ||
platforms: linux/amd64,linux/arm64 | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} |
This file contains 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 @@ | ||
FROM python:3.11-buster as builder | ||
|
||
# libpq-dev is required for psycopg2 | ||
RUN apt-get update && apt-get -y install libpq-dev | ||
|
||
# python | ||
ENV PYTHONUNBUFFERED=1 \ | ||
PYTHONDONTWRITEBYTECODE=1 \ | ||
# pip | ||
PIP_NO_CACHE_DIR=off \ | ||
PIP_DISABLE_PIP_VERSION_CHECK=on \ | ||
PIP_DEFAULT_TIMEOUT=100 \ | ||
# poetry | ||
POETRY_NO_INTERACTION=1 \ | ||
POETRY_VIRTUALENVS_IN_PROJECT=1 \ | ||
POETRY_VIRTUALENVS_CREATE=1 | ||
|
||
RUN pip install poetry==1.7.1 | ||
|
||
WORKDIR /app | ||
|
||
COPY pyproject.toml ./ | ||
|
||
RUN poetry install --without dev | ||
|
||
FROM python:3.11-slim-buster as runtime | ||
|
||
# libpq-dev is required for psycopg2 | ||
RUN apt-get update \ | ||
&& apt-get -y install libpq-dev \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
ENV VIRTUAL_ENV=/app/.venv \ | ||
PATH="/app/.venv/bin:$PATH" | ||
|
||
COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV} | ||
COPY app app | ||
|
||
EXPOSE 8000 | ||
|
||
ENTRYPOINT fastapi run |
This file contains 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
This file contains 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,16 +1,59 @@ | ||
# Ibis server | ||
|
||
## Environment Setup | ||
## Quick Start | ||
### Running on Docker | ||
Pull the image from the GitHub Container Registry | ||
```bash | ||
docker pull ghcr.io/canner/wren-engine-ibis:latest | ||
``` | ||
Create `.env` file and fill in the environment variables (see [Environment Variables](#Environment-Variables)) \ | ||
```bash | ||
vim .env | ||
``` | ||
Run the container | ||
```bash | ||
docker run --env-file .env -p 8000:8000 ghcr.io/canner/wren-engine-ibis:latest | ||
``` | ||
### Running on Local | ||
Requirements: | ||
- Python 3.11 | ||
- [poetry](https://github.com/python-poetry/poetry) 1.7.1 | ||
|
||
Clone the repository and navigate to the ibis directory | ||
```bash | ||
git clone [email protected]:Canner/wren-engine.git | ||
cd ibis-server | ||
``` | ||
Create `.env` file and fill in the environment variables (see [Environment Variables](#Environment-Variables)) | ||
```bash | ||
vim .env | ||
``` | ||
Install the dependencies | ||
```bash | ||
make install | ||
``` | ||
Run the server | ||
```bash | ||
make run | ||
``` | ||
|
||
## Developer Guide | ||
|
||
### Environment Setup | ||
- Python 3.11 | ||
- Install `poetry` with version 1.7.1: `curl -sSL https://install.python-poetry.org | python3 - --version 1.7.1` | ||
- Execute `make install` to install the dependencies | ||
- Execute `make test` to run the tests | ||
- Create `.env` file and fill in the environment variables | ||
|
||
## Environment Variables | ||
### Environment Variables | ||
- `WREN_ENGINE_ENDPOINT`: The endpoint of the Wren engine | ||
|
||
## Start the server | ||
### Start the server | ||
- Execute `make run` to start the server | ||
- Execute `make dev` to start the server in development mode. It will auto-reload after the code is edited. | ||
- Default port is `8000`, you can change it by `make run PORT=8001` or `make dev PORT=8001` | ||
|
||
### Docker | ||
- Build the image: `make docker-build` | ||
- Run the container: `make docker-run` |
This file contains 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,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "ibis-server" | ||
version = "0.1.0" | ||
version = "0.4.5" | ||
description = "" | ||
authors = ["Canner <[email protected]>"] | ||
readme = "README.md" | ||
|
@@ -15,7 +15,7 @@ ibis-framework = {extras = ["bigquery", "postgres", "snowflake"], version = "9.0 | |
google-auth = "2.29.0" | ||
httpx = "0.27.0" | ||
python-dotenv = "1.0.1" | ||
orjson = "2.0.1" | ||
orjson = "3.10.3" | ||
|
||
[tool.poetry.group.dev.dependencies] | ||
pytest = "8.2.0" | ||
|