Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.venv
storage
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@
# You can see the Docker images from Apify at https://hub.docker.com/r/apify/.
# You can also use any other image from Docker Hub.
# % if cookiecutter.crawler_type == 'playwright'
FROM apify/actor-python-playwright:3.13
FROM apify/actor-python-playwright:3.13-beta
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's just for testing i guess? we dont want beta images in our templates

# % elif cookiecutter.crawler_type == 'playwright-camoufox'
# Currently camoufox has issues installing on Python 3.13
FROM apify/actor-python-playwright:3.12
FROM apify/actor-python-playwright:3.12-beta
# % else
FROM apify/actor-python:3.13
FROM apify/actor-python:3.13-beta
# % endif

RUN apt update && apt install -yq git && rm -rf /var/lib/apt/lists/*

# % if cookiecutter.package_manager == 'poetry'
RUN pip install -U pip setuptools \
&& pip install 'poetry<3' \
Expand All @@ -20,7 +18,7 @@ RUN pip install -U pip setuptools \
# Second, copy just poetry.lock and pyproject.toml into the Actor image,
# since those should be the only files that affects the dependency install in the next step,
# in order to speed up the build
COPY pyproject.toml poetry.lock ./
COPY --chown=myuser:myuser pyproject.toml poetry.lock ./

# Install the dependencies
RUN echo "Python version:" \
Expand All @@ -38,9 +36,7 @@ RUN echo "Python version:" \
RUN pip install -U pip setuptools \
&& pip install 'uv<1'

ENV UV_PROJECT_ENVIRONMENT="/usr/local"

COPY pyproject.toml uv.lock ./
COPY --chown=myuser:myuser pyproject.toml uv.lock ./

RUN echo "Python version:" \
&& python --version \
Expand All @@ -62,7 +58,7 @@ RUN pip install -U pip setuptools
# Second, copy just requirements.txt into the Actor image,
# since it should be the only file that affects the dependency install in the next step,
# in order to speed up the build
COPY requirements.txt ./
COPY --chown=myuser:myuser requirements.txt ./

# Install the dependencies
RUN echo "Python version:" \
Expand All @@ -83,10 +79,10 @@ RUN echo "Python version:" \
# Next, copy the remaining files and directories with the source code.
# Since we do this after installing the dependencies, quick build will be really fast
# for most source file changes.
COPY . ./
COPY --chown=myuser:myuser . ./

# Use compileall to ensure the runnability of the Actor Python code.
RUN python -m compileall -q .
RUN python -m compileall -q ./{{ cookiecutter.__package_name }}

# % if cookiecutter.crawler_type == 'playwright-camoufox'
# Fetch camoufox files that are always needed when using camoufox.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ authors = [
readme = "README.md"
requires-python = ">=3.10,<4.0"
dependencies = [
"crawlee[{{ extras|join(',') }}]",
"crawlee[{{ extras|join(',') }}]==0.6.12",
# % if cookiecutter.crawler_type == 'playwright-camoufox'
"camoufox[geoip]~=0.4.5",
# % endif
Expand Down
24 changes: 12 additions & 12 deletions tests/e2e/project_template/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ def _patch_crawlee_version_in_requirements_txt_based_project(project_path: Path,
with requirements_path.open() as f:
modified_lines = []
for line in f:
if 'crawlee' in line:
modified_lines.append(f'./{wheel_path.name}{crawlee_extras}\n')
else:
modified_lines.append(line)
# if 'crawlee' in line:
# modified_lines.append(f'./{wheel_path.name}{crawlee_extras}\n')
# else:
modified_lines.append(line)
with requirements_path.open('w') as f:
f.write(''.join(modified_lines))

Expand All @@ -42,13 +42,13 @@ def _patch_crawlee_version_in_requirements_txt_based_project(project_path: Path,
modified_lines = []
for line in f:
modified_lines.append(line)
if line.startswith('COPY requirements.txt ./'):
if line.startswith('COPY') and 'requirements.txt' in line:
modified_lines.extend(
[
f'COPY {wheel_path.name} ./\n',
# f'COPY {wheel_path.name} ./\n',
# If no crawlee version bump, pip might be lazy and take existing pre-installed crawlee version,
# make sure that one is patched as well.
f'RUN pip install ./{wheel_path.name}{crawlee_extras} --force-reinstall\n',
# f'RUN pip install ./{wheel_path.name}{crawlee_extras} --force-reinstall\n',
]
)
with dockerfile_path.open('w') as f:
Expand All @@ -69,7 +69,7 @@ def _patch_crawlee_version_in_pyproject_toml_based_project(project_path: Path, w
modified_lines = []
for line in f:
modified_lines.append(line)
if line.startswith('COPY pyproject.toml'):
if line.startswith('COPY') and 'pyproject.toml' in line:
if 'uv.lock' in line:
package_manager = 'uv'
elif 'poetry.lock' in line:
Expand All @@ -90,12 +90,12 @@ def _patch_crawlee_version_in_pyproject_toml_based_project(project_path: Path, w
# and so the absolute path(in the container) is generated when running `add` command in the container.
modified_lines.extend(
[
f'COPY {wheel_path.name} ./\n',
# f'COPY {wheel_path.name} ./\n',
# If no crawlee version bump, poetry might be lazy and take existing pre-installed crawlee
# version, make sure that one is patched as well.
f'RUN pip install ./{wheel_path.name}{crawlee_extras} --force-reinstall\n',
f'RUN {package_manager} add ./{wheel_path.name}{crawlee_extras}\n',
f'RUN {package_manager} lock\n',
# f'RUN pip install ./{wheel_path.name}{crawlee_extras} --force-reinstall\n',
# f'RUN {package_manager} add ./{wheel_path.name}{crawlee_extras}\n',
# f'RUN {package_manager} lock\n',
]
)
with dockerfile_path.open('w') as f:
Expand Down
Loading