Github Actions构建Docker镜像比本地大4倍的问题求助
镜像大小差异问题排查与优化请求
我正在开发一款应用,使用Github Actions执行CI/CD流程,构建Docker镜像并推送到AWS ECR云镜像仓库。但发现通过Github Actions构建的镜像大小是本地构建的4倍以上。
以下是同一代码通过两种方式构建后,云镜像仓库中的大小差异截图:
Github Actions配置文件
name: Build and Push Summarizer App Docker Image to AWS ECR on: push: branches: [ master ] jobs: build-and-push: name: Build Image & Push to ECR runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v3 - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v1 with: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws-region: eu-central-1 - name: Login to AWS ECR id: login-ecr uses: aws-actions/amazon-ecr-login@v1 - name: Build, Tag, and Push the Image to AWS ECR id: build-image env: ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} ECR_REPOSITORY: summarizer-service IMAGE_TAG: latest run: | docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
Dockerfile内容
from python:3.9-slim-buster run apt-get update run apt-get install -y python3 python3-dev python3-setuptools python3-pip git-all run apt-get install -y nginx supervisor run pip3 install uwsgi run apt-get install -y software-properties-common run apt-get update run add-apt-repository -y ppa:nginx/stable run apt-get install -y sqlite3 COPY ./requirements.txt /home/docker/ run pip3 install -r /home/docker/requirements.txt COPY ./nginx-app.conf /home/docker/ COPY ./supervisor-app.conf /home/docker/ COPY ./uwsgi.ini /home/docker/ COPY ./uwsgi_params /home/docker/ COPY ./app /home/docker/app # setup all the configfiles run echo "daemon off;" >> /etc/nginx/nginx.conf run rm /etc/nginx/sites-enabled/default run ln -s /home/docker/nginx-app.conf /etc/nginx/sites-enabled/ run ln -s /home/docker/supervisor-app.conf /etc/supervisor/conf.d/ expose 80 expose 443 cmd ["supervisord", "-n"]
我分别通过Github Actions和本地Docker命令构建镜像,两者镜像内容一致,但尺寸差异极大,希望得到排查原因及优化的宝贵建议。
Github Actions构建的镜像内容截图:
本地构建的镜像内容截图:
内容的提问来源于stack exchange,提问作者Jack Daniel
相关产品推荐
相关产品推荐

