Skip to content

Commit 903f54c

Browse files
committed
feat: initial attempt on packaging ananta
1 parent b11a4b7 commit 903f54c

File tree

5 files changed

+163
-0
lines changed

5 files changed

+163
-0
lines changed

.github/dependabot.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "docker"
9+
directory: "/"
10+
schedule:
11+
interval: "weekly"
12+
13+
- package-ecosystem: "github-actions"
14+
directory: "/"
15+
schedule:
16+
interval: "weekly"
17+
18+
- package-ecosystem: "pip"
19+
directory: "/"
20+
schedule:
21+
interval: "weekly"
22+
23+
- package-ecosystem: "uv"
24+
directory: "/"
25+
schedule:
26+
interval: "weekly"

.github/workflows/ananta.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: ananta Image CI
2+
on:
3+
push:
4+
branches:
5+
- 'master'
6+
paths:
7+
- '.github/workflows/ananta.yml'
8+
- 'docker-entrypoint.sh'
9+
- 'Dockerfile'
10+
schedule:
11+
- cron: "0 5 1-31/10 * *"
12+
workflow_dispatch:
13+
14+
env:
15+
ananta_repo: ${{ secrets.DOCKERHUB_USERNAME }}/ananta
16+
17+
jobs:
18+
ananta:
19+
runs-on: ubuntu-latest
20+
steps:
21+
-
22+
name: Set up QEMU
23+
uses: docker/setup-qemu-action@v3
24+
-
25+
name: Set up Docker Buildx
26+
uses: docker/setup-buildx-action@v3
27+
-
28+
name: Login to Docker Hub
29+
uses: docker/login-action@v3
30+
with:
31+
username: ${{ secrets.DOCKERHUB_USERNAME }}
32+
password: ${{ secrets.DOCKERHUB_TOKEN }}
33+
-
34+
name: Build and push
35+
uses: docker/build-push-action@v6
36+
with:
37+
push: true
38+
platforms: linux/amd64,linux/arm64
39+
tags: ${{ env.ananta_repo }}:latest
40+
cache-from: type=gha
41+
cache-to: type=gha,mode=max
42+
43+
-
44+
name: Inspect image
45+
run: |
46+
docker buildx imagetools inspect ${{ env.ananta_repo }}:latest \
47+
| grep -Po '[^ \r\n\t\v]+@sha256:[a-z0-9]+' | xargs -r -t -n 1 docker buildx imagetools inspect --raw
48+
-
49+
name: Run Trivy vulnerability scanner
50+
uses: aquasecurity/trivy-action@0.30.0
51+
with:
52+
image-ref: "${{ env.ananta_repo }}:latest"
53+
format: 'table'

Dockerfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# syntax=docker/dockerfile:1
2+
3+
FROM mirror.gcr.io/icecodexi/python:debian-nonroot AS build
4+
RUN uv tool install 'ananta[speed]'
5+
6+
7+
FROM mirror.gcr.io/icecodexi/bash-toybox:latest AS assets
8+
FROM gcr.io/distroless/python3:latest
9+
COPY --link --chmod=0755 ./docker-entrypoint.sh /usr/local/bin/
10+
# toybox + bash(ash) + catatonit
11+
COPY --link --from=assets /usr/bin/ /usr/bin/
12+
COPY --link --from=build /home/nonroot/.local/ /home/nonroot/.local/
13+
14+
SHELL ["/usr/bin/bash", "-o", "pipefail", "-c"]
15+
RUN rm -rf /bin/ && ln -sf /usr/bin /bin
16+
17+
USER nonroot:nonroot
18+
WORKDIR /home/nonroot/
19+
ENV TZ=Asia/Taipei
20+
ENV PATH="/home/nonroot/.local/bin:${PATH}"
21+
22+
ENTRYPOINT [ "/usr/local/bin/docker-entrypoint.sh" ]

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# How to start
2+
3+
```shell
4+
docker pull icecodexi/ananta:latest
5+
mkdir -p "${HOME}/.ssh/"
6+
find "${HOME}/.ssh/" -type f -print0 | xargs -0 -r chmod 600
7+
touch "$(pwd)/hosts.csv"
8+
9+
if [[ "$UID" -eq '0' ]]; then
10+
_run_as_root='--user root'
11+
fi
12+
docker run --rm --interactive --tty \
13+
${_run_as_root} \
14+
--volume /etc/localtime:/etc/localtime:ro \
15+
--volume "${HOME}/.ssh/:/home/nonroot/.ssh/:ro" \
16+
--volume "$(pwd)/hosts.csv:/home/nonroot/hosts.csv:ro" \
17+
--cpu-shares 512 --memory 512M --memory-swap 512M \
18+
--security-opt no-new-privileges \
19+
icecodexi/ananta:latest \
20+
--help
21+
```

docker-entrypoint.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env bash
2+
set -e -o pipefail
3+
4+
cd /home/nonroot/.ssh/ || exit 1
5+
6+
args=()
7+
while [[ $# -gt 0 ]]; do
8+
case "$1" in
9+
-[kK]|--default-key)
10+
_DEFAULT_KEY="$2"
11+
# Modify the key path to be under /home/nonroot/.ssh/
12+
key_file=$(basename "$_DEFAULT_KEY")
13+
# Add the modified parameter
14+
args+=("$1" "/home/nonroot/.ssh/$key_file")
15+
shift 2
16+
;;
17+
# Keep other parameters unchanged
18+
-[nNsSeEcCvV]|--no-color|--separate-output|--allow-empty-line|--allow-cursor-control|--version)
19+
args+=("$1")
20+
shift
21+
;;
22+
-[tTwW]|--host-tags|--terminal-width)
23+
args+=("$1" "$2")
24+
shift 2
25+
;;
26+
[!-]*)
27+
_HOSTS_CSV="$1"
28+
# Modify the hosts.csv path to be under /home/nonroot/
29+
hosts_file=$(basename "$_HOSTS_CSV")
30+
# Add the modified parameter
31+
args+=("/home/nonroot/$hosts_file")
32+
shift
33+
# Stop processing remaining arguments
34+
args+=("$@")
35+
break
36+
;;
37+
esac
38+
done
39+
40+
# Run the ananta command with the modified arguments
41+
exec catatonit -- ananta "${args[@]}"

0 commit comments

Comments
 (0)