Sign inSign up

wlkc/oracle-claimer

By wlkc

•Updated 13 days ago

Image
0

144

wlkc/oracle-claimer repository overview

⁠Configuration / 配置说明

中文⁠ | English⁠


⁠中文

⁠环境变量

在项目目录创建或修改 .env:

# OCI API 账号
OCI_USER_ID=ocid1.user.oc1..example
OCI_TENANCY_ID=ocid1.tenancy.oc1..example
OCI_FINGERPRINT=11:22:33:44:55:66:77:88
OCI_REGION=ap-tokyo-1

# 本地直接运行时使用;Compose 会覆盖为 /run/secrets/oci_api_key.pem
OCI_KEY_FILE=./app/oci_api_key.pem
# OCI_KEY_PASSPHRASE=私钥密码

# 实例配置
OCI_AD=xxxx:AP-TOKYO-1-AD-1
OCI_SHAPE=VM.Standard.A1.Flex
OCI_OCPUS=2
OCI_MEMORY_IN_GB=12
OCI_BOOT_VOLUME_SIZE_IN_GBS=50
OCI_SUBNET_ID=ocid1.subnet.oc1.ap-tokyo-1.example
OCI_IMAGE_ID=ocid1.image.oc1.ap-tokyo-1.example
OCI_SSH_PUBLIC_KEY="ssh-rsa AAAAB3Nza... user@example"

# IPv6,可选;留空或删除即不请求 IPv6 地址
OCI_IPV6_SUBNET_CIDR=2603:c021:8000:e8ae:0000:0000:0000:0000/64

# 每轮基础等待时间,实际等待范围为 88-92 秒
RETRY_INTERVAL=90

# Telegram,可选
TELEGRAM_BOT_TOKEN=123456789:example-token
TELEGRAM_CHAT_ID=123456789

# 代理,可选
# HTTPS_PROXY=http://host.docker.internal:7890
# HTTP_PROXY=http://host.docker.internal:7890

含空格的值必须加引号,尤其是 OCI_SSH_PUBLIC_KEY。否则执行 source .env 时,Shell 会把公钥后半部分当成命令。

⁠参数表
参数必填默认值说明
OCI_USER_ID是无OCI 用户 OCID
OCI_TENANCY_ID是无OCI 租户 OCID,同时用作实例 Compartment OCID
OCI_FINGERPRINT是无OCI API Key 指纹
OCI_REGION是无OCI 区域,例如 ap-tokyo-1
OCI_KEY_FILE是无OCI API 私钥路径;Compose 会覆盖容器内路径
OCI_KEY_PASSPHRASE否空私钥密码
OCI_AD否空指定可用区;为空时轮询当前区域的全部 AD
OCI_SHAPE否VM.Standard.A1.FlexOCI 实例规格
OCI_OCPUS否2OCPU 数量
OCI_MEMORY_IN_GB否12内存大小,单位 GiB
OCI_BOOT_VOLUME_SIZE_IN_GBS否50启动盘大小,单位 GB
OCI_SUBNET_ID是无VNIC 所属子网 OCID
OCI_IMAGE_ID是无系统镜像 OCID
OCI_SSH_PUBLIC_KEY是无写入实例的 SSH 公钥,含空格时必须加引号
OCI_IPV6_SUBNET_CIDR否空IPv6 子网 CIDR;配置后请求 IPv6 地址
RETRY_INTERVAL否90每轮基础等待秒数,实际随机范围为该值 ±2 秒
TELEGRAM_BOT_TOKEN否空Telegram Bot Token
TELEGRAM_CHAT_ID否空Telegram 接收方 Chat ID
HTTPS_PROXY否空HTTPS 代理地址,Telegram 和支持标准代理变量的请求使用
HTTP_PROXY否空HTTP 代理地址
https_proxy否空HTTPS_PROXY 的小写形式
http_proxy否空HTTP_PROXY 的小写形式

只有同时配置 TELEGRAM_BOT_TOKEN 和 TELEGRAM_CHAT_ID 才会发送 Telegram 通知。

遇到 OCI 429 TooManyRequests 时,可先提高 RETRY_INTERVAL,例如设置为 120 或 180。

⁠Docker Compose 配置

使用已发布镜像时,可使用以下 docker-compose.yaml:

services:
  oracle-arm-claimer:
    image: wlkc/oracle-claimer
    container_name: oracle-arm-claimer
    env_file:
      - .env
    environment:
      OCI_KEY_FILE: /run/secrets/oci_api_key.pem
    volumes:
      - ./app/oci_api_key.pem:/run/secrets/oci_api_key.pem:ro
    restart: unless-stopped
    stop_grace_period: 30s

⁠English

⁠Environment Variables

Create or update .env in the project directory:

# OCI API account
OCI_USER_ID=ocid1.user.oc1..example
OCI_TENANCY_ID=ocid1.tenancy.oc1..example
OCI_FINGERPRINT=11:22:33:44:55:66:77:88
OCI_REGION=ap-tokyo-1

# Used when running locally; Compose overrides this with /run/secrets/oci_api_key.pem
OCI_KEY_FILE=./app/oci_api_key.pem
# OCI_KEY_PASSPHRASE=private-key-passphrase

# Instance configuration
OCI_AD=xxxx:AP-TOKYO-1-AD-1
OCI_SHAPE=VM.Standard.A1.Flex
OCI_OCPUS=2
OCI_MEMORY_IN_GB=12
OCI_BOOT_VOLUME_SIZE_IN_GBS=50
OCI_SUBNET_ID=ocid1.subnet.oc1.ap-tokyo-1.example
OCI_IMAGE_ID=ocid1.image.oc1.ap-tokyo-1.example
OCI_SSH_PUBLIC_KEY="ssh-rsa AAAAB3Nza... user@example"

# Optional IPv6 configuration; leave empty or remove it to disable IPv6 assignment
OCI_IPV6_SUBNET_CIDR=2603:c021:8000:e8ae:0000:0000:0000:0000/64

# Base delay between rounds; the actual delay is randomized between 88 and 92 seconds
RETRY_INTERVAL=90

# Optional Telegram notification
TELEGRAM_BOT_TOKEN=123456789:example-token
TELEGRAM_CHAT_ID=123456789

# Optional proxy
# HTTPS_PROXY=http://host.docker.internal:7890
# HTTP_PROXY=http://host.docker.internal:7890

Values containing spaces must be quoted, especially OCI_SSH_PUBLIC_KEY. Otherwise, when you run source .env, the shell interprets the remainder of the public key as a command.

⁠Parameter Reference
VariableRequiredDefaultDescription
OCI_USER_IDYesNoneOCI user OCID
OCI_TENANCY_IDYesNoneOCI tenancy OCID; also used as the instance compartment OCID
OCI_FINGERPRINTYesNoneOCI API key fingerprint
OCI_REGIONYesNoneOCI region, for example ap-tokyo-1
OCI_KEY_FILEYesNonePath to the OCI API private key; Compose overrides the path inside the container
OCI_KEY_PASSPHRASENoEmptyPrivate-key passphrase
OCI_ADNoEmptyAvailability domain; when empty, all ADs in the current region are tried
OCI_SHAPENoVM.Standard.A1.FlexOCI instance shape
OCI_OCPUSNo2Number of OCPUs
OCI_MEMORY_IN_GBNo12Memory size in GiB
OCI_BOOT_VOLUME_SIZE_IN_GBSNo50Boot volume size in GB
OCI_SUBNET_IDYesNoneOCID of the VNIC subnet
OCI_IMAGE_IDYesNoneOperating system image OCID
OCI_SSH_PUBLIC_KEYYesNoneSSH public key added to the instance; quote it because it contains spaces
OCI_IPV6_SUBNET_CIDRNoEmptyIPv6 subnet CIDR; an IPv6 address is requested when configured
RETRY_INTERVALNo90Base delay between rounds in seconds; the actual delay is randomized by ±2 seconds
TELEGRAM_BOT_TOKENNoEmptyTelegram bot token
TELEGRAM_CHAT_IDNoEmptyTelegram recipient chat ID
HTTPS_PROXYNoEmptyHTTPS proxy used by Telegram and requests that support standard proxy variables
HTTP_PROXYNoEmptyHTTP proxy address
https_proxyNoEmptyLowercase form of HTTPS_PROXY
http_proxyNoEmptyLowercase form of HTTP_PROXY

Telegram notifications are sent only when both TELEGRAM_BOT_TOKEN and TELEGRAM_CHAT_ID are configured.

If OCI returns 429 TooManyRequests, increase RETRY_INTERVAL to a value such as 120 or 180.

⁠Docker Compose Configuration

When using the published image, use the following docker-compose.yaml:

services:
  oracle-arm-claimer:
    image: wlkc/oracle-claimer
    container_name: oracle-arm-claimer
    env_file:
      - .env
    environment:
      OCI_KEY_FILE: /run/secrets/oci_api_key.pem
    volumes:
      - ./app/oci_api_key.pem:/run/secrets/oci_api_key.pem:ro
    restart: unless-stopped
    stop_grace_period: 30s

Tag summary

Content type

Image

Digest

sha256:7bb1511dd…

Size

6.9 MB

Last updated

13 days ago

docker pull wlkc/oracle-claimer