Skip to content

Commit 2477fa8

Browse files
committed
ci: try to automated Docker image push to Docker Hub via GitHub Actions
1 parent 85f7c1f commit 2477fa8

File tree

4 files changed

+52
-5
lines changed

4 files changed

+52
-5
lines changed

.github/workflows/build-docker.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Build and Push Docker Image
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
7+
jobs:
8+
build-and-push:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout repository
12+
uses: actions/checkout@v4
13+
14+
- name: Set up QEMU
15+
uses: docker/setup-qemu-action@v3
16+
17+
- name: Set up Docker Buildx
18+
uses: docker/setup-buildx-action@v3
19+
20+
- name: Login to Docker Hub
21+
uses: docker/login-action@v3
22+
with:
23+
username: ${{ secrets.DOCKERHUB_USERNAME }}
24+
password: ${{ secrets.DOCKERHUB_TOKEN }}
25+
26+
- name: Build and push
27+
uses: docker/build-push-action@v5
28+
with:
29+
context: .
30+
push: true
31+
tags: 006lp/akashchat-api-go:latest

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build stage
2-
FROM golang:1.21-alpine AS builder
2+
FROM golang:1.24-alpine AS builder
33

44
# Set working directory
55
WORKDIR /app

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,22 @@ go run cmd/server/main.go
4646

4747
### 使用 Docker
4848

49+
#### 从 Docker Hub 拉取镜像
50+
51+
```bash
52+
docker pull 006lp/akashchat-api-go:latest
53+
```
54+
55+
#### 本地构建
56+
4957
1. 构建 Docker 镜像:
5058
```bash
51-
docker build -t akashchat-api-go .
59+
docker build -t 006lp/akashchat-api-go .
5260
```
5361

5462
2. 运行容器:
5563
```bash
56-
docker run -p 16571:16571 akashchat-api-go
64+
docker run -p 16571:16571 006lp/akashchat-api-go
5765
```
5866

5967
## API 使用

README_EN.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,22 @@ The server will start on `localhost:16571` by default.
4646

4747
### Using Docker
4848

49+
#### Pull from Docker Hub
50+
51+
```bash
52+
docker pull 006lp/akashchat-api-go:latest
53+
```
54+
55+
#### Build Locally
56+
4957
1. Build the Docker image:
5058
```bash
51-
docker build -t akashchat-api-go .
59+
docker build -t 006lp/akashchat-api-go .
5260
```
5361

5462
2. Run the container:
5563
```bash
56-
docker run -p 16571:16571 akashchat-api-go
64+
docker run -p 16571:16571 006lp/akashchat-api-go
5765
```
5866

5967
## API Usage

0 commit comments

Comments
 (0)