lwthiker / curl-impersonate

curl-impersonate: A special build of curl that can impersonate Chrome & Firefox
MIT License
3.45k stars 229 forks source link

Using curl-impersonate binaries from docker image inside my own image #189

Closed windbridges closed 4 months ago

windbridges commented 9 months ago

Could you tell me if I can use the binaries from the https://hub.docker.com/r/lwthiker/curl-impersonate image inside my image?

Right now I'm building curl-impersonate completely from source inside dockerfile, but it's very slow. I want to get rid of that.

Why can't I just use the official image? For the reason that I use other php extensions besides curl-impersonate, and have my own Dockerfile.

As far as I understand, I need to copy some files from this image into my own so I can use the library. Any instructions on which files to copy?

lhpalacio commented 9 months ago

Yes, you can utilize the binaries from the curl-impersonate Docker image in your own image without building it from source every time.

Here's an example using a multi-stage build:

FROM lwthiker/curl-impersonate:0.5.4-chrome-alpine AS curl-impersonate

# Your base image
FROM php-x

# Copy curl-impersonate binaries and wrapper scripts from the builder stage
COPY --from=curl-impersonate /usr/local /usr/local

# Rest of your Dockerfile...
windbridges commented 8 months ago

Yes, you can utilize the binaries from the curl-impersonate Docker image in your own image without building it from source every time.

Here's an example using a multi-stage build:

FROM lwthiker/curl-impersonate:0.5.4-chrome-alpine AS curl-impersonate

# Your base image
FROM php-x

# Copy curl-impersonate binaries and wrapper scripts from the builder stage
COPY --from=curl-impersonate /usr/local /usr/local

# Rest of your Dockerfile...

Could you please advise what the problem could be?

FROM lwthiker/curl-impersonate:0.5.4-chrome-alpine AS curl-impersonate

FROM php:8.2-cli AS base

# ....

COPY --from=curl-impersonate /usr/local /usr/local
------
 > [php base  8/11] COPY --from=curl-impersonate /usr/local /usr/local:
------
failed to solve: cannot copy to non-directory: /var/lib/docker/overlay2/avlxqohz55jf4i4vl6jikhtrm/merged/usr/local/include/curl
solariane commented 6 months ago

@windbridges or anyone coming here

I made it work by issuing a

RUN rm -fR /usr/local/include/curl

before the COPY command

And found another issue

error while loading shared libraries: libcurl-impersonate-chrome.so.4

so modify the DOCKERFILE to add

RUN ldconfig

after the COPY

lwthiker commented 4 months ago

This seems to be resolved so I'm closing it.