Skip to content

Commit

Permalink
feat: Add cloudflared service to the docker image (#2252)
Browse files Browse the repository at this point in the history
* feat: Add cloudflared service to the docker image

* feat: add cloudflared switch

Signed-off-by: Teror Fox <[email protected]>

---------

Signed-off-by: Teror Fox <[email protected]>
  • Loading branch information
sysfox authored Dec 1, 2024
1 parent 8603f21 commit 1bcb434
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
8 changes: 8 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,16 @@ echo "Allowed Origins: $(get_cmd_value "--allowed_origins=" $command_args)"
echo "Config Path: $(if [ -z "$(get_cmd_value "--config_path=" $command_args)" ]; then echo "NULL"; else echo "$(get_cmd_value "--config_path=" $command_args)"; fi)"
echo "Encryption: $(get_boolean_str $(is_in_cmd "--encrypt_enable" $command_args))"
echo "Cluster: $(get_boolean_str $(is_in_cmd "--cluster" $command_args))"
echo "CF Zero Trust Token: $(get_cmd_value "--cf_zero_trust_token=" $command_args)"
echo "============================================"

command="node index.js $command_args"

# 根据环境变量决定是否启动 cloudflared
if [ "$ENABLE_CLOUDFLARED" = "true" ]; then
echo "Starting Cloudflared Tunnel"
echo "============================================"
nohup /usr/local/bin/cloudflared service install $CF_ZERO_TRUST_TOKEN &
echo "============================================"
fi
exec $command
5 changes: 4 additions & 1 deletion dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ RUN node apps/core/download-latest-admin-assets.js

FROM node:20-alpine

RUN apk add zip unzip mongodb-tools bash fish rsync jq curl --no-cache
RUN apk add zip unzip mongodb-tools bash fish rsync jq curl openrc --no-cache

RUN curl -L https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 -o /usr/local/bin/cloudflared \
&& chmod +x /usr/local/bin/cloudflared

WORKDIR /app
COPY --from=builder /app/out .
Expand Down

0 comments on commit 1bcb434

Please sign in to comment.