diff --git a/.env.example b/.env.example index d5aa4ec..70be479 100644 --- a/.env.example +++ b/.env.example @@ -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= diff --git a/Dockerfile b/Dockerfile index 8944580..a2ff9f6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/docker-compose.yaml b/docker-compose.yaml index ad6dc9d..2f3492f 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -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} diff --git a/entrypoint.sh b/entrypoint.sh index a2f313e..597476f 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -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 diff --git a/nginx.conf b/nginx.conf.template similarity index 97% rename from nginx.conf rename to nginx.conf.template index 68fb8c8..84d727f 100644 --- a/nginx.conf +++ b/nginx.conf.template @@ -7,7 +7,7 @@ events { http { # 定义 server 块 server { - listen 80; + listen ${NGINX_PORT}; # 定义 WS 的代理规则 location /ws {