Skip to content

Instantly share code, notes, and snippets.

@divinity76
Created February 8, 2024 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save divinity76/646f743331ceec492a1a3c1bf227f435 to your computer and use it in GitHub Desktop.
Save divinity76/646f743331ceec492a1a3c1bf227f435 to your computer and use it in GitHub Desktop.
Dockerfile reproduce example
# see https://github.com/php/php-src/issues/12450
FROM ubuntu:20.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update -y
RUN apt-get -y full-upgrade;
RUN apt-get -y install apt-utils
RUN apt-get -y install golang build-essential git autoconf bison re2c make cmake automake libtool libpsl-dev libpsl5
RUN bash -c 'set -e;\
git clone -b curl-8_6_0 --single-branch --depth 1 https://github.com/curl/curl.git; \
cd curl; \
autoreconf -fi; \
echo ./buildconf; \
./configure --without-ssl --without-libpsl ; \
make -j$(nproc); \
make install\
'
RUN bash -c 'set -e;\
git clone '\''https://github.com/php/php-src.git'\'' /tmp/php-src --single-branch --depth 1; \
cd /tmp/php-src; \
./buildconf --force; \
./configure --disable-all --disable-cgi --enable-cli --with-curl;\
make -j$(nproc); \
make install; \
php -v; \
'
RUN echo '<?php\n\
\n\
declare(strict_types=1);\n\
\n\
$ch = curl_init();\n\
\n\
curl_setopt($ch, CURLOPT_HEADER, false);\n\
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");\n\
\n\
curl_setopt($ch, CURLOPT_URL, "http://localhost");\n\
curl_exec($ch);\n\
\n\
curl_setopt($ch, CURLOPT_URL, "http://localhost");\n\
curl_exec($ch);\n\
\n\
curl_close($ch);\n\
' > /tmp/reproduce.php;
RUN echo 'package main\n\
\n\
import (\n\
"log"\n\
"net/http"\n\
"time"\n\
)\n\
\n\
type Handler struct {\n\
amount int\n\
}\n\
\n\
func (p *Handler) ServeHTTP(respw http.ResponseWriter, req *http.Request) {\n\
log.Printf("Got %s request %v from %s\\n", req.Method, req.URL.String(), req.RemoteAddr)\n\
\n\
p.amount += 1\n\
\n\
if p.amount == 2 {\n\
time.Sleep(time.Second * 5)\n\
}\n\
\n\
return\n\
}\n\
\n\
func main() {\n\
h := Handler{}\n\
srv := http.Server{\n\
Addr: ":80",\n\
Handler: &h,\n\
ReadTimeout: 2 * time.Second,\n\
WriteTimeout: 2 * time.Second,\n\
}\n\
\n\
srv.ListenAndServe()\n\
}\n\
' > /tmp/main.go;
RUN bash -c 'set -e;\
php -v; \
php -i | grep -i curl ; \
go run /tmp/main.go & sleep 1; \
php /tmp/reproduce.php;\
false; \
';
# the last false; prevents caching of the last RUN.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment