build: 尝试在GitHub Action构建
This commit is contained in:
parent
d31c6399f6
commit
b2ff5645b5
52
.github/workflows/build-and-push.yml
vendored
Normal file
52
.github/workflows/build-and-push.yml
vendored
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
name: build-and-push
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
registryAddress:
|
||||||
|
description: 'Registry Address'
|
||||||
|
default: 'registry-hkproxy.fit2cloud.com'
|
||||||
|
required: true
|
||||||
|
dockerImageName:
|
||||||
|
description: 'Docker Image Name'
|
||||||
|
default: 'maxkb/maxkb'
|
||||||
|
required: true
|
||||||
|
dockerImageTag:
|
||||||
|
description: 'Docker Image Tag'
|
||||||
|
default: 'v1.0.0'
|
||||||
|
required: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-push:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Prepare
|
||||||
|
id: prepare
|
||||||
|
run: |
|
||||||
|
DOCKER_IMAGE=${{ github.event.inputs.registryAddress }}/${{ github.event.inputs.dockerImageName }}
|
||||||
|
DOCKER_PLATFORMS=linux/amd64,linux/arm64
|
||||||
|
TAG_NAME=${{ github.event.inputs.dockerImageTag }}
|
||||||
|
DOCKER_IMAGE_TAGS="--tag ${DOCKER_IMAGE}:${TAG_NAME} --tag ${DOCKER_IMAGE}:latest"
|
||||||
|
echo ::set-output name=docker_image::${DOCKER_IMAGE}
|
||||||
|
echo ::set-output name=version::${TAG_NAME}
|
||||||
|
echo ::set-output name=buildx_args::--platform ${DOCKER_PLATFORMS} \
|
||||||
|
--build-arg VERSION=${TAG_NAME} \
|
||||||
|
--build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \
|
||||||
|
--build-arg VCS_REF=${GITHUB_SHA::8} \
|
||||||
|
${DOCKER_IMAGE_TAGS} .
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: crazy-max/ghaction-docker-buildx@v3
|
||||||
|
- name: Docker Buildx (build)
|
||||||
|
run: |
|
||||||
|
docker buildx build --output "type=image,push=false" ${{ steps.prepare.outputs.buildx_args }}
|
||||||
|
- name: Login to Registry
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
registry: ${{ github.event.inputs.registryAddress }}
|
||||||
|
username: ${{ secrets.FIT2CLOUD_REGISTRY_USERNAME }}
|
||||||
|
password: ${{ secrets.FIT2CLOUD_REGISTRY_PASSWORD }}
|
||||||
|
- name: Docker Buildx (push)
|
||||||
|
run: |
|
||||||
|
docker buildx build --output "type=image,push=true" ${{ steps.prepare.outputs.buildx_args }}
|
||||||
18
Dockerfile
18
Dockerfile
@ -1,3 +1,16 @@
|
|||||||
|
FROM python:3.11-slim as vector-model-build
|
||||||
|
COPY install_model.py install_model.py
|
||||||
|
RUN pip3 install --upgrade pip setuptools && \
|
||||||
|
pip install pycrawlers && \
|
||||||
|
pip install transformers && \
|
||||||
|
python3 install_model.py
|
||||||
|
|
||||||
|
FROM node:18-alpine3.18 as web-build
|
||||||
|
COPY ui ui
|
||||||
|
RUN cd ui && \
|
||||||
|
npm install && \
|
||||||
|
npm run build
|
||||||
|
|
||||||
FROM python:3.11-slim
|
FROM python:3.11-slim
|
||||||
|
|
||||||
ENV LANG=C.UTF-8
|
ENV LANG=C.UTF-8
|
||||||
@ -6,7 +19,10 @@ USER root
|
|||||||
# 创建工作目录
|
# 创建工作目录
|
||||||
RUN mkdir -p /opt/maxkb/app && mkdir -p /opt/maxkb/model
|
RUN mkdir -p /opt/maxkb/app && mkdir -p /opt/maxkb/model
|
||||||
# 拷贝项目
|
# 拷贝项目
|
||||||
|
RUN ls -la
|
||||||
COPY . /opt/maxkb/app
|
COPY . /opt/maxkb/app
|
||||||
|
COPY --from=vector-model-build model /opt/maxkb/app/model
|
||||||
|
COPY --from=web-build ui /opt/maxkb/app/ui
|
||||||
# 复制模型
|
# 复制模型
|
||||||
RUN mv /opt/maxkb/app/model/* /opt/maxkb/model
|
RUN mv /opt/maxkb/app/model/* /opt/maxkb/model
|
||||||
RUN ls /opt/maxkb/model
|
RUN ls /opt/maxkb/model
|
||||||
@ -22,7 +38,7 @@ RUN pip3 install poetry
|
|||||||
# 导出依赖
|
# 导出依赖
|
||||||
RUN poetry export -f requirements.txt --output requirements.txt --without-hashes
|
RUN poetry export -f requirements.txt --output requirements.txt --without-hashes
|
||||||
# 下载python依赖
|
# 下载python依赖
|
||||||
RUN pip3 install --no-cache-dir -r requirements.txt --trusted-host pypi.tuna.tsinghua.edu.cn
|
RUN pip3 install --no-cache-dir -r requirements.txt
|
||||||
# 删除前端依赖
|
# 删除前端依赖
|
||||||
RUN rm -rf ui/node_modules
|
RUN rm -rf ui/node_modules
|
||||||
# 启动命令
|
# 启动命令
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user