Skip to content

Commit 7649c46

Browse files
author
yesmore
committed
test: docker file
1 parent 7bddaa3 commit 7649c46

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

Dockerfile

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
FROM golang:1.18 AS builder
2+
3+
ENV GO111MODULE=on \
4+
CGO_ENABLED=0 \
5+
GOOS=linux \
6+
GOARCH=amd64 \
7+
GOPROXY=https://goproxy.cn
8+
9+
WORKDIR /app
10+
11+
COPY . .
12+
13+
RUN go mod download
14+
RUN go build -o app core/core.go
15+
16+
# Runer
17+
FROM alpine:latest
18+
19+
WORKDIR /app
20+
COPY --from=builder /app/app .
21+
COPY core /app
22+
23+
CMD ["./app"]

README.md

+8
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@
4242

4343
Windows 11 with vscode,go module
4444

45+
### Docker 部署
46+
47+
```bash
48+
docker build . -t yesmore/disk
49+
50+
docker run -p 20088:20088 yesmore/disk
51+
```
52+
4553
## 共建者
4654

4755
<div style="display:flex">

core/models/init.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import (
1515
初始化数据库
1616
*/
1717
func Init(dataSource string) *gorm.DB {
18-
engine, err := gorm.Open(mysql.Open(dataSource), &gorm.Config{})
18+
// engine, err := gorm.Open(mysql.Open(dataSource), &gorm.Config{})
19+
engine, err := gorm.Open(mysql.Open("root:"+define.MySQLPassword+"@tcp(81.69.202.167:3306)/gcloud?charset=utf8mb4&parseTime=True&loc=Local"), &gorm.Config{})
1920
if err != nil {
2021
log.Printf("Gorm New Engine Error:%v", err)
2122
return nil

0 commit comments

Comments
 (0)