aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander NeonXP Kiryukhin <i@neonxp.ru>2024-07-21 22:04:13 +0300
committerAlexander NeonXP Kiryukhin <i@neonxp.ru>2024-07-21 22:04:13 +0300
commit12ed72e4e1da181a6c87319a50d3b4142788b4c0 (patch)
tree3595e51b5a13489b45c3735b7230f2ba2ce8f6f1
parentce3111b0efe91e275ce070f9511b5b1b9801a46d (diff)
фикс ошибки и докерфайл
-rw-r--r--Dockerfile18
-rw-r--r--routes/node.go24
2 files changed, 36 insertions, 6 deletions
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..5b46639
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,18 @@
+# syntax=docker/dockerfile:1
+
+FROM golang:1.22.5-alpine3.20 AS builder
+
+WORKDIR /app
+
+COPY go.mod go.sum ./
+RUN go mod download
+
+COPY . .
+
+RUN CGO_ENABLED=0 GOOS=linux go build -o /app/gorum
+
+FROM alpine:3.20
+
+COPY --from=builder /app/gorum .
+
+ENTRYPOINT ["/gorum"] \ No newline at end of file
diff --git a/routes/node.go b/routes/node.go
index 2f5b7d3..e8aa455 100644
--- a/routes/node.go
+++ b/routes/node.go
@@ -77,9 +77,15 @@ func (r *Router) NewPost(c echo.Context) error {
return c.Redirect(302, fmt.Sprintf("/t/%d#post%d", parentID, postID))
}
- node, err := r.nodeRepo.Get(c.Request().Context(), parentID)
- if err != nil {
- return err
+ node := &models.Node{
+ ID: 0,
+ Text: "Gorum",
+ }
+ if parentID > 0 {
+ node, err = r.nodeRepo.Get(c.Request().Context(), parentID)
+ if err != nil {
+ return err
+ }
}
return utils.Render(c, views.NewPost(node))
@@ -108,9 +114,15 @@ func (r *Router) NewTopic(c echo.Context) error {
return c.Redirect(302, fmt.Sprintf("/t/%d", postID))
}
- node, err := r.nodeRepo.Get(c.Request().Context(), parentID)
- if err != nil {
- return err
+ node := &models.Node{
+ ID: 0,
+ Text: "Gorum",
+ }
+ if parentID > 0 {
+ node, err = r.nodeRepo.Get(c.Request().Context(), parentID)
+ if err != nil {
+ return err
+ }
}
return utils.Render(c, views.NewTopic(node))