-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add action workflow for torch2.2
- Loading branch information
Showing
3 changed files
with
136 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
name: Build and publish torchserve | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: 'Version of the image to build and publish' | ||
required: true | ||
default: 'v1.0.0' | ||
tags: | ||
description: 'Test scenario tags' | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
NAME: serve | ||
VERSION: ${{ github.event.inputs.version }} #v1.0.0 | ||
|
||
jobs: | ||
build-and-push-image: | ||
runs-on: ubuntu-latest | ||
permissions: # Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job. | ||
contents: read | ||
packages: write | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
# Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here. | ||
- name: Log in to the Container registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
# This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels. | ||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: ${{ env.REGISTRY }}/moverseai/moai/${{ env.NAME }} | ||
tags: | # https://github.com/docker/metadata-action#tags-input | ||
type=raw,enable=true,priority=200,prefix=,suffix=,value=${{ env.VERSION }}-pt112-cu113 | ||
# This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages. | ||
# It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository. | ||
# It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step. | ||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: . | ||
file: docker/serve/pt220-cu118/Dockerfile | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
# labels: ${{ steps.meta.outputs.labels }} | ||
labels: | # strip down labels: https://stackoverflow.com/questions/76472989/how-to-access-a-subset-of-keys-among-the-labels-in-the-json-object-returned-by-d | ||
org.opencontainers.image.created=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }} | ||
org.opencontainers.image.revision=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }} | ||
org.opencontainers.image.version=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }} | ||
com.github.moverseai.moai.sha=${{ github.sha }} | ||
com.github.moverseai.moai.branch=${{ github.ref_name }} |
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,29 @@ | ||
FROM ghcr.io/moverseai/moai/serve:v1.0.0-pt220-cu118 | ||
|
||
USER root | ||
|
||
RUN apt-get update && apt-get install -y -qq \ | ||
curl \ | ||
apt-transport-https \ | ||
lsb-release \ | ||
gnupg \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
RUN curl -sL https://packages.microsoft.com/keys/microsoft.asc | \ | ||
gpg --dearmor -o /etc/apt/trusted.gpg.d/microsoft.gpg \ | ||
&& echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ $(lsb_release -cs) main" | \ | ||
tee /etc/apt/sources.list.d/azure-cli.list | ||
|
||
RUN apt-get update && apt-get install -y -qq azure-cli | ||
|
||
# install azure python sdk | ||
RUN pip install azure-core \ | ||
azure-storage-blob | ||
|
||
# cache cleanup | ||
RUN chown -R worker /workspace \ | ||
&& chmod 755 /workspace \ | ||
&& pip cache purge && apt-get clean | ||
|
||
USER worker | ||
WORKDIR /workspace |
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,49 @@ | ||
FROM pytorch/pytorch:2.2.0-cuda11.8-cudnn8-runtime | ||
|
||
COPY . /moai | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -y -qq \ | ||
zip \ | ||
libgl1 \ | ||
openjdk-11-jre-headless \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
RUN python -m pip uninstall -y torchtext | ||
RUN pip install \ | ||
-e /moai \ | ||
torchserve==0.10.0 \ | ||
# onnx==1.8.1 \ | ||
torch-model-archiver==0.10.0 | ||
# onnxruntime==1.6.0 | ||
|
||
COPY ./docker/serve/config.properties /workspace/config.properties | ||
|
||
EXPOSE 7070/tcp 7071/tcp 8080/tcp 8081/tcp 8082/tcp | ||
|
||
COPY docker/serve/serve.sh /workspace/serve.sh | ||
RUN chmod +x /workspace/serve.sh | ||
|
||
RUN useradd -m worker \ | ||
&& mkdir -p /workspace/models \ | ||
&& mkdir -p /workspace/logs \ | ||
&& mkdir -p /workspace/data \ | ||
&& mkdir -p /workspace/run \ | ||
&& chown -R worker /workspace \ | ||
&& chmod 755 /workspace \ | ||
&& chown -R worker /workspace/data \ | ||
&& chmod 755 /workspace/data \ | ||
&& chown -R worker /workspace/logs \ | ||
&& chmod 755 /workspace/logs \ | ||
&& chown -R worker /workspace/run \ | ||
&& chmod 755 /workspace/run | ||
|
||
ENV LOG_LOCATION=/workspace/logs | ||
ENV METRICS_LOCATION=/workspace/logs | ||
|
||
RUN pip cache purge && apt-get clean | ||
|
||
USER worker | ||
WORKDIR /workspace | ||
|
||
ENTRYPOINT ["/bin/bash", "/workspace/serve.sh"] |