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.
Merge pull request #1 from inean/asyncio
Move logic to an asyncio based one
- Loading branch information
Showing
49 changed files
with
2,686 additions
and
842 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,4 @@ | ||
--container-architecture linux/arm64 | ||
--container-options --security-opt label:disable | ||
--action-offline-mode | ||
--artifact-server-path /tmp |
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,42 @@ | ||
# Builder image | ||
FROM debian:bookworm-slim AS builder | ||
|
||
# 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 | ||
|
||
# Find pinned python version on current project and download it | ||
COPY ./.python-version ./ | ||
RUN rye pin "$(cat .python-version)" | ||
|
||
# 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" | ||
ENV PYTHONUNBUFFERED=True | ||
|
||
# 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 | ||
|
||
RUN chown -R vscode $RYE_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. For config options | ||
{ | ||
"name": "CloudFlare DNS Updater", | ||
"shutdownAction": "stopCompose", | ||
"workspaceFolder": "/workspace", | ||
|
||
// Docker Compose Options | ||
"dockerComposeFile": "docker-compose.yml", | ||
"service": "devcontainer", | ||
|
||
"features": { | ||
"ghcr.io/dhoeric/features/hadolint:1": { }, | ||
"ghcr.io/devcontainers/features/docker-outside-of-docker": { | ||
"postCreateCommand": "sudo usermod -aG docker vscode" | ||
} | ||
}, | ||
"customizations": { | ||
"vscode": { | ||
"extensions": [ | ||
// Python exrtensions | ||
"charliermarsh.ruff", | ||
"codezombiech.gitignore", | ||
"exiasr.hadolint", | ||
"kevinrose.vsc-python-indent", | ||
"mosapride.zenkaku", | ||
"ms-azuretools.vscode-docker", | ||
"ms-python.python", | ||
"ms-vscode-remote.remote-containers", | ||
"njpwerner.autodocstring", | ||
"shardulm94.trailing-spaces", | ||
"usernamehw.errorlens", | ||
"yzhang.markdown-all-in-one" | ||
|
||
// Project related extensions | ||
], | ||
"settings": { | ||
"python.defaultInterpreterPath": "${containerWorkspaceFolder}/.venv/bin/python", | ||
"[python]": { | ||
"editor.codeActionsOnSave": { | ||
"source.fixAll": "explicit", | ||
"source.organizeImports": "explicit" | ||
}, | ||
"editor.defaultFormatter": "charliermarsh.ruff", | ||
"editor.formatOnSave": true, | ||
"editor.rulers": [ | ||
88 | ||
] | ||
}, | ||
"terminal.integrated.defaultProfile.linux": "zsh", | ||
"terminal.integrated.profiles.linux": { | ||
"zsh": { | ||
"path": "/bin/zsh" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
|
||
// Forward traefik dashboard port | ||
"forwardPorts": [ 8080 ], | ||
|
||
// Use 'postCreateCommand' to run commands after the container is created. | ||
"postCreateCommand": "rye sync -f", | ||
|
||
// use 'postStartCommand' to run commands after the container is started. | ||
"postStartCommand": "which git && rye run pre-commit install", | ||
|
||
// Run vscode-server as non-root user | ||
"containerUser": "vscode" | ||
|
||
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. | ||
//"remoteUser": "root" | ||
} |
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,51 @@ | ||
--- | ||
version: '3.8' | ||
name: "cloudflare-updater" | ||
services: | ||
devcontainer: | ||
build: | ||
context: .. | ||
dockerfile: .devcontainer/Dockerfile | ||
environment: | ||
- PYTHONUNBUFFERED=1 | ||
volumes: | ||
- ..:/workspace:cached | ||
cap_add: | ||
- SYS_ADMIN | ||
- AUDIT_WRITE | ||
security_opt: | ||
- seccomp=unconfined | ||
- label=disable | ||
- apparmor=unconfined | ||
depends_on: | ||
- traefik | ||
- whoami | ||
# Override the default command so things don't shut down after the process ends. | ||
command: sleep infinity | ||
labels: | ||
- "traefik.enable=false" | ||
|
||
traefik: | ||
image: traefik:v3.1 | ||
container_name: traefik | ||
command: | ||
- "--api.insecure=true" | ||
- "--providers.docker=true" | ||
- "--entrypoints.web.address=:80" | ||
ports: | ||
- "8080:8080" | ||
- "80:80" | ||
volumes: | ||
- /var/run/docker.sock:/var/run/docker.sock | ||
cap_add: | ||
- SYS_ADMIN | ||
security_opt: | ||
- seccomp=unconfined | ||
- label=disable | ||
- apparmor=unconfined | ||
|
||
whoami: | ||
image: containous/whoami | ||
container_name: whoami | ||
labels: | ||
- "traefik.http.routers.whoami.rule=Host(`whoami.localhost`)" |
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,2 @@ | ||
examples/ | ||
src/mock.py |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,69 @@ | ||
--- | ||
name: Setup Rye | ||
description: Install Python with Rye | ||
|
||
inputs: | ||
python-version: | ||
description: Python version | ||
required: false | ||
rye-version: | ||
description: Rye version | ||
required: false | ||
default: "latest" | ||
|
||
outputs: | ||
python-version: | ||
description: The Python version to use | ||
value: ${{ steps.compute-python-version.outputs.python-version }} | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Compute Python Version | ||
id: compute-python-version | ||
run: | | ||
PYTHON_VERSION="${{ inputs.python-version }}" | ||
if [ -z "$PYTHON_VERSION" ]; then | ||
PYTHON_VERSION=$(cat .python-version) | ||
fi | ||
if [ -z "$PYTHON_VERSION" ]; then | ||
echo "No Python version specified, and no .python-version file found" | ||
exit 1 | ||
fi | ||
echo "Python version specified: $PYTHON_VERSION" | ||
echo "python-version=$PYTHON_VERSION" >> $GITHUB_OUTPUT | ||
shell: bash | ||
|
||
- name: Install Rye | ||
uses: eifinger/setup-rye@v4 | ||
with: | ||
enable-cache: true | ||
cache-prefix: ${{ steps.compute-python-version.outputs.python-version }} | ||
|
||
- name: Set Rye Config | ||
run: | | ||
rye config --set-bool behavior.global-python=true | ||
rye config --set-bool behavior.use-uv=true | ||
shell: bash | ||
|
||
- name: Pin Python Version ${{ steps.compute-python-version.outputs.python-version }} | ||
run: | | ||
export PYTHONUNBUFFERED=True | ||
rye pin ${{ steps.compute-python-version.outputs.python-version }} | ||
shell: bash | ||
|
||
- name: Install dependencies | ||
if: steps.setup-rye.outputs.cache-hit != 'true' | ||
run: | | ||
if [ -f requirements.lock ] && [ -f requirements-dev.lock ]; then | ||
rye sync --no-lock | ||
else | ||
rye sync | ||
fi | ||
shell: bash | ||
|
||
- name: Cache pre-commit | ||
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 | ||
with: | ||
path: ~/.cache/pre-commit | ||
key: pre-commit-|${{ steps.compute-python-version.outputs.python-version }}|${{ hashFiles('.pre-commit-config.yaml') }} |
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 |
---|---|---|
@@ -1,7 +1,16 @@ | ||
--- | ||
version: 2 | ||
updates: | ||
# Maintain dependencies for GitHub Actions | ||
- package-ecosystem: "github-actions" | ||
- package-ecosystem: pip | ||
directory: "/" | ||
schedule: | ||
interval: "daily" | ||
interval: weekly | ||
commit-message: | ||
prefix: "chore(rye)" | ||
|
||
- package-ecosystem: github-actions | ||
directory: / | ||
schedule: | ||
interval: weekly | ||
commit-message: | ||
prefix: "chore(github-actions)" |
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,21 @@ | ||
--- | ||
name: Actions CI | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
|
||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
lint-actions: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Lint GitHub Actions | ||
uses: eifinger/actionlint-action@v1 |
Oops, something went wrong.