-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from xiaoyao9184/main
support docker image
- Loading branch information
Showing
14 changed files
with
431 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
.git/ | ||
.github/ | ||
.vscode/ | ||
assets/ | ||
benchmark/ | ||
cache/ | ||
docker/ | ||
docs/ | ||
dist/ | ||
logs/ | ||
mirrors_dir/ | ||
olah.egg-info/ | ||
playground/ | ||
scripts/ | ||
tests/ | ||
repos/ | ||
.dockerignore | ||
.gitignore | ||
environment.yml |
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,86 @@ | ||
|
||
name: Docker Image Build/Publish tag with commit | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'dev' | ||
paths: | ||
- docker/build@source/dockerfile | ||
- .github/workflows/docker-image-tag-commit.yml | ||
workflow_dispatch: | ||
inputs: | ||
commit_id: | ||
description: olah commit id(like 'main' 'db028a3b') | ||
required: true | ||
default: main | ||
|
||
jobs: | ||
build-and-push-docker-image: | ||
name: Build Docker image and push to repositories | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
BRANCH_CHECKOUT: | ||
- ${{ github.event.inputs.commit_id || 'main' }} | ||
platforms: | ||
- linux/amd64,linux/arm64 | ||
|
||
steps: | ||
- name: Checkout code | ||
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: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Checkout commit | ||
run: | | ||
git checkout ${{ matrix.BRANCH_CHECKOUT }} | ||
- name: Set env git short head | ||
working-directory: ./olah | ||
run: echo "COMMIT_SHORT=$(git rev-parse --short HEAD)" >> $GITHUB_ENV | ||
|
||
- name: Meta data image | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: | | ||
${{ secrets.DOCKERHUB_USERNAME }}/olah | ||
ghcr.io/${{ github.repository_owner }}/olah | ||
tags: | | ||
type=raw,value=${{ matrix.BRANCH_CHECKOUT }} | ||
type=raw,value=${{ env.COMMIT_SHORT }} | ||
flavor: | | ||
latest=false | ||
- name: Build push image | ||
id: build | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
file: ./docker/build@source/dockerfile | ||
platforms: ${{ matrix.platforms }} | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
|
||
- name: Print image digest | ||
run: echo ${{ steps.build.outputs.digest }} |
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,100 @@ | ||
|
||
name: Docker Image Build/Publish tag with version | ||
|
||
on: | ||
push: | ||
tags: | ||
- "v*" | ||
branches: | ||
- 'main' | ||
paths: | ||
- docker/build@pypi/dockerfile | ||
- .github/workflows/docker-image-tag-version.yml | ||
workflow_dispatch: | ||
inputs: | ||
olah_version: | ||
description: olah version of pypi | ||
required: true | ||
default: 0.3.3 | ||
|
||
jobs: | ||
build-and-push-docker-image: | ||
name: Build Docker image and push to repositories | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
platform: | ||
- linux/amd64,linux/arm64 | ||
|
||
steps: | ||
- name: Set OLAH_SOURCE/OLAH_TAG variable for push or workflow_dispatch | ||
id: set_olah_source | ||
run: | | ||
if [[ "${{ github.event_name }}" == "push" ]]; then | ||
if [[ "${{ github.ref }}" == refs/tags/* ]]; then | ||
TAG_NAME=${GITHUB_REF##*/} | ||
VERSION=${TAG_NAME#v} | ||
OLAH_SOURCE="https://github.com/${{ github.repository_owner }}/${{ github.repository }}/releases/download/${TAG_NAME}/olah-${VERSION}-py3-none-any.whl" | ||
OLAH_TAG="${VERSION}" | ||
elif [[ "${{ github.ref }}" == refs/heads/main ]]; then | ||
OLAH_SOURCE="olah" | ||
OLAH_TAG="lastet" | ||
fi | ||
elif [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then | ||
OLAH_SOURCE="olah==${{ github.event.inputs.olah_version }}" | ||
OLAH_TAG="${{ github.event.inputs.olah_version }}" | ||
fi | ||
echo "OLAH_SOURCE=$OLAH_SOURCE" >> $GITHUB_ENV | ||
echo "OLAH_TAG=$OLAH_TAG" >> $GITHUB_ENV | ||
- name: Checkout code | ||
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: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Meta data image | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: | | ||
${{ secrets.DOCKERHUB_USERNAME }}/olah | ||
ghcr.io/${{ github.repository_owner }}/olah | ||
tags: | | ||
type=raw,value=${{ env.OLAH_TAG }} | ||
type=raw,value=lastet | ||
flavor: | | ||
latest=false | ||
- name: Build push image | ||
id: build | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
file: ./docker/build@pypi/dockerfile | ||
build-args: | | ||
OLAH_SOURCE=${{ env.OLAH_SOURCE }} | ||
platforms: ${{ matrix.platform }} | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
|
||
- name: Print image digest | ||
run: echo ${{ steps.build.outputs.digest }} |
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 |
---|---|---|
|
@@ -163,4 +163,5 @@ cython_debug/ | |
/model_dir/ | ||
/dataset_dir/ | ||
/repos/ | ||
/logs/ | ||
/logs/ | ||
/cache/ |
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,14 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "debugpy: server", | ||
"type": "debugpy", | ||
"request": "launch", | ||
"program": "${workspaceFolder}/olah/server.py", | ||
"console": "integratedTerminal", | ||
"args": ["-c", "${workspaceFolder}/assets/full_configs.toml"], | ||
"justMyCode": false | ||
} | ||
] | ||
} |
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,53 @@ | ||
{ | ||
// See https://go.microsoft.com/fwlink/?LinkId=733558 | ||
// for the documentation about the tasks.json format | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"label": "docker: compose up", | ||
"type": "shell", | ||
"options": { | ||
"cwd": "${workspaceFolder}/docker/up/" | ||
}, | ||
"command": "docker compose -p olah up", | ||
}, | ||
{ | ||
"label": "docker: build main", | ||
"type": "shell", | ||
"command": "docker build -t xiaoyao9184/olah:main -f ./docker/build@source/dockerfile .", | ||
}, | ||
{ | ||
"label": "docker: build 0.3.3", | ||
"type": "shell", | ||
"command": "docker build -t xiaoyao9184/olah:0.3.3 -f ./docker/build@pypi/dockerfile .", | ||
}, | ||
{ | ||
"label": "huggingface-cli: download cais/mmlu", | ||
"type": "shell", | ||
"options": { | ||
"cwd": "${workspaceFolder}", | ||
"env": { | ||
"HF_ENDPOINT": "http://localhost:8090", | ||
"HF_HUB_ETAG_TIMEOUT": "100", | ||
"HF_HUB_DOWNLOAD_TIMEOUT": "100" | ||
} | ||
}, | ||
"command": "huggingface-cli download cais/mmlu --repo-type dataset --revision main --cache-dir ./cache/huggingface/hub" | ||
}, | ||
{ | ||
"label": "conda: run olah-cli", | ||
"type": "shell", | ||
"command": [ | ||
"conda run --no-capture-output -n olah olah-cli -c ./assets/full_configs.toml" | ||
], | ||
"problemMatcher": [] | ||
}, | ||
{ | ||
"label": "conda: create env", | ||
"type": "shell", | ||
"command": [ | ||
"conda env create -f ./environment.yml" | ||
] | ||
} | ||
] | ||
} |
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
ARG OLAH_SOURCE=olah==0.3.3 | ||
|
||
FROM python:3.12 | ||
|
||
ARG OLAH_SOURCE | ||
|
||
WORKDIR /app | ||
|
||
RUN pip3 install --upgrade pip | ||
|
||
RUN pip install --no-cache-dir ${OLAH_SOURCE} | ||
|
||
EXPOSE 8090 | ||
|
||
VOLUME /data/repos | ||
VOLUME /data/mirrors | ||
|
||
ENTRYPOINT [ "olah-cli" ] | ||
|
||
CMD ["--repos-path", "/repos"] |
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,17 @@ | ||
FROM python:3.12 | ||
|
||
WORKDIR /app | ||
|
||
RUN pip3 install --upgrade pip | ||
|
||
COPY . /app | ||
RUN pip3 install --no-cache-dir -e . | ||
|
||
EXPOSE 8090 | ||
|
||
VOLUME /data/repos | ||
VOLUME /data/mirrors | ||
|
||
ENTRYPOINT [ "olah-cli" ] | ||
|
||
CMD ["--repos-path", "/repos"] |
Oops, something went wrong.