kitabisa / docker-slim-action

GitHub Action to minify container image by up to 30x (and for compiled languages even more) making it secure too!
MIT License
22 stars 5 forks source link

Over-minified Image Problem #4

Closed pourmand1376 closed 11 months ago

pourmand1376 commented 1 year ago

Hi, Thanks for building this amazing Github action.

I want to add your workflow to al-folio github template.

This is my docker-compose file:

version: "3"
# this file uses prebuilt image in dockerhub
services:
  jekyll:
    image: amirpourmand/al-folio
    ports:
      - 8080:8080
    volumes:
      - .:/srv/jekyll

This is my github actions file:

name: Docker Slim

#Only trigger, when the build workflow succeeded
# on:
#   workflow_run:
#     workflows: ["Docker Image CI"]
#     types:
#       - completed

on: 
  push:
    branches: 
      - '**'

jobs: 
  build:
    runs-on: ubuntu-latest

    defaults:
      run:
        working-directory: ${{ github.workspace }}

    steps:
    - name: Checkout
      uses: actions/checkout@v3

    - name: update docker-compose
      shell: bash
      run:  |
        sed -i "s|\.:|${{ github.workspace }}:|g" ${{ github.workspace }}/docker-compose.yml 
        cat ${{ github.workspace }}/docker-compose.yml 

    - uses: kitabisa/docker-slim-action@v1
      env:
        DSLIM_HTTP_PROBE: false
        DSLIM_PULL: true
        DSLIM_COMPOSE_FILE: ${{ github.workspace }}/docker-compose.yml
        DSLIM_TARGET_COMPOSE_SVC: jekyll
      with:
        target: amirpourmand/al-folio
        tag: "slim"

I've noticed that when I use Docker Slim, the image size on my local machine is reduced from 1.6GB to 188MB, which is already impressive. However, when I utilize Docker Slim within my GitHub Actions workflow, the image size is further reduced to just 14MB, which seems almost impossible.

I can not understand where the problem is or how I should fix this.

Here you can see the complete log file.

dwisiswant0 commented 1 year ago

How do you reproduce slim on your local machine? Do the commands and environment mirror those used in your GitHub Actions?

pourmand1376 commented 1 year ago

Hi, Thanks for replying.

Here, I've mentioned using docker-slim and came along with this code to minify my docker image (which works great):

docker-slim build --compose-file docker-compose.yml --target-compose-svc jekyll

I've tried to mirror everything but something is not right. Can you spot any difference?

dwisiswant0 commented 1 year ago

So, the way you reproduce on the local machine does not use --http-probe-off or --http-probe=false flag?

pourmand1376 commented 1 year ago

No, I do not use http-probe-off.

This was something I did to see if the problem can be fixed. Now, I commented out this line and the problem still persists.

Here is the dockerslim github action and Here is the log.

It is still saying:

cmd=build info=results status='MINIFIED' by='109.74X' size.original='1.6 GB' size.optimized='14 MB' 
pourmand1376 commented 11 months ago

I've found the problem!

Why is --continue-after 1 the default option? There is no way to change this to normal mode and it overrides default behavior.

https://github.com/kitabisa/docker-slim-action/blob/1ca67f5c1a2812a600fb1aefd09a8ba048954c78/src/index.ts#L129

pourmand1376 commented 11 months ago

I could reproduce the problem by using

docker-slim build --compose-file docker-compose.yml --target-compose-svc jekyll --continue-after 1

The point is continue-after 1 should not be passed by default.