1
0
mirror of https://github.com/thingsboard/thingsboard-gateway synced 2025-10-26 22:31:42 +08:00

Updated main Dockerfile

This commit is contained in:
imbeacon
2024-05-14 11:48:07 +03:00
parent 98d9300dad
commit 4098306354

View File

@@ -3,9 +3,21 @@ FROM --platform=$TARGETPLATFORM python:3.11-slim AS build
ARG TARGETPLATFORM
ARG BUILDPLATFORM
RUN echo "Running on $BUILDPLATFORM, building for $TARGETPLATFORM" > /log
COPY ./thingsboard_gateway /thingsboard_gateway
COPY . .
RUN apt-get update && apt-get install -y --no-install-recommends \
ENV PATH="/root/.cargo/bin:/root/.local/bin:$PATH" \
PYTHONPATH="." \
configs="/thingsboard_gateway/config" \
extensions="/thingsboard_gateway/extensions" \
logs="/thingsboard_gateway/logs"
RUN mkdir -p /default-config/config /default-config/extensions/ && \
cp -r /thingsboard_gateway/config/* /default-config/config/ && \
cp -r /thingsboard_gateway/extensions/* /default-config/extensions && \
echo "Running on $BUILDPLATFORM, building for $TARGETPLATFORM" > /log && \
apt-get update && \
apt-get install -y --no-install-recommends \
gcc python3-dev build-essential libssl-dev libffi-dev zlib1g-dev \
python3-grpcio curl pkg-config libssl-dev && \
case "$TARGETPLATFORM" in \
@@ -18,11 +30,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
esac && \
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-host=$DEFAULT_HOST && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
COPY ./thingsboard_gateway /thingsboard_gateway
RUN echo '#! /bin/sh\n\
rm -rf /var/lib/apt/lists/* && \
echo '#! /bin/sh\n\
# Main start script\n\
CONF_FOLDER="/thingsboard_gateway/config"\n\
FIRSTLAUNCH="${CONF_FOLDER}/.firstlaunch"\n\
@@ -33,18 +42,10 @@ if [ ! -f "$FIRSTLAUNCH" ]; then\n\
echo "#Remove this file only if you want to recreate default config files! This will overwrite existing files" > $FIRSTLAUNCH\n\
fi\n\
echo "nameserver 8.8.8.8" >> /etc/resolv.conf\n\
python /thingsboard_gateway/tb_gateway.py' > /start-gateway.sh && chmod +x /start-gateway.sh
ENV PATH="/root/.cargo/bin:/root/.local/bin:$PATH" \
PYTHONPATH="." \
configs="/thingsboard_gateway/config" \
extensions="/thingsboard_gateway/extensions" \
logs="/thingsboard_gateway/logs"
COPY requirements.txt .
RUN python3 -m pip install --no-cache-dir --upgrade pip setuptools wheel && \
python /thingsboard_gateway/tb_gateway.py' > /start-gateway.sh && chmod +x /start-gateway.sh && \
python3 -m pip install --no-cache-dir --upgrade pip setuptools wheel && \
python3 -m pip install --no-cache-dir -r requirements.txt
VOLUME ["${configs}", "${extensions}", "${logs}"]
CMD [ "/bin/sh", "/start-gateway.sh" ]
CMD [ "/bin/sh", "/start-gateway.sh" ]