forked from morganzero/cloudflare-companion
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
1,286 additions
and
207 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 |
---|---|---|
@@ -1,42 +1,38 @@ | ||
# Builder image | ||
FROM debian:bookworm-slim AS builder | ||
|
||
LABEL maintainer="inean <inean.es+contact@gmail.com>" | ||
|
||
# hadolint ignore=DL3008 | ||
RUN <<EOF | ||
apt-get update | ||
apt-get install -y --no-install-recommends ca-certificates curl | ||
EOF | ||
|
||
# Install and initialize rye | ||
ENV RYE_HOME="/opt/rye" | ||
ENV PATH="$RYE_HOME/shims:$PATH" | ||
|
||
# hadolint ignore=DL4006 | ||
RUN <<EOF | ||
curl -sSf https://rye.astral.sh/get | RYE_INSTALL_OPTION="--yes" bash | ||
rye config --set-bool behavior.global-python=true | ||
rye config --set-bool behavior.use-uv=true | ||
EOF | ||
|
||
# Copy project | ||
WORKDIR /opt | ||
# Download the latest installer | ||
ADD https://astral.sh/uv/install.sh uv-installer.sh | ||
|
||
# Find pinned python version on current project and download it | ||
COPY ./.python-version ./ | ||
RUN rye pin "$(cat .python-version)" | ||
# Run the installer then remove it | ||
RUN sh uv-installer.sh | ||
|
||
# Devcontainer image | ||
FROM mcr.microsoft.com/vscode/devcontainers/base:bookworm | ||
COPY --from=builder /opt/rye /opt/rye | ||
|
||
ENV RYE_HOME="/opt/rye" | ||
ENV PATH="$RYE_HOME/shims:$PATH" | ||
# Set uv | ||
ENV UV_HOME="/opt/.cargo/bin" | ||
ENV PATH="$UV_HOME/:$PATH" | ||
COPY --from=builder /root/.cargo/bin/uv $UV_HOME/uv | ||
|
||
# Configure uv behavior | ||
ENV PYTHONUNBUFFERED=True | ||
ENV UV_LINK_MODE=copy | ||
|
||
# Use rye as the default python and uv as default package manager | ||
RUN <<EOF | ||
rye config --set-bool behavior.global-python=true | ||
rye config --set-bool behavior.use-uv=true | ||
EOF | ||
# Set workdir | ||
WORKDIR /opt | ||
# Define version of python interpreter to use | ||
COPY ./.python-version ./ | ||
# Pin and install python interpreter | ||
RUN uv python pin "$(cat .python-version)" | ||
|
||
RUN chown -R vscode $RYE_HOME | ||
# let vscode user to use uv | ||
RUN chown -R vscode $UV_HOME |
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 was deleted.
Oops, something went wrong.
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,52 @@ | ||
--- | ||
name: Setup uv | ||
description: Install Python with uv | ||
|
||
inputs: | ||
python-version: | ||
description: Python version | ||
required: false | ||
uv-sync-options: | ||
description: Options to pass to uv sync | ||
required: false | ||
default: "--dev --all-extras" | ||
|
||
outputs: | ||
python-version: | ||
description: The Python version used | ||
value: ${{ steps.extract-python-version.outputs.python-version }} | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Extract Python Version | ||
id: extract-python-version | ||
uses: ./.github/actions/extract-python-version | ||
with: | ||
python-version: ${{ inputs.python-version }} | ||
|
||
- name: Install uv | ||
uses: astral-sh/setup-uv@v2 | ||
|
||
- name: Pin Python Version | ||
run: | | ||
export PYTHONUNBUFFERED=True | ||
uv python pin ${{ steps.extract-python-version.outputs.python-version }} | ||
shell: bash | ||
|
||
- name: Install dependencies | ||
run: uv sync ${{ inputs.uv-sync-options}} | ||
shell: bash | ||
|
||
- name: Normalize UV Sync Options | ||
id: normalize-uv-sync-options | ||
run: | | ||
NORMALIZED_UV_SYNC_OPTIONS=$(echo "${{ inputs.uv-sync-options }}" | tr '[:upper:]' '[:lower:]' | tr -c '[:alnum:]' '-') | ||
echo "normalized-uv-sync-options=$NORMALIZED_UV_SYNC_OPTIONS" >> $GITHUB_ENV | ||
shell: bash | ||
|
||
- uses: actions/cache@v4 | ||
id: cache-uv | ||
with: | ||
path: ~/.cache/uv | ||
key: ${{ runner.os }}-python-${{ steps.extract-python-version.outputs.python-version }}-uv-sync-${{ env.normalized-uv-sync-options }} |
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 |
---|---|---|
@@ -1 +1 @@ | ||
3.10 | ||
3.11 |
Oops, something went wrong.