【Projects/web_api】GitHub Workflow Docker镜像打包与上传 & 优化Dockerfile占用空间 #1
Workflow file for this run
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
name: Docker Build Image-WebAPI | |
on: | |
push: | |
branches: [ "master" ] | |
pull_request: | |
branches: [ "master" ] | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Clean up unnecessary large folders | |
run: | | |
# Delete unnecessary large folders | |
sudo rm -rf /opt/hostedtoolcache | |
sudo rm -rf /usr/share/dotnet | |
sudo rm -rf /usr/local/lib/android | |
sudo rm -rf /usr/local/share/boost | |
# Clean apt cache | |
sudo apt-get clean | |
sudo rm -rf /var/lib/apt/lists/* | |
# Show available disk space | |
df -h | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
with: | |
buildkitd-flags: --debug | |
- name: Login to Aliyun Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: crpi-is0d31x62vq89ybt.cn-hangzhou.personal.cr.aliyuncs.com | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v4 | |
with: | |
context: ./projects/web_api | |
file: ./projects/web_api/Dockerfile | |
push: true | |
tags: crpi-is0d31x62vq89ybt.cn-hangzhou.personal.cr.aliyuncs.com/betterspace/mineru2:latest | |
cache-from: type=registry,ref=crpi-is0d31x62vq89ybt.cn-hangzhou.personal.cr.aliyuncs.com/betterspace/mineru2:buildcache | |
cache-to: type=registry,ref=crpi-is0d31x62vq89ybt.cn-hangzhou.personal.cr.aliyuncs.com/betterspace/mineru2:buildcache,mode=max |