- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix installer.sh
to only require /bin/sh
.
#141
Merged
+283
−201
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
5c89f32
Setup docker cmd.
jsirois 72bcea4
Fix up tags for arches with `/` in them.
jsirois 680452c
Fix Windows typing.
jsirois 3cb70af
Actually type:ignore.
jsirois 8c83031
Convert install.sh to Posix sh syntax for wider usability.
jsirois 2d4ab73
Add back ppc64le test skip.
jsirois File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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,16 @@ | ||
FROM python:3.12-alpine | ||
|
||
ARG UID | ||
ARG GID | ||
|
||
RUN pip install --root-user-action ignore uv && \ | ||
addgroup --gid $GID build && \ | ||
adduser -D -g '' -G build -u $UID build && \ | ||
apk add \ | ||
bash \ | ||
curl \ | ||
gcc \ | ||
git \ | ||
linux-headers \ | ||
musl-dev \ | ||
python3-dev |
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,11 @@ | ||
FROM python:3.12-bookworm | ||
|
||
ARG UID | ||
ARG GID | ||
|
||
RUN pip install --root-user-action ignore uv && \ | ||
addgroup --gid ${GID} build && \ | ||
adduser --disabled-password --gecos '' --gid ${GID} --uid ${UID} build | ||
|
||
COPY post-install.sh /post-install.sh | ||
RUN /post-install.sh && rm /post-install.sh |
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,10 @@ | ||
#!/usr/bin/env sh | ||
|
||
set -eu | ||
|
||
if [ "$(uname -m)" = "s390x" ]; then | ||
# This hack gets the PyPy provider working on this image. The old PyPy s390x distributions | ||
# dynamically link libffi at an older version than I've been able to find a multi-platform | ||
# image with s390x support for. | ||
ln -s /usr/lib/s390x-linux-gnu/libffi.so.8 /usr/lib/s390x-linux-gnu/libffi.so.6 | ||
fi |
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,124 @@ | ||
# Copyright 2025 Science project contributors. | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
import os | ||
import shutil | ||
import subprocess | ||
import sys | ||
from argparse import ArgumentParser | ||
from pathlib import Path | ||
from typing import Any | ||
|
||
from science.platform import CURRENT_OS, Os | ||
|
||
|
||
def main() -> Any: | ||
if CURRENT_OS is Os.Windows: | ||
return "This script does not work on Windows yet." | ||
|
||
parser = ArgumentParser() | ||
parser.add_argument("--image", default="debian", choices=["alpine", "debian"]) | ||
parser.add_argument( | ||
"--arch", | ||
default="amd64", | ||
choices=[ | ||
"amd64", | ||
"arm64", | ||
"riscv64", | ||
"ppc64le", | ||
"s390x", | ||
"386", | ||
"mips64le", | ||
"mips64", | ||
"arm/v7", | ||
"arm/v6", | ||
], | ||
) | ||
options, args = parser.parse_known_args() | ||
|
||
platform = f"linux/{options.arch}" | ||
subprocess.run( | ||
args=[ | ||
"docker", | ||
"run", | ||
"--privileged", | ||
"--rm", | ||
"tonistiigi/binfmt", | ||
"--install", | ||
platform, | ||
], | ||
check=True, | ||
) | ||
|
||
parent_dir = Path(__file__).parent | ||
arch_tag = options.arch.replace("/", "-") | ||
base_image = f"a-scie/lift/base:{arch_tag}" | ||
|
||
# The type-ignores for os.get{uid,gid} cover Windows which we explicitly fail-fast for above. | ||
subprocess.run( | ||
args=[ | ||
"docker", | ||
"buildx", | ||
"build", | ||
"--build-arg", | ||
f"UID={os.getuid()}", # type:ignore[attr-defined] | ||
"--build-arg", | ||
f"GID={os.getgid()}", # type:ignore[attr-defined] | ||
"--platform", | ||
platform, | ||
"--tag", | ||
base_image, | ||
str(parent_dir / options.image), | ||
], | ||
check=True, | ||
) | ||
|
||
dev_image = f"a-scie/lift/dev:{arch_tag}" | ||
|
||
ephemeral_build_context = parent_dir / "ephemeral-build-context" | ||
ephemeral_build_context.mkdir(parents=True, exist_ok=True) | ||
shutil.copy(Path("pyproject.toml"), ephemeral_build_context) | ||
shutil.copy(Path("uv.lock"), ephemeral_build_context) | ||
|
||
subprocess.run( | ||
args=[ | ||
"docker", | ||
"buildx", | ||
"build", | ||
"--build-arg", | ||
f"BASE_IMAGE={base_image}", | ||
"--build-context", | ||
f"ephemeral={ephemeral_build_context}", | ||
"--platform", | ||
platform, | ||
"--tag", | ||
dev_image, | ||
str(parent_dir / "uv"), | ||
], | ||
check=True, | ||
) | ||
|
||
subprocess.run( | ||
args=[ | ||
"docker", | ||
"run", | ||
"-e", | ||
"FORCE_COLOR", | ||
"-e", | ||
"SCIENCE_AUTH_API_GITHUB_COM_BEARER", | ||
"-v", | ||
f"{Path().absolute()}:/code", | ||
"--platform", | ||
platform, | ||
dev_image, | ||
*args, | ||
], | ||
check=True, | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
try: | ||
sys.exit(main()) | ||
except subprocess.CalledProcessError as e: | ||
sys.exit(str(e)) |
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,15 @@ | ||
ARG BASE_IMAGE=scratch | ||
FROM ${BASE_IMAGE} | ||
|
||
VOLUME /code | ||
WORKDIR /code | ||
|
||
COPY --from=ephemeral pyproject.toml . | ||
COPY --from=ephemeral uv.lock . | ||
RUN chown -R build:build /code | ||
|
||
USER build | ||
ENV UV_LINK_MODE=copy | ||
RUN uv sync --frozen --no-install-project && rm pyproject.toml uv.lock | ||
|
||
ENTRYPOINT ["uv", "run", "dev-cmd"] |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All this yaml-thrash and the paired intro of
scripts/docker/uv.py
was just so I could test the install.sh changes locally viauvrc docker -- --image alpine test -- -vvsk test_installer
(whereuvrc
is my alias foruv run dev-cmd
). The upshot of streamlined yaml / an easy way to repro CI locally is, of course, generally good.