Compare commits

...
8 Commits
Author SHA1 Message Date
ThePhaseless 6a56098a33 add platform to apt cache name 2025-02-28 16:28:32 +01:00
ThePhaseless 7dd1dd633f upload apt and uv cache 2025-02-28 16:24:20 +01:00
ThePhaseless e825e588a8 add qemu back 2025-02-28 16:17:54 +01:00
ThePhaseless 43fe522417 [skip ci] allow sha versions 2025-02-28 16:13:28 +01:00
ThePhaseless ad88b7b505 comment out test 2025-02-28 16:11:59 +01:00
ThePhaseless 78deb9ed34 tweaks to tags 2025-02-28 16:11:10 +01:00
renovate[bot] 65f39b4448 Update dependency fastapi to v0.115.9 (#96)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-02-28 02:18:00 +00:00
ThePhaseless 565b076c67 cache apt and uv libs 2025-02-28 01:06:25 +01:00
5 changed files with 116 additions and 69 deletions
+105 -60
View File
@@ -23,33 +23,33 @@ env:
IMAGE_NAME: ${{ github.repository }}
jobs:
test:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write
# test:
# runs-on: ubuntu-latest
# permissions:
# contents: read
# packages: write
# id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
# steps:
# - name: Checkout repository
# uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v3
- name: Test
id: test
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64
cache-from: type=gha,scope=x64
pull: true
cache-to: type=gha,mode=max,scope=x64
target: test
# - name: Test
# id: test
# uses: docker/build-push-action@v6
# with:
# context: .
# platforms: linux/amd64
# cache-from: type=gha,scope=x64
# pull: true
# cache-to: type=gha,mode=max,scope=x64
# target: test
build:
needs: test
# needs: test
runs-on: ubuntu-latest
permissions:
contents: read
@@ -64,29 +64,21 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4
# Install the cosign tool except on PR
- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@v3
- name: Prepare variables
id: vars
run: |
SURFIX=$(echo ${{ matrix.platform }} | cut -d'/' -f2)
echo "SURFIX=$SURFIX" >> $GITHUB_OUTPUT
# Generate a unique local tag for the image
echo "LOCAL_TAG=local-${{ github.sha }}-$SURFIX" >> $GITHUB_OUTPUT
# Add support for more platforms with QEMU (optional)
# https://github.com/docker/setup-qemu-action
- name:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
# Set up BuildKit Docker container builder
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# Login against a Docker registry except on PR
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Extract metadata (tags, labels) for Docker
- name: Extract Docker metadata
id: meta
@@ -101,30 +93,53 @@ jobs:
type=raw,enable=${{ github.ref_type == 'tag' }}, value=latest
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# Build and push Docker image with platform-specific tag
- name: Build and push Docker image
id: build-and-push
- name: Set up apt cache
uses: actions/cache@v4
id: cache
with:
path: |
var-cache-apt
var-lib-apt
/root/.cache/uv
key: cache-${{ hashFiles('Dockerfile') }}-${{ steps.vars.outputs.SURFIX }}
- name: Inject cache into docker
uses: reproducible-containers/buildkit-cache-dance@v3.1.0
with:
cache-map: |
{
"var-cache-apt": "/var/cache/apt",
"var-lib-apt": "/var/lib/apt",
"root-cache-uv": "/root/.cache/uv"
}
skip-extraction: ${{ steps.cache.outputs.cache-hit }}
# Build and export Docker image for each platform (without pushing)
- name: Build Docker image
id: build
uses: docker/build-push-action@v6
with:
context: .
pull: true
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}-${{ matrix.platform == 'linux/amd64' && 'amd64' || 'arm64' }}
push: false
load: true # Export to local Docker instead of pushing
tags: ${{ steps.vars.outputs.LOCAL_TAG }}
labels: ${{ steps.meta.outputs.labels }}
platforms: ${{ matrix.platform }}
cache-from: type=gha,scope=${{ matrix.platform }}
cache-to: type=gha,mode=max,scope=${{ matrix.platform }}
build-args: GITHUB_BUILD=true,VERSION=${{ github.ref_type == 'tag' && github.ref_name || github.sha }}
outputs: type=docker,dest=/tmp/image-${{ steps.vars.outputs.SURFIX }}.tar
# Sign the platform specific image
- name: Sign the published Docker image
if: ${{ github.event_name != 'pull_request' }}
env:
TAGS: ${{ steps.meta.outputs.tags }}
DIGEST: ${{ steps.build-and-push.outputs.digest }}
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}
# Upload the tarball as an artifact
- name: Upload image artifact
uses: actions/upload-artifact@v4
with:
name: docker-image-${{ steps.vars.outputs.SURFIX }}
path: /tmp/image-${{ steps.vars.outputs.SURFIX }}.tar
retention-days: 1
merge:
merge-and-push:
needs: build
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
@@ -137,6 +152,15 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4
# Install the cosign tool
- name: Install cosign
uses: sigstore/cosign-installer@v3
# Set up Docker Buildx
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# Log into registry
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v3
with:
@@ -144,6 +168,7 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Extract Docker metadata for tagging
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
@@ -157,26 +182,46 @@ jobs:
type=raw,enable=${{ github.ref_type == 'tag' }}, value=latest
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Install cosign
uses: sigstore/cosign-installer@v3
# Download all image artifacts
- name: Download AMD64 image
uses: actions/download-artifact@v4
with:
name: docker-image-amd64
path: /tmp
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Download ARM64 image
uses: actions/download-artifact@v4
with:
name: docker-image-arm64
path: /tmp
- name: Create and push manifest
# Load images into Docker
- name: Load images
run: |
docker load --input /tmp/image-amd64.tar
docker load --input /tmp/image-arm64.tar
# Create manifest lists and push
- name: Create and push manifest lists
run: |
TAGS="${{ steps.meta.outputs.tags }}"
for TAG in $TAGS; do
# Tag the local images with their registry counterparts
docker tag local-${{ github.sha }}-amd64 $TAG-amd64
docker tag local-${{ github.sha }}-arm64 $TAG-arm64
# Push individual platform images
# docker push $TAG-amd64
# docker push $TAG-arm64
# Create manifest list and push it
docker buildx imagetools create -t $TAG \
$TAG-amd64 \
$TAG-arm64
done
- name: Install cosign
uses: sigstore/cosign-installer@v3
- name: Sign the manifest
# Sign the manifest
- name: Sign the manifests
env:
TAGS: ${{ steps.meta.outputs.tags }}
run: |
+5 -3
View File
@@ -15,13 +15,15 @@ ENV PATH="${HOME}/.local/bin:$PATH"
WORKDIR /app
RUN apt update &&\
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
apt update && \
apt install -y --no-install-recommends --no-install-suggests xauth xvfb scrot wget chromium chromium-driver ca-certificates
ADD https://astral.sh/uv/install.sh install.sh
RUN sh install.sh
COPY pyproject.toml uv.lock ./
RUN uv sync
RUN --mount=type=cache,target=${HOME}/.cache/uv uv sync
# SeleniumBase does not come with an arm64 chromedriver binary
RUN cd .venv/lib/*/site-packages/seleniumbase/drivers && ln -s /usr/bin/chromedriver uc_driver
@@ -30,7 +32,7 @@ COPY . .
FROM base AS test
RUN uv sync --group test
RUN --mount=type=cache,target=${HOME}/.cache/uv uv sync --group test
RUN ./test.sh
FROM base
+1 -1
View File
@@ -8,7 +8,7 @@ version = "0.1.0"
description = "API for getting cookies for Cloudflare challenges"
readme = "README.md"
dependencies = [
"fastapi[standard]==0.115.8",
"fastapi[standard]==0.115.9",
"pyautogui==0.9.54",
"pydantic==2.10.6",
"seleniumbase==4.35.2",
+1 -1
View File
@@ -16,7 +16,7 @@ def get_version_from_env():
"""
version_env = os.getenv("VERSION")
if not version_env or not version_env.startswith("v"):
if not version_env:
return None
return version_env.removeprefix("v")
Generated
+4 -4
View File
@@ -89,7 +89,7 @@ test = [
[package.metadata]
requires-dist = [
{ name = "fastapi", extras = ["standard"], specifier = "==0.115.8" },
{ name = "fastapi", extras = ["standard"], specifier = "==0.115.9" },
{ name = "pyautogui", specifier = "==0.9.54" },
{ name = "pydantic", specifier = "==2.10.6" },
{ name = "seleniumbase", specifier = "==4.35.2" },
@@ -272,16 +272,16 @@ wheels = [
[[package]]
name = "fastapi"
version = "0.115.8"
version = "0.115.9"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "pydantic" },
{ name = "starlette" },
{ name = "typing-extensions" },
]
sdist = { url = "https://files.pythonhosted.org/packages/a2/b2/5a5dc4affdb6661dea100324e19a7721d5dc524b464fe8e366c093fd7d87/fastapi-0.115.8.tar.gz", hash = "sha256:0ce9111231720190473e222cdf0f07f7206ad7e53ea02beb1d2dc36e2f0741e9", size = 295403 }
sdist = { url = "https://files.pythonhosted.org/packages/ab/dd/d854f85e70f7341b29e3fda754f2833aec197bd355f805238758e3bcd8ed/fastapi-0.115.9.tar.gz", hash = "sha256:9d7da3b196c5eed049bc769f9475cd55509a112fbe031c0ef2f53768ae68d13f", size = 293774 }
wheels = [
{ url = "https://files.pythonhosted.org/packages/8f/7d/2d6ce181d7a5f51dedb8c06206cbf0ec026a99bf145edd309f9e17c3282f/fastapi-0.115.8-py3-none-any.whl", hash = "sha256:753a96dd7e036b34eeef8babdfcfe3f28ff79648f86551eb36bfc1b0bf4a8cbf", size = 94814 },
{ url = "https://files.pythonhosted.org/packages/32/b6/7517af5234378518f27ad35a7b24af9591bc500b8c1780929c1295999eb6/fastapi-0.115.9-py3-none-any.whl", hash = "sha256:4a439d7923e4de796bcc88b64e9754340fcd1574673cbd865ba8a99fe0d28c56", size = 94919 },
]
[package.optional-dependencies]