Commit e2daa969 authored by chenhan wang's avatar chenhan wang
Browse files

feat: docker backend

parent e59f5971
# 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"]
......@@ -43,7 +43,7 @@ func ConnectDatabase() {
// connect to database
logInfo := viper.GetStringMapString("mysql")
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{})
if err != nil {
logrus.Panic(err)
......
......@@ -120,8 +120,8 @@ async function posttext(text,fileContent,time,ttyy,pass) {
fetch('http://localhost:8089/api/text/upload', {
method: 'POST',
body: JSON.stringify({
Name: "i",// 文件名,比如 xxx
FileType: ttyy ,//文件类型,比如c
Name: "",// 文件名,比如 xxx
Type: ttyy ,//文件类型,比如c
Expiration: time,//过期时间,单位
User: "",//用户名
Passwd: pass,//密码
......@@ -165,7 +165,7 @@ async function getText(url, pass) {
export default posttext;
export { posttext, getText }
export { getText };
//PUT 更新
//DELETE 删除
\ No newline at end of file
......@@ -9,6 +9,7 @@ import { fileContent } from './upload';
const handleClick = () => {
posttext(text, fileContent.content, time, ttyy, pass);
console.log(ttyy)
};
const Submit = () => (
......
......@@ -4,7 +4,9 @@ import { Input } from 'antd';
export let ttyy = '';
const Type = () => {
const [type,setType]=useState("");
const handleTypeChange = (e) => {
setType(e.target.value);
ttyy = e.target.value;
};
......@@ -16,7 +18,7 @@ const Type = () => {
class="input"
placeholder="file type"
autoComplete="off"
value={ttyy}
value={type}
onChange={handleTypeChange}/>
<datalist id="appNamelist">
<option>.md</option>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment