slimtoolkit / slim

Slim(toolkit): Don't change anything in your container image and minify it by up to 30x (and for compiled languages even more) making it secure too! (free and open source)
Apache License 2.0
19.26k stars 718 forks source link

API url of python application is not working after docker-slim image #248

Open rajeshjatavkonvergeai opened 2 years ago

rajeshjatavkonvergeai commented 2 years ago

When running a python application with normal docker images, the application is running on Flask and the API URL is also working. When running this application with docker-slim image, the application is running but none of the APIs are working. Get the following error "home:1 Access to XMLHttpRequest at 'http://localhost:7002/PATH' from origin 'http://localhost:8080' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource."

I am running this application on Ubuntu 20.04.3 LTS machine. docker version is 20.10.8. docker-compose version is v2.0.1. docker-slim version is 1.34.0.

I am running docker-compose up command and got the error that I have attached the screenshot. docker-slim_error

The container hits the API at http://localhost:7002/PATH, and it works in the original python:3.9.7-buster image. Something about the slimming process appears to be removing something from the Requests library or something.

rajeshjatavkonvergeai commented 2 years ago

Any update?

satishdash commented 2 years ago

I perhaps have the same problem. After inspecting the slim report using docker xray I find the RUN instructions removed which actually had the pipenv install --clear -d command to install packages. @kcq Is there a config to use in cli that would depict which instructions shouldn't be excluded? (Thanks for all the hard work :) it's an awesome framework btw)

kcq commented 2 years ago

The original report seems to involve a containerized app with an unusual design. Usually the containerized apps don't "talk" to the host they are running on. Also not quit clear if the containerized app is a cli app or a server app that exposes a network/http interface. Need to know more about the application including the base path for the network interface if it's a server app.

Also useful to know the command line that was used to invoke docker-slim (will help with repro).

kcq commented 2 years ago

@satishdash not sure what you mean by RUN instructions removed which actually had the pipenv install --clear -d command to install packages

If you used xray on the minified image you won't see any of the original image instructions because the minified image is built from scratch.

Need more info about the app and how your tried to minify it.