Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenhan wang
pastebin
Commits
e2daa969
Commit
e2daa969
authored
Aug 04, 2024
by
chenhan wang
Browse files
feat: docker backend
parent
e59f5971
Changes
5
Hide whitespace changes
Inline
Side-by-side
backend/Dockerfile
0 → 100644
View file @
e2daa969
# lot-backend
FROM
golang:1.19.13-alpine3.18
AS
go-builder
ENV
\
GO111MODULE=on \
CGO_ENABLED=0
WORKDIR
/home/pastebin
COPY
./ backend/
WORKDIR
/home/pastebin/backend
# Build your Go code
RUN
go build
-o
./pastebin .
# Final image for running only the built executable
FROM
alpine:latest
# Copy Go backend executable
COPY
--from=go-builder /home/pastebin/backend/pastebin /home/pastebin/backend/
COPY
--from=go-builder /home/pastebin/backend/config.yaml /home/pastebin/backend/
# 设置工作目录,这里需要根据实际情况修改
WORKDIR
/home/pastebin/backend
# 你可以添加其他一些需要的命令或设置,根据实际情况进行调整
# 例如,你可能需要设置启动命令
CMD
["/home/pastebin/backend/pastebin"]
backend/model/init.go
View file @
e2daa969
...
@@ -43,7 +43,7 @@ func ConnectDatabase() {
...
@@ -43,7 +43,7 @@ func ConnectDatabase() {
// connect to database
// connect to database
logInfo
:=
viper
.
GetStringMapString
(
"mysql"
)
logInfo
:=
viper
.
GetStringMapString
(
"mysql"
)
sqlInfo
:=
logInfo
[
"user"
]
+
":"
+
logInfo
[
"password"
]
+
sqlInfo
:=
logInfo
[
"user"
]
+
":"
+
logInfo
[
"password"
]
+
"@(
localhost
)/"
+
logInfo
[
"database"
]
+
"?charset=utf8mb4&parseTime=True&loc=Local"
"@(
"
+
logInfo
[
"host"
]
+
"
)/"
+
logInfo
[
"database"
]
+
"?charset=utf8mb4&parseTime=True&loc=Local"
DB
,
err
=
gorm
.
Open
(
mysql
.
Open
(
sqlInfo
),
&
gorm
.
Config
{})
DB
,
err
=
gorm
.
Open
(
mysql
.
Open
(
sqlInfo
),
&
gorm
.
Config
{})
if
err
!=
nil
{
if
err
!=
nil
{
logrus
.
Panic
(
err
)
logrus
.
Panic
(
err
)
...
...
frontend/comment_area/src/pages/api/api.js
View file @
e2daa969
...
@@ -120,8 +120,8 @@ async function posttext(text,fileContent,time,ttyy,pass) {
...
@@ -120,8 +120,8 @@ async function posttext(text,fileContent,time,ttyy,pass) {
fetch
(
'
http://localhost:8089/api/text/upload
'
,
{
fetch
(
'
http://localhost:8089/api/text/upload
'
,
{
method
:
'
POST
'
,
method
:
'
POST
'
,
body
:
JSON
.
stringify
({
body
:
JSON
.
stringify
({
Name
:
"
i
"
,
// 文件名,比如 xxx
Name
:
""
,
// 文件名,比如 xxx
File
Type
:
ttyy
,
//文件类型,比如c
Type
:
ttyy
,
//文件类型,比如c
Expiration
:
time
,
//过期时间,单位
Expiration
:
time
,
//过期时间,单位
User
:
""
,
//用户名
User
:
""
,
//用户名
Passwd
:
pass
,
//密码
Passwd
:
pass
,
//密码
...
@@ -165,7 +165,7 @@ async function getText(url, pass) {
...
@@ -165,7 +165,7 @@ async function getText(url, pass) {
export
default
posttext
;
export
default
posttext
;
export
{
posttext
,
getText
}
export
{
getText
}
;
//PUT 更新
//PUT 更新
//DELETE 删除
//DELETE 删除
\ No newline at end of file
frontend/comment_area/src/pages/components/submit.js
View file @
e2daa969
...
@@ -9,6 +9,7 @@ import { fileContent } from './upload';
...
@@ -9,6 +9,7 @@ import { fileContent } from './upload';
const
handleClick
=
()
=>
{
const
handleClick
=
()
=>
{
posttext
(
text
,
fileContent
.
content
,
time
,
ttyy
,
pass
);
posttext
(
text
,
fileContent
.
content
,
time
,
ttyy
,
pass
);
console
.
log
(
ttyy
)
};
};
const
Submit
=
()
=>
(
const
Submit
=
()
=>
(
...
...
frontend/comment_area/src/pages/components/type.js
View file @
e2daa969
...
@@ -4,7 +4,9 @@ import { Input } from 'antd';
...
@@ -4,7 +4,9 @@ import { Input } from 'antd';
export
let
ttyy
=
''
;
export
let
ttyy
=
''
;
const
Type
=
()
=>
{
const
Type
=
()
=>
{
const
[
type
,
setType
]
=
useState
(
""
);
const
handleTypeChange
=
(
e
)
=>
{
const
handleTypeChange
=
(
e
)
=>
{
setType
(
e
.
target
.
value
);
ttyy
=
e
.
target
.
value
;
ttyy
=
e
.
target
.
value
;
};
};
...
@@ -16,7 +18,7 @@ const Type = () => {
...
@@ -16,7 +18,7 @@ const Type = () => {
class
=
"
input
"
class
=
"
input
"
placeholder
=
"
file type
"
placeholder
=
"
file type
"
autoComplete
=
"
off
"
autoComplete
=
"
off
"
value
=
{
t
tyy
}
value
=
{
t
ype
}
onChange
=
{
handleTypeChange
}
/
>
onChange
=
{
handleTypeChange
}
/
>
<
datalist
id
=
"
appNamelist
"
>
<
datalist
id
=
"
appNamelist
"
>
<
option
>
.
md
<
/option
>
<
option
>
.
md
<
/option
>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment