Skip to content

Commit 2cbbc97

Browse files
ZhaoFancyYi-01-ai
andauthored
Update CI (#102)
* add basic check * apply autoflake * apply isort * apply black * add docker pipeline * maximize build space * use internal actions * make GA happy * update github action * add lock file * pass ci * fix typo * fix typo * check proxy * check proxy * add proxy * sync docker image everywhere * fix config error * add sync docker image in separate PR --------- Co-authored-by: Yi-01-ai <[email protected]>
1 parent fba730f commit 2cbbc97

File tree

11 files changed

+2966
-53
lines changed

11 files changed

+2966
-53
lines changed

.github/workflows/ci.yml

Lines changed: 59 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,65 @@ concurrency:
1515
jobs:
1616
basic-check:
1717
runs-on: ubuntu-latest
18-
strategy:
19-
matrix:
20-
python-version: ["3.10"]
18+
outputs:
19+
tag: ${{ steps.read_version.outputs.value }}
2120
steps:
2221
- uses: actions/checkout@v3
23-
# - uses: 01-ai/actions/lint@main
22+
- name: Checkout Actions
23+
uses: actions/checkout@v3
24+
with:
25+
repository: 01-ai/actions
26+
token: ${{ secrets.PAT_TO_CLONE_ACTIONS }}
27+
path: actions
28+
ref: main
29+
- name: Basic check
30+
uses: ./actions/lint
31+
# https://github.com/actions/checkout/issues/692#issuecomment-1502203573
32+
- name: Checkout Actions
33+
uses: actions/checkout@v3
34+
with:
35+
repository: 01-ai/actions
36+
token: ${{ secrets.PAT_TO_CLONE_ACTIONS }}
37+
path: actions
38+
ref: main
39+
# try to create a tag
40+
- uses: SebRollen/[email protected]
41+
id: read_version
42+
with:
43+
file: "pyproject.toml"
44+
field: "tool.poetry.version"
45+
- uses: rickstaa/action-create-tag@v1
46+
id: "tag_create"
47+
if: (github.ref_name == github.event.repository.default_branch) && !contains(steps.read_version.outputs.value, '-')
48+
with:
49+
tag: ${{ steps.read_version.outputs.value }}
2450

25-
# build-and-push:
26-
# needs: basic-check
27-
# runs-on:
28-
# - arc
29-
# - cpu
30-
# steps:
31-
# - name: Checkout
32-
# uses: actions/checkout@v3
33-
# - name: Set proxy
34-
# run: |
35-
# echo "http_proxy=$http_proxy" >> $GITHUB_ENV
36-
# echo "https_proxy=$https_proxy" >> $GITHUB_ENV
37-
# - uses: 01-ai/actions/build_docker_image@main
38-
# id: build-and-push
39-
# with:
40-
# registry: ${{ vars.VOLCES_REGISTRY }}
41-
# namespace: ${{ vars.VOLCES_NAMESPACE }}
42-
# tags: 'latest'
43-
# username: ${{ secrets.VOLCES_USER }}
44-
# password: ${{ secrets.VOLCES_TOKEN }}
51+
build-and-push:
52+
runs-on:
53+
- public
54+
needs: basic-check
55+
outputs:
56+
primary_tag: ${{ steps.build-and-push.outputs.primary_tag }}
57+
matrix: ${{ steps.build-and-push.outputs.matrix }}
58+
steps:
59+
- uses: actions/checkout@v3
60+
- name: Checkout Actions
61+
uses: actions/checkout@v3
62+
with:
63+
repository: 01-ai/actions
64+
token: ${{ secrets.PAT_TO_CLONE_ACTIONS }}
65+
path: actions
66+
ref: main
67+
- name: Set proxy
68+
run: |
69+
echo "http_proxy=$http_proxy" >> $GITHUB_ENV
70+
echo "https_proxy=$https_proxy" >> $GITHUB_ENV
71+
- name: Build Docker Image
72+
id: build-and-push
73+
uses: ./actions/build_docker_image
74+
with:
75+
registry: ${{ secrets.DEFAULT_REGISTRY }}
76+
namespace: ci
77+
tags: ${{ needs.basic-check.outputs.tag }}
78+
username: ${{ secrets.DEFAULT_REGISTRY_USER }}
79+
password: ${{ secrets.DEFAULT_REGISTRY_PASSWORD }}

Dockerfile

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,49 @@
11
ARG REGISTRY="nvcr.io"
22
ARG CUDA_VERSION="11.8.0"
3+
FROM mambaorg/micromamba:1.5.1 as micromamba
34
FROM ${REGISTRY}/nvidia/cuda:${CUDA_VERSION}-devel-ubuntu22.04 as base
45

5-
ARG MAX_JOBS=8
6-
6+
#####
7+
# Setup user & common tools
8+
#####
79
RUN apt update \
8-
&& apt install -y python3-pip python3-packaging git ninja-build \
9-
&& pip3 install -U pip \
10-
&& ln -s /usr/bin/python3 /usr/bin/python
10+
&& apt install -y git ninja-build \
11+
&& rm -rf /var/lib/apt/lists/*
1112

12-
WORKDIR /yi
13+
#####
14+
# Setup micromamba
15+
#####
16+
17+
USER root
18+
19+
ARG MAMBA_USER=yi
20+
ARG MAMBA_USER_ID=56789
21+
ARG MAMBA_USER_GID=56789
22+
ENV MAMBA_USER=$MAMBA_USER
23+
ENV MAMBA_ROOT_PREFIX="/opt/conda"
24+
ENV MAMBA_EXE="/bin/micromamba"
25+
ENV ENV_NAME=yi
1326

14-
RUN pip3 install torch==2.0.1 \
15-
&& pip3 install flash-attn==2.3.3 --no-build-isolation
27+
COPY --from=micromamba "$MAMBA_EXE" "$MAMBA_EXE"
28+
COPY --from=micromamba /usr/local/bin/_activate_current_env.sh /usr/local/bin/_activate_current_env.sh
29+
COPY --from=micromamba /usr/local/bin/_dockerfile_shell.sh /usr/local/bin/_dockerfile_shell.sh
30+
COPY --from=micromamba /usr/local/bin/_entrypoint.sh /usr/local/bin/_entrypoint.sh
31+
COPY --from=micromamba /usr/local/bin/_dockerfile_initialize_user_accounts.sh /usr/local/bin/_dockerfile_initialize_user_accounts.sh
32+
COPY --from=micromamba /usr/local/bin/_dockerfile_setup_root_prefix.sh /usr/local/bin/_dockerfile_setup_root_prefix.sh
1633

17-
COPY ./requirements.txt .
18-
RUN pip3 install -r requirements.txt
34+
RUN /usr/local/bin/_dockerfile_initialize_user_accounts.sh && \
35+
/usr/local/bin/_dockerfile_setup_root_prefix.sh
36+
37+
USER $MAMBA_USER
38+
SHELL ["/usr/local/bin/_dockerfile_shell.sh"]
39+
ENTRYPOINT ["/usr/local/bin/_entrypoint.sh"]
40+
CMD ["/bin/bash"]
41+
42+
# Install dependencies
43+
44+
WORKDIR /yi
45+
COPY ./conda-lock.yml .
46+
RUN micromamba create -y -n ${ENV_NAME} -f conda-lock.yml && \
47+
micromamba clean --all --yes
1948

20-
COPY . .
49+
COPY . .

0 commit comments

Comments
 (0)