-
Notifications
You must be signed in to change notification settings - Fork 41
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
Add Dockerfile and build image flow #567
Changes from 16 commits
0bbabc5
71b77e7
18a0750
9c92ea7
822b242
7fff6a6
59ecc1b
6c9f8be
7b8a6b2
55a33d0
639b7e3
2ddf7d1
003da24
34eed7e
4bbbda0
a885481
88081c2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 }} |
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 |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -13,3 +13,9 @@ dev: | |||||
|
||||||
test: | ||||||
poetry run pytest | ||||||
|
||||||
docker-build: | ||||||
docker image build . -t wren-engine-ibis | ||||||
|
||||||
docker-run: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
How about add a |
||||||
docker run -it --rm -p 8000:8000 --env-file .env wren-engine-ibis |
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 | ||||||
``` | ||||||
|
||||||
## Contributing | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
It's a kind of guide to show how start a development environment for developers. |
||||||
|
||||||
### 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` |
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" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First time to know this action to put the image tags. it's really concise!