-
Notifications
You must be signed in to change notification settings - Fork 253
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from lwthiker/alpine
Add Alpine Linux images and push automatically to DockerHub
- Loading branch information
Showing
9 changed files
with
432 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Build an Alpine Linux image containing curl-impersonate and push to | ||
# Docker hub. | ||
name: Publish Docker image | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
|
||
jobs: | ||
push-docker-image: | ||
name: Push Docker image to Docker Hub | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out the repo | ||
uses: actions/checkout@v2 | ||
|
||
- name: Log in to Docker Hub | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
- name: Extract metadata (tags, labels) for Docker (chrome) | ||
id: meta_chrome | ||
uses: docker/metadata-action@v3 | ||
with: | ||
images: lwthiker/curl-impersonate | ||
tags: | | ||
type=semver,pattern={{version}},suffix=-chrome-alpine | ||
type=semver,pattern={{version}},suffix=-chrome | ||
type=semver,pattern={{major}}.{{minor}},suffix=-chrome-alpine | ||
type=semver,pattern={{major}}.{{minor}},suffix=-chrome | ||
- name: Build and push the Chrome version of curl-impersonate | ||
uses: docker/build-push-action@v2 | ||
with: | ||
push: true | ||
context: chrome/ | ||
file: chrome/Dockerfile.alpine | ||
tags: ${{ steps.meta_chrome.outputs.tags }} | ||
labels: ${{ steps.meta_chrome.outputs.labels }} | ||
|
||
- name: Extract metadata (tags, labels) for Docker (firefox) | ||
id: meta_firefox | ||
uses: docker/metadata-action@v3 | ||
with: | ||
images: lwthiker/curl-impersonate | ||
tags: | | ||
type=semver,pattern={{version}},suffix=-ff-alpine | ||
type=semver,pattern={{version}},suffix=-ff | ||
type=semver,pattern={{major}}.{{minor}},suffix=-ff-alpine | ||
type=semver,pattern={{major}}.{{minor}},suffix=-ff | ||
- name: Build and push the Firefox version of curl-impersonate | ||
uses: docker/build-push-action@v2 | ||
with: | ||
push: true | ||
context: firefox/ | ||
file: firefox/Dockerfile.alpine | ||
tags: ${{ steps.meta_firefox.outputs.tags }} | ||
labels: ${{ steps.meta_firefox.outputs.labels }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
# | ||
# NOTE: THIS DOCKERFILE IS GENERATED FROM "Dockerfile.template" VIA | ||
# "generate-dockerfiles.sh". | ||
# | ||
# PLEASE DO NOT EDIT IT DIRECTLY. | ||
# | ||
|
||
FROM alpine:3.15.0 as builder | ||
|
||
WORKDIR /build | ||
|
||
# Common dependencies | ||
RUN apk add git build-base make cmake ninja curl zlib-dev patch linux-headers python3 python3-dev | ||
|
||
# The following are needed because we are going to change some autoconf scripts, | ||
# both for libnghttp2 and curl. | ||
RUN apk add autoconf automake pkgconfig libtool | ||
|
||
# Dependencies for downloading and building BoringSSL | ||
RUN apk add g++ go unzip | ||
|
||
# Download and compile libbrotli | ||
ARG BROTLI_VERSION=1.0.9 | ||
RUN curl -L https://github.com/google/brotli/archive/refs/tags/v${BROTLI_VERSION}.tar.gz -o brotli-${BROTLI_VERSION}.tar.gz && \ | ||
tar xf brotli-${BROTLI_VERSION}.tar.gz | ||
RUN cd brotli-${BROTLI_VERSION} && \ | ||
mkdir build && cd build && \ | ||
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=./installed .. && \ | ||
cmake --build . --config Release --target install | ||
|
||
# BoringSSL doesn't have versions. Choose a commit that is used in a stable | ||
# Chromium version. | ||
ARG BORING_SSL_COMMIT=3a667d10e94186fd503966f5638e134fe9fb4080 | ||
RUN curl -L https://github.com/google/boringssl/archive/${BORING_SSL_COMMIT}.zip -o boringssl.zip && \ | ||
unzip boringssl && \ | ||
mv boringssl-${BORING_SSL_COMMIT} boringssl | ||
|
||
# Compile BoringSSL. | ||
# See https://boringssl.googlesource.com/boringssl/+/HEAD/BUILDING.md | ||
COPY patches/boringssl-*.patch boringssl/ | ||
RUN cd boringssl && \ | ||
for p in $(ls boringssl-*.patch); do patch -p1 < $p; done && \ | ||
mkdir build && cd build && \ | ||
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_POSITION_INDEPENDENT_CODE=on -GNinja .. && \ | ||
ninja | ||
|
||
# Fix the directory structure so that curl can compile against it. | ||
# See https://everything.curl.dev/source/build/tls/boringssl | ||
RUN mkdir boringssl/build/lib && \ | ||
ln -s ../crypto/libcrypto.a boringssl/build/lib/libcrypto.a && \ | ||
ln -s ../ssl/libssl.a boringssl/build/lib/libssl.a && \ | ||
cp -R boringssl/include boringssl/build | ||
|
||
ARG NGHTTP2_VERSION=nghttp2-1.46.0 | ||
ARG NGHTTP2_URL=https://github.com/nghttp2/nghttp2/releases/download/v1.46.0/nghttp2-1.46.0.tar.bz2 | ||
|
||
# Download nghttp2 for HTTP/2.0 support. | ||
RUN curl -o ${NGHTTP2_VERSION}.tar.bz2 -L ${NGHTTP2_URL} | ||
RUN tar xf ${NGHTTP2_VERSION}.tar.bz2 | ||
|
||
# Patch nghttp2 pkg config file to support static builds. | ||
COPY patches/libnghttp2-*.patch ${NGHTTP2_VERSION}/ | ||
RUN cd ${NGHTTP2_VERSION} && \ | ||
for p in $(ls libnghttp2-*.patch); do patch -p1 < $p; done && \ | ||
autoreconf -i && automake && autoconf | ||
|
||
# Compile nghttp2 | ||
RUN cd ${NGHTTP2_VERSION} && \ | ||
./configure --with-pic && \ | ||
make && make install | ||
|
||
# Download curl. | ||
ARG CURL_VERSION=curl-7.81.0 | ||
RUN curl -o ${CURL_VERSION}.tar.xz https://curl.se/download/${CURL_VERSION}.tar.xz | ||
RUN tar xf ${CURL_VERSION}.tar.xz | ||
|
||
# Patch curl and re-generate the configure script | ||
COPY patches/curl-*.patch ${CURL_VERSION}/ | ||
RUN cd ${CURL_VERSION} && \ | ||
for p in $(ls curl-*.patch); do patch -p1 < $p; done && \ | ||
autoreconf -fi | ||
|
||
# Compile curl with nghttp2, libbrotli and nss (firefox) or boringssl (chrome). | ||
# Enable keylogfile for debugging of TLS traffic. | ||
RUN cd ${CURL_VERSION} && \ | ||
./configure --enable-static \ | ||
--disable-shared \ | ||
--with-nghttp2=/usr/local \ | ||
--with-brotli=/build/brotli-${BROTLI_VERSION}/build/installed \ | ||
--with-openssl=/build/boringssl/build \ | ||
LIBS="-pthread" \ | ||
CFLAGS="-I/build/boringssl/build" \ | ||
USE_CURL_SSLKEYLOGFILE=true && \ | ||
make | ||
|
||
RUN mkdir out && \ | ||
cp ${CURL_VERSION}/src/curl out/curl-impersonate && \ | ||
strip out/curl-impersonate | ||
|
||
# Re-compile libcurl dynamically | ||
RUN cd ${CURL_VERSION} && \ | ||
./configure --with-nghttp2=/usr/local \ | ||
--with-brotli=/build/brotli-${BROTLI_VERSION}/build/installed \ | ||
--with-openssl=/build/boringssl/build \ | ||
LIBS="-pthread" \ | ||
CFLAGS="-I/build/boringssl/build" \ | ||
USE_CURL_SSLKEYLOGFILE=true && \ | ||
make clean && make | ||
|
||
# Rename to 'libcurl-impersonate' to avoid confusion, and recreate the | ||
# symbolic links. | ||
RUN ver=$(readlink -f curl-7.81.0/lib/.libs/libcurl.so | sed 's/.*so\.//') && \ | ||
major=$(echo -n $ver | cut -d'.' -f1) && \ | ||
cp "${CURL_VERSION}/lib/.libs/libcurl.so.$ver" "out/libcurl-impersonate.so.$ver" && \ | ||
ln -s "libcurl-impersonate.so.$ver" "out/libcurl-impersonate.so.$major" && \ | ||
ln -s "libcurl-impersonate.so.$ver" "out/libcurl-impersonate.so" && \ | ||
strip "out/libcurl-impersonate.so.$ver" | ||
|
||
# Wrapper scripts | ||
COPY curl_chrome* curl_edge* curl_safari* out/ | ||
# Replace /bin/bash with /bin/ash | ||
RUN sed -i 's@/bin/bash@/bin/ash@' out/curl_* | ||
RUN chmod +x out/curl_* | ||
|
||
# When using alpine, create a final, minimal image with the compiled binaries | ||
# only. | ||
FROM alpine:3.15.0 | ||
|
||
# Copy curl-impersonate from the builder image | ||
COPY --from=builder /build/out/curl-impersonate /usr/local/bin/ | ||
# Wrapper scripts | ||
COPY --from=builder /build/out/curl_* /usr/local/bin/ | ||
|
||
# Copy libcurl-impersonate from the builder image | ||
COPY --from=builder /build/out/libcurl-impersonate.so /usr/local/lib/ |
Oops, something went wrong.