Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

新增支持postgres/sqlite数据库,Dockerfile文件 #12

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/workflows/docker-alpine.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: docker-alpine-epusdt
on:
workflow_dispatch: #github页面手动触发
push:
branches: [ "main" ]
env:
IMAGE_NAME: epusdt #这是您的镜像名

jobs:
push-docker-hub:
runs-on: ubuntu-latest
env:
TZ: Asia/Shanghai
steps:
- uses: actions/checkout@v3
- name: Login
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build && Push
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:alpine
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.idea/
src/runtime/
src/.env
.DS_Store
.DS_Store
.env
22 changes: 22 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM golang:alpine AS builder

RUN apk add --no-cache --update git build-base
ENV CGO_ENABLED=1
WORKDIR /app

COPY ./src .
RUN go mod tidy \
&& go build -ldflags "-s -w" \
-o epusdt .

FROM alpine:latest AS runner
ENV TZ=Asia/Shanghai
RUN apk --no-cache add ca-certificates tzdata

WORKDIR /app
COPY --from=builder /app/static /app/static
COPY --from=builder /app/static /static
COPY --from=builder /app/epusdt .
EXPOSE 8000

ENTRYPOINT ["./epusdt" ,"http","start"]
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# 分支说明

此为自动打包docker版本

## 新增
1. 支持postgres/sqlite数据库
2. 支持设置`订单回调失败自动重试次数`

## 使用方法
配置好`.env`文件后,使用 `docker-compose up -d` 启动镜像


## Epusdt (Easy Payment Usdt)
<p align="center">
<img src="wiki/img/usdtlogo.png">
Expand Down
12 changes: 12 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: "3"
services:
epusdt:
image: annona/epusdt:alpine
restart: always
# build:
# context: .
# dockerfile: Dockerfile
volumes:
- ./env:/app/.env
ports:
- "8088:8000"
22 changes: 21 additions & 1 deletion src/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,24 @@ log_max_size=32
log_max_age=7
max_backups=3

#数据库类型,默认为mysql类型,可配置项: postgres,mysql,sqlite
db_type=sqlite

# sqlite配置
sqlite_database_filename=
sqlite_table_prefix=

# postgres配置
postgres_host=127.0.0.1
postgres_port=3306
postgres_user=mysql账号
postgres_passwd=mysql密码
postgres_database=数据库
postgres_table_prefix=
postgres_max_idle_conns=10
postgres_max_open_conns=100
postgres_max_life_time=6

# mysql配置
mysql_host=127.0.0.1
mysql_port=3306
Expand All @@ -28,6 +46,7 @@ mysql_max_idle_conns=10
mysql_max_open_conns=100
mysql_max_life_time=6


# redis配置
redis_host=127.0.0.1
redis_port=6379
Expand Down Expand Up @@ -55,6 +74,7 @@ api_auth_token=

#订单过期时间(单位分钟)
order_expiration_time=10

#订单回调失败最大重试次数
order_notice_max_retry=0
#强制汇率(设置此参数后每笔交易将按照此汇率计算,例如:6.4)
forced_usdt_rate=
12 changes: 7 additions & 5 deletions src/bootstrap/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@ import (
"github.com/assimon/luuu/util/log"
)

//Start 服务启动
// Start 服务启动
func Start() {
// 配置加载
config.Init()
// 日志加载
log.Init()
// Mysql启动
dao.MysqlInit()
// redis启动
dao.RedisInit()
// // Mysql启动
// dao.MysqlInit()
// dao.MdbTableInit()
// // redis启动
// dao.RedisInit()
dao.Init()
// 队列启动
mq.Start()
// telegram机器人启动
Expand Down
60 changes: 50 additions & 10 deletions src/go.mod
Original file line number Diff line number Diff line change
@@ -1,34 +1,74 @@
module github.com/assimon/luuu

go 1.16
go 1.20

require (
github.com/go-redis/redis/v8 v8.11.5
github.com/go-resty/resty/v2 v2.7.0
github.com/golang-module/carbon/v2 v2.0.1
github.com/google/btree v1.0.0 // indirect
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/gookit/color v1.5.0
github.com/gookit/goutil v0.4.6
github.com/gookit/validate v1.3.1
github.com/hibiken/asynq v0.23.0
github.com/json-iterator/go v1.1.12
github.com/labstack/echo/v4 v4.6.0
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/natefinch/lumberjack v2.0.0+incompatible
github.com/robfig/cron/v3 v3.0.1
github.com/satori/go.uuid v1.2.0
github.com/shopspring/decimal v1.3.1
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/cobra v1.2.1
github.com/spf13/viper v1.9.0
go.uber.org/zap v1.17.0
golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec // indirect
gopkg.in/telebot.v3 v3.0.0
gorm.io/driver/mysql v1.5.1
gorm.io/driver/postgres v1.5.2
gorm.io/gorm v1.25.7-0.20240204074919-46816ad31dde
)

require (
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/fsnotify/fsnotify v1.5.1 // indirect
github.com/go-sql-driver/mysql v1.7.0 // indirect
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/gookit/filter v1.1.2 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
github.com/jackc/pgx/v5 v5.3.1 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/labstack/gommon v0.3.0 // indirect
github.com/magiconair/properties v1.8.5 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mattn/go-sqlite3 v1.14.22 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.4.2 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml v1.9.4 // indirect
github.com/spf13/afero v1.6.0 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasttemplate v1.2.1 // indirect
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
golang.org/x/crypto v0.8.0 // indirect
golang.org/x/net v0.9.0 // indirect
golang.org/x/sys v0.7.0 // indirect
golang.org/x/text v0.9.0 // indirect
golang.org/x/time v0.0.0-20220922220347-f3bd1da661af // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/ini.v1 v1.63.2 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
gopkg.in/telebot.v3 v3.0.0
gorm.io/driver/mysql v1.1.2
gorm.io/gorm v1.21.15
gopkg.in/yaml.v2 v2.4.0 // indirect
gorm.io/driver/sqlite v1.5.6 // indirect
)
Loading