Skip to content

Commit

Permalink
fix:更换为无CGO编译依赖sqlite
Browse files Browse the repository at this point in the history
  • Loading branch information
huangyanming committed Mar 27, 2023
1 parent 8436681 commit 090fbf4
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/go-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ jobs:
github_token: ${{ secrets.GITHUB_TOKEN }} # 一个默认的变量,用来实现往 Release 中添加文件
goos: ${{ matrix.goos }}
goarch: ${{ matrix.goarch }}
goversion: 1.17 # 可以指定编译使用的 Golang 版本
goversion: 1.18 # 可以指定编译使用的 Golang 版本
binary_name: "chatgpt-web" # 可以指定二进制文件的名称
extra_files: ./resources ./static README.md config.dev.json # 需要包含的额外文件
retry: 10
overwrite: true
pre_command: "apt-get update && apt-get install --no-install-recommends -y gcc musl-dev && export CGO_ENABLED=1 && go mod tidy && go mod download"
pre_command: go mod tidy && go mod download

8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# 使用 golang 官方镜像提供 Go 运行环境,并且命名为 builder 以便后续引用
FROM golang:1.17-alpine AS builder
FROM golang:1.18-alpine AS builder

# 启用 Go Modules 并设置 GOPROXY
ENV GO111MODULE on
Expand All @@ -9,7 +9,7 @@ ENV GOPROXY https://goproxy.cn
#RUN apk --no-cache add git

# 安装gcc
RUN apk --no-cache add gcc musl-dev
#RUN apk --no-cache add gcc musl-dev

# 设置工作目录
WORKDIR /app
Expand All @@ -21,13 +21,13 @@ COPY . .
RUN go mod tidy && go mod download

# 构建二进制文件,设置了一些额外参数以便可以在 Alpine 中运行它
RUN CGO_ENABLED=1 GOOS=linux go build -a -installsuffix cgo -o chatgpt-web
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o chatgpt-web

# 下面是第二阶段的镜像构建,和之前保持一致
FROM alpine:latest

# 安装相关软件和库
RUN apk update && apk add --no-cache bash supervisor ca-certificates sqlite
RUN apk update && apk add --no-cache bash supervisor ca-certificates

# 设置工作目录
WORKDIR /app
Expand Down
15 changes: 11 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,33 +1,40 @@
module github.com/869413421/chatgpt-web

go 1.17
go 1.18

require (
github.com/alecthomas/kong v0.7.1
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/gin-gonic/gin v1.7.7
github.com/glebarez/sqlite v1.7.0
github.com/sashabaranov/go-gpt3 v1.3.0
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519
golang.org/x/net v0.8.0
gorm.io/driver/sqlite v1.4.4
gorm.io/gorm v1.24.6
)

require (
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/glebarez/go-sqlite v1.20.3 // indirect
github.com/go-playground/locales v0.13.0 // indirect
github.com/go-playground/universal-translator v0.17.0 // indirect
github.com/go-playground/validator/v10 v10.4.1 // indirect
github.com/golang/protobuf v1.3.3 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/json-iterator/go v1.1.9 // indirect
github.com/leodido/go-urn v1.2.0 // indirect
github.com/mattn/go-isatty v0.0.12 // indirect
github.com/mattn/go-sqlite3 v1.14.16 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230126093431-47fa9a501578 // indirect
github.com/ugorji/go/codec v1.1.7 // indirect
golang.org/x/sys v0.6.0 // indirect
gopkg.in/yaml.v2 v2.2.8 // indirect
modernc.org/libc v1.22.2 // indirect
modernc.org/mathutil v1.5.0 // indirect
modernc.org/memory v1.5.0 // indirect
modernc.org/sqlite v1.20.3 // indirect
)
2 changes: 1 addition & 1 deletion pkg/model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package model
import (
"time"

"gorm.io/driver/sqlite"
"github.com/glebarez/sqlite"
"gorm.io/gorm"
gloger "gorm.io/gorm/logger"

Expand Down

0 comments on commit 090fbf4

Please sign in to comment.