feat: Add support for dynamic NGINX port configuration and update related files.(#34)

This commit is contained in:
jarvis2f 2025-02-17 16:58:37 +08:00
parent e03bb0fb7f
commit 493392ed07
5 changed files with 17 additions and 4 deletions

View file

@ -3,6 +3,14 @@ LOG_LEVEL=INFO
APP_ENV=prod
# The root directory of the application
APP_ROOT=/app/data
# PUID and PGID are the user id and group id of the user who owns the files in the mounted volume.
# PUID: 1000
# PGID: 1000
# The port on which the nginx listens for incoming connections, default is 80
# NGINX_PORT: 80
# only use in test
#TDLIB_PATH=
#JAVA_HOME=

View file

@ -52,11 +52,12 @@ WORKDIR /app
ARG LIB_PATH=/app/tdlib
ENV JAVA_HOME=/jre \
PATH="/jre/bin:$PATH" \
LANG=C.UTF-8
LANG=C.UTF-8 \
NGINX_PORT=80
RUN npm install -g pm2 && \
apt-get update && \
apt-get install -y --no-install-recommends nginx wget curl unzip tini gosu && \
apt-get install -y --no-install-recommends nginx wget curl unzip tini gosu gettext && \
mkdir -p $LIB_PATH && \
wget --no-check-certificate -q -O libs.zip https://github.com/p-vorobyev/spring-boot-starter-telegram/releases/download/1.15.0/libs.zip && \
unzip -q libs.zip -d /tmp/tdlib && \
@ -89,7 +90,7 @@ COPY --from=web-builder --chown=1000:1000 /web/.next/static /app/web/.next/stati
COPY --chown=1000:1000 ./web/pm2.json /app/web/
COPY --chown=1000:1000 ./entrypoint.sh .
COPY --chown=1000:1000 ./nginx.conf /etc/nginx/nginx.conf
COPY --chown=1000:1000 ./nginx.conf.template /etc/nginx/nginx.conf.template
EXPOSE 80

View file

@ -13,6 +13,7 @@ services:
# PUID and PGID are the user id and group id of the user who owns the files in the mounted volume.
# PUID: 1000
# PGID: 1000
# NGINX_PORT: 80
APP_ENV: "prod"
APP_ROOT: "/app/data"
TELEGRAM_API_ID: ${TELEGRAM_API_ID}

View file

@ -72,6 +72,9 @@ start_services() {
# Set up signal handlers
trap cleanup TERM INT
# Replace nginx.conf.template with environment variables
envsubst '$NGINX_PORT' < /etc/nginx/nginx.conf.template > /etc/nginx/nginx.conf
# Set up permissions
setup_permissions

View file

@ -7,7 +7,7 @@ events {
http {
# 定义 server 块
server {
listen 80;
listen ${NGINX_PORT};
# 定义 WS 的代理规则
location /ws {