Skip to content

Commit

Permalink
Merge pull request #1 from Qetesh/Publishing-Docker-images
Browse files Browse the repository at this point in the history
Publishing docker images
  • Loading branch information
Qetesh authored May 22, 2024
2 parents 51a325e + 748a83e commit 9ff84f7
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 7 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: CDN_bestIP docker image

on:
release:
types: [ published ]

jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Check out the repo
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
# list of Docker images to use as base name for tags
images: |
ghcr.io/${{ github.repository }}
# generate Docker tags based on the following events/attributes
tags: |
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/') }}
type=pep440,pattern={{raw}},enable=${{ startsWith(github.ref, 'refs/tags/') }}
- name: Build and push Docker image
id: push
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
42 changes: 38 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# CDN_bestIP
[![CDN_bestIP docker image](https://github.com/Qetesh/CDN_bestIP/actions/workflows/docker-image.yml/badge.svg?branch=main&event=workflow_run)](https://github.com/Qetesh/CDN_bestIP/actions/workflows/docker-image.yml)

[中文版本](README.md) | [English Version](README_EN.md)

Expand Down Expand Up @@ -33,7 +34,34 @@ CDN_bestIP 是一个使用 Python 编写的项目,通过[官方链接](https:/
> docker安装 https://docs.docker.com/engine/install/
>
> docker compose安装 https://docs.docker.com/compose/install/
```
docker run -d --name ghcr.io/qetesh/cdn_bestip:latest \
--restart always \
-e domain='example.com' \
-e record_name='cdn' \
-e api_key='ccccccccccccccccccccccccccccccc' \
-e email='[email protected]' \
-e stUrl='https://xxxxxxx.cloudfront.net/100MB.test' \
cdn_bestip
```

使用 Docker Compose 运行,可参考[docker-compose.yml](docker-compose.yml)。需先设置`.env`文件:
.env
```shell
domain = 'example.com'
record_name = 'cdn'
api_key = 'ccccccccccccccccccccccccccccccc'
email = '[email protected]'
stUrl = 'https://xxxxxxx.cloudfront.net/100MB.test'
```

```shell
docker compose build
docker compose up -d
```

<details>
<summary>Docker 本地构建运行</summary>
该项目可以在 Docker 环境中运行。你可以使用提供的 Dockerfile 构建镜像,并通过 Docker 或 Docker Compose 运行。

首先,使用以下命令构建 Docker 镜像:
Expand Down Expand Up @@ -70,8 +98,10 @@ stUrl = 'https://xxxxxxx.cloudfront.net/100MB.test'
docker compose build
docker compose up -d
```
---
</details>

<details>
<summary>使用方法-本地运行</summary>
## 使用方法-本地运行

### 1. 克隆项目
Expand All @@ -81,7 +111,6 @@ docker compose up -d
```shell
git clone https://github.com/qetesh/CDN_bestIP.git
```

### 2. 安装依赖

安装python3、pip3:
Expand Down Expand Up @@ -111,6 +140,7 @@ export domain='example.com' record_name='cdn' api_key='ccccccccccccccccccccccccc
```shell
python3 main.py
```
</details>

---

Expand All @@ -120,8 +150,12 @@ python3 main.py
- https://www.maxmind.com

## Todo
- [ ] CDN - CloudFlare 测试添加
- [ ] DNS服务器接入
### CDN
- [x] aws CloudFront
- [ ] CloudFlare
### DNS服务商
- [x] CloudFlare
- [ ] DNSPod

## 贡献

Expand Down
14 changes: 14 additions & 0 deletions docker-compose-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: '3.3'
services:
cdn_bestip:
build: ./
container_name: cdn_bestip
image: cdn_bestip
restart: always
environment:
TZ: Asia/Shanghai
domain: $domain
record_name: $record_name
api_key: $api_key
email: $email
stUrl: $stUrl
5 changes: 2 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
version: '3.3'
services:
awsCloudFront_AutoUpdate:
build: ./
cdn_bestip:
container_name: cdn_bestip
image: cdn_bestip
image: ghcr.io/qetesh/cdn_bestip:latest
restart: always
environment:
TZ: Asia/Shanghai
Expand Down

0 comments on commit 9ff84f7

Please sign in to comment.