mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-19 12:50:51 +08:00
Add Docker support with CI/CD workflow and usage instructions
- Added `.github/workflows/docker-image.yml` for automated Docker image build and push on version tags. - Created `Dockerfile` to containerize the application. - Updated README with instructions for running the application using Docker.
This commit is contained in:
42
.github/workflows/docker-image.yml
vendored
Normal file
42
.github/workflows/docker-image.yml
vendored
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
name: docker-image
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- v*
|
||||||
|
|
||||||
|
env:
|
||||||
|
APP_NAME: CLIProxyAPI
|
||||||
|
DOCKERHUB_REPO: eceasy/cli-proxy-api
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
docker:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v3
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
- name: Login to DockerHub
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
- name: Generate App Version
|
||||||
|
run: echo APP_VERSION=`git describe --tags --always` >> $GITHUB_ENV
|
||||||
|
- name: Build and push
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
platforms: |
|
||||||
|
linux/amd64
|
||||||
|
linux/arm64
|
||||||
|
push: true
|
||||||
|
build-args: |
|
||||||
|
APP_NAME=${{ env.APP_NAME }}
|
||||||
|
APP_VERSION=${{ env.APP_VERSION }}
|
||||||
|
tags: |
|
||||||
|
${{ env.DOCKERHUB_REPO }}:latest
|
||||||
|
${{ env.DOCKERHUB_REPO }}:${{ env.APP_VERSION }}
|
||||||
23
Dockerfile
Normal file
23
Dockerfile
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
FROM golang:1.24-alpine AS builder
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY go.mod go.sum ./
|
||||||
|
|
||||||
|
RUN go mod download
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
RUN CGO_ENABLED=0 GOOS=linux go build -o ./CLIProxyAPI ./cmd/server/
|
||||||
|
|
||||||
|
FROM alpine:3.22.0
|
||||||
|
|
||||||
|
RUN mkdir /CLIProxyAPI
|
||||||
|
|
||||||
|
COPY --from=builder ./app/CLIProxyAPI /CLIProxyAPI/CLIProxyAPI
|
||||||
|
|
||||||
|
WORKDIR /CLIProxyAPI
|
||||||
|
|
||||||
|
EXPOSE 8317
|
||||||
|
|
||||||
|
CMD ["./CLIProxyAPI"]
|
||||||
14
README.md
14
README.md
@@ -212,6 +212,20 @@ The server will relay the `loadCodeAssist`, `onboardUser`, and `countTokens` req
|
|||||||
> This feature only allows local access because I couldn't find a way to authenticate the requests.
|
> This feature only allows local access because I couldn't find a way to authenticate the requests.
|
||||||
> I hardcoded `127.0.0.1` into the load balancing.
|
> I hardcoded `127.0.0.1` into the load balancing.
|
||||||
|
|
||||||
|
## Run with Docker
|
||||||
|
|
||||||
|
Run the following command to login:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run --rm -p 8085:8085 -v /path/to/your/config.yaml:/CLIProxyAPI/config.yaml -v /path/to/your/auth-dir:/root/.cli-proxy-api eceasy/cli-proxy-api:latest /CLIProxyAPI/CLIProxyAPI --login
|
||||||
|
```
|
||||||
|
|
||||||
|
Run the following command to start the server:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run --rm -p 8317:8317 -v /path/to/your/config.yaml:/CLIProxyAPI/config.yaml -v /path/to/your/auth-dir:/root/.cli-proxy-api eceasy/cli-proxy-api:latest
|
||||||
|
```
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
Contributions are welcome! Please feel free to submit a Pull Request.
|
Contributions are welcome! Please feel free to submit a Pull Request.
|
||||||
|
|||||||
Reference in New Issue
Block a user