Skip to content

Commit d420443

Browse files
committed
feat: add start tianji container shell and which make tianji report can build in report self
1 parent ff3c4a5 commit d420443

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

Dockerfile

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# tianji reporter
22
FROM golang:1.21.1-bookworm AS reporter
3-
WORKDIR /app/reporter
3+
WORKDIR /app
44

55
COPY ./reporter/ ./reporter/
66

77
RUN apt update
8-
RUN cd reporter && go build .
8+
RUN cd reporter && CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-extldflags "-static"' -o tianji-reporter .
99

1010
# Base ------------------------------
1111
# The current Chromium version in Alpine 3.20 is causing timeout issues with Puppeteer. Downgrading to Alpine 3.19 fixes the issue. See #11640, #12637, #12189
@@ -62,14 +62,23 @@ RUN mkdir -p ./src/server/public
6262
COPY --from=static /app/tianji/geo /app/tianji/geo
6363
COPY --from=static /app/tianji/src/server/public /app/tianji/src/server/public
6464

65+
# Copy reporter binary from reporter stage
66+
COPY --from=reporter /app/reporter/tianji-reporter /usr/local/bin/tianji-reporter
67+
RUN chmod +x /usr/local/bin/tianji-reporter
68+
6569
RUN pnpm build:server
6670

6771
RUN pip install apprise cryptography --break-system-packages
6872

73+
# Copy startup script
74+
COPY ./scripts/start-tianji-container.sh /usr/local/bin/start-tianji-container.sh
75+
RUN chmod +x /usr/local/bin/start-tianji-container.sh
76+
77+
6978
RUN rm -rf ./src/client
7079
RUN rm -rf ./website
7180
RUN rm -rf ./reporter
7281

7382
EXPOSE 12345
7483

75-
CMD ["pnpm", "start:docker"]
84+
CMD ["/usr/local/bin/start-tianji-container.sh"]

scripts/start-tianji-container.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/sh
2+
3+
# Start Tianji server in background
4+
pnpm start:docker &
5+
6+
# Wait a moment for server to start
7+
sleep 10
8+
9+
# Start reporter with default workspace
10+
/usr/local/bin/tianji-reporter --url "http://localhost:12345" --workspace "clnzoxcy10001vy2ohi4obbi0" --name "tianji-container" &
11+
12+
# Wait for any process to exit
13+
wait -n
14+
15+
# Exit with status of process that exited first
16+
exit $?

0 commit comments

Comments
 (0)