Browse Source

feat: update dockerfile, compile website into single image

delong.wang 1 year ago
parent
commit
dbe38a4038
6 changed files with 15 additions and 25 deletions
  1. 2 1
      .gitignore
  2. 6 7
      Dockerfile
  3. 0 16
      backend/Dockerfile
  4. 3 0
      documents/.dockerignore
  5. 3 0
      website/.dockerignore
  6. 1 1
      website/src/components/NavBar.tsx

+ 2 - 1
.gitignore

@@ -2,4 +2,5 @@
 .DS_Store
 *.zip
 *.tar
-build.sh
+build.sh
+compose.yml

+ 6 - 7
Dockerfile

@@ -12,18 +12,17 @@ RUN go build -o server .
 
 FROM node:20.5-alpine
 
+ARG telemetry
+
 RUN apk update
-RUN apk add nginx supervisor
+RUN apk add nginx supervisor curl
 
 RUN echo -e "                                                                   \n\
 server {                                                                        \n\
     listen 80;                                                                  \n\
                                                                                 \n\
-    location /api/count {                                                       \n\
-        proxy_pass https://rivers-telemetry.chaitin.cn:10086;                   \n\
-    }                                                                           \n\
-    location /api/exist {                                                       \n\
-        proxy_pass https://rivers-telemetry.chaitin.cn:10086;                   \n\
+    location /api/(count|exist) {                                               \n\
+        proxy_pass \$telemetry;                                                 \n\
     }                                                                           \n\
     location /api/ {                                                            \n\
         proxy_pass http://localhost:8080;                                       \n\
@@ -93,7 +92,7 @@ command     = server                \n\
 directory   = /srv/server           \n\
 " > /etc/supervisor.d/safeline.ini
 
-# COPY --from=go-builder /work/server /srv/server/server
+COPY --from=go-builder /work/server /srv/server
 
 COPY documents /srv/documents
 WORKDIR /srv/documents

+ 0 - 16
backend/Dockerfile

@@ -1,16 +0,0 @@
-FROM golang:1.21 as build
-
-WORKDIR /app
-
-COPY .  .
-
-RUN go mod tidy && \
-    CGO_ENABLED=0 go build -o server .
-
-FROM alpine:latest
-
-WORKDIR /app
-
-COPY --from=0 /app/server .
-
-CMD ["./server"]

+ 3 - 0
documents/.dockerignore

@@ -0,0 +1,3 @@
+node_modules
+build
+.docusaurus

+ 3 - 0
website/.dockerignore

@@ -0,0 +1,3 @@
+node_modules
+build
+.next

+ 1 - 1
website/src/components/NavBar.tsx

@@ -6,7 +6,7 @@ import usePopupState, { bindPopover, bindHover } from '@/components/Popover/useP
 import HoverPopover from '@/components/Popover/HoverPopover'
 
 const navs = [
-  { to: "https://waf-ce.chaitin.cn/posts/guide_introduction", label: "帮助文档", target: "_blank" },
+  { to: "/docs", label: "帮助文档", target: "_blank" },
   { to: "/community", label: "社区", target: "_self" },
   { to: "/version", label: "版本对比", target: "_self" },
 ];