thingsboard/msa/tb/docker-postgres/Dockerfile.custom

59 lines
2.0 KiB
Docker

#
# Copyright © 2016-2025 The Thingsboard Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# 使用本地 tag 的基础镜像 thingsboard/tb-postgres-base
# 这样可以避免 Mac M1 上构建时的 GPG 密钥问题
FROM thingsboard/tb-postgres-base:latest
# 复制本地构建的 DEB 包和配置文件
COPY thingsboard.deb /tmp/thingsboard.deb
COPY logback.xml thingsboard.conf /tmp/
COPY start-tb.sh upgrade-tb.sh install-tb.sh /tmp/
# 切换到 root 用户以执行安装操作
USER root
# 卸载旧版本并安装新版本的 ThingsBoard DEB 包
RUN dpkg -r thingsboard || true \
&& dpkg -i /tmp/thingsboard.deb \
&& rm /tmp/thingsboard.deb
# 更新配置文件和启动脚本
RUN mv /tmp/logback.xml /usr/share/thingsboard/conf/ 2>/dev/null || true \
&& mv /tmp/thingsboard.conf /usr/share/thingsboard/conf/ 2>/dev/null || true \
&& mv /tmp/start-tb.sh /usr/bin/ 2>/dev/null || true \
&& mv /tmp/upgrade-tb.sh /usr/bin/ 2>/dev/null || true \
&& mv /tmp/install-tb.sh /usr/bin/ 2>/dev/null || true \
&& chmod +x /usr/bin/start-tb.sh /usr/bin/upgrade-tb.sh /usr/bin/install-tb.sh \
&& (systemctl --no-reload disable --now thingsboard.service > /dev/null 2>&1 || :) \
&& chown -R thingsboard:thingsboard /usr/share/thingsboard \
&& chown -R thingsboard:thingsboard /usr/bin/start-tb.sh /usr/bin/upgrade-tb.sh /usr/bin/install-tb.sh
# 切换回 thingsboard 用户
USER thingsboard
# 暴露端口
EXPOSE 9090
EXPOSE 1883
EXPOSE 5683/udp
EXPOSE 5685/udp
EXPOSE 5686/udp
VOLUME ["/data"]
CMD ["start-tb.sh"]