From 2b6874a58d7908e79e153666a0bea5cf6a24d634 Mon Sep 17 00:00:00 2001 From: Alireza Ahmadi Date: Thu, 18 Jul 2024 23:13:09 +0200 Subject: [PATCH] better docker solution #176 --- Dockerfile | 5 +++-- docker-compose.yml | 41 +++++++++++++++++++++++++++++++++++++++-- entrypoint.sh | 4 ++++ 3 files changed, 46 insertions(+), 4 deletions(-) create mode 100755 entrypoint.sh diff --git a/Dockerfile b/Dockerfile index d8dfe538..a19a127f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM --platform=$BUILDPLATFORM node:alpine as front-builder +FROM --platform=$BUILDPLATFORM node:alpine AS front-builder WORKDIR /app COPY frontend/ ./ RUN npm install && npm run build @@ -20,5 +20,6 @@ ENV TZ=Asia/Tehran WORKDIR /app RUN apk add --no-cache --update ca-certificates tzdata COPY --from=backend-builder /app/sui /app/ +COPY entrypoint.sh /app/ VOLUME [ "s-ui" ] -CMD [ "./sui" ] \ No newline at end of file +ENTRYPOINT [ "./entrypoint.sh" ] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index e186e322..fbf5ebd3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,6 +8,7 @@ services: - "singbox:/app/bin" - "$PWD/db:/app/db" - "$PWD/cert:/app/cert" + - "logs:/logs" environment: SINGBOX_API: "sing-box:1080" SUI_DB_FOLDER: "db" @@ -18,7 +19,16 @@ services: - "2096:2096" networks: - s-ui - entrypoint: "./sui migrate && ./sui" + links: + - syslog + logging: + driver: syslog + options: + tag: "s-ui" + syslog-address: "udp://127.0.0.1:1514" + entrypoint: "./entrypoint.sh" + depends_on: + - syslog sing-box: image: alireza7/s-ui-singbox @@ -34,12 +44,39 @@ services: - "2443:2443" - "3443:3443" restart: unless-stopped + links: + - syslog + logging: + driver: syslog + options: + tag: "sing-box" + syslog-address: "udp://127.0.0.1:1514" depends_on: - s-ui + - syslog + + syslog: + image: rsyslog/syslog_appliance_alpine + container_name: syslog + volumes: + - "logs:/logs" + networks: + - s-ui + ports: + - "127.0.0.1:1514:1514/udp" + restart: unless-stopped + environment: + - RSYSLOG_CONF_GLOBAL_CONF=template(name="RemoteLogs" type="string" string="/logs/%programname%.log") + - RSYSLOG_CONF_INPUT_UDP="input(type=\"imudp\" port=\"1514\" ruleset=\"remote\")" + - RSYSLOG_CONF_RULESET_REMOTE="ruleset(name=\"remote\") { action(type=\"omfile\" dynaFile=\"RemoteLogs\") }" + command: > + sh -c 'touch /config/container_config' networks: s-ui: driver: bridge volumes: - singbox: \ No newline at end of file + logs: + singbox: + \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 00000000..9df1ac78 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +./sui migrate +./sui \ No newline at end of file