Browse Source

Updated and optimized docker build files.

pull/6737/head
Igor Kulikov 4 years ago
parent
commit
4195d48c3b
  1. 16
      msa/js-executor/docker/Dockerfile
  2. 2
      msa/js-executor/pom.xml
  3. 7
      msa/tb-node/docker/Dockerfile
  4. 80
      msa/tb/docker-cassandra/Dockerfile
  5. 61
      msa/tb/docker-postgres/Dockerfile
  6. 2
      msa/transport/coap/docker/Dockerfile
  7. 2
      msa/transport/http/docker/Dockerfile
  8. 2
      msa/transport/lwm2m/docker/Dockerfile
  9. 2
      msa/transport/mqtt/docker/Dockerfile
  10. 2
      msa/transport/snmp/docker/Dockerfile
  11. 16
      msa/web-ui/docker/Dockerfile
  12. 2
      msa/web-ui/pom.xml
  13. 2
      ui-ngx/pom.xml

16
msa/js-executor/docker/Dockerfile

@ -14,16 +14,13 @@
# limitations under the License.
#
FROM node:16.13.1-bullseye-slim
COPY start-js-executor.sh /tmp/
RUN chmod a+x /tmp/*.sh \
&& mv /tmp/start-js-executor.sh /usr/bin
FROM node:16.15.1-bullseye-slim
ENV NODE_ENV production
ENV DOCKER_MODE true
COPY start-js-executor.sh /tmp/
WORKDIR ${pkg.installFolder}
COPY ["src/package.json", "src/yarn.lock", "./"]
@ -34,9 +31,10 @@ COPY src/api ./api
COPY src/queue ./queue
COPY src/server.js ./
RUN chown -R node:node ${pkg.installFolder}
RUN yarn install --production && yarn cache clean --all
RUN chmod a+x /tmp/*.sh \
&& mv /tmp/start-js-executor.sh /usr/bin \
&& chown -R node:node ${pkg.installFolder} \
&& yarn install --production && yarn cache clean --all
USER node

2
msa/js-executor/pom.xml

@ -71,7 +71,7 @@
<goal>install-node-and-yarn</goal>
</goals>
<configuration>
<nodeVersion>v16.13.1</nodeVersion>
<nodeVersion>v16.15.1</nodeVersion>
<yarnVersion>v1.22.17</yarnVersion>
</configuration>
</execution>

7
msa/tb-node/docker/Dockerfile

@ -14,13 +14,12 @@
# limitations under the License.
#
FROM thingsboard/openjdk11
RUN echo 'networkaddress.cache.ttl=60' >> /etc/java-11-openjdk/security/java.security
FROM thingsboard/openjdk11:bullseye-slim
COPY start-tb-node.sh ${pkg.name}.deb /tmp/
RUN chmod a+x /tmp/*.sh \
RUN echo 'networkaddress.cache.ttl=60' >> /etc/java-11-openjdk/security/java.security \
&& chmod a+x /tmp/*.sh \
&& mv /tmp/start-tb-node.sh /usr/bin && \
(yes | dpkg -i /tmp/${pkg.name}.deb) && \
rm /tmp/${pkg.name}.deb && \

80
msa/tb/docker-cassandra/Dockerfile

@ -14,37 +14,9 @@
# limitations under the License.
#
FROM thingsboard/openjdk11
FROM thingsboard/openjdk11:bullseye-slim
RUN apt-get update
RUN apt-get install -y curl nmap procps gnupg2
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ $(. /etc/os-release && echo -n $VERSION_CODENAME)-pgdg main" | tee --append /etc/apt/sources.list.d/pgdg.list > /dev/null
RUN curl -L https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
RUN echo 'deb http://downloads.apache.org/cassandra/debian 40x main' | tee --append /etc/apt/sources.list.d/cassandra.list > /dev/null
RUN curl -L https://downloads.apache.org/cassandra/KEYS | apt-key add -
ENV PG_MAJOR=12
RUN apt-get update
RUN apt-get install -y cassandra cassandra-tools postgresql-12
RUN update-rc.d cassandra disable
RUN update-rc.d postgresql disable
RUN sed -i.old '/ulimit/d' /etc/init.d/cassandra
COPY logback.xml ${pkg.name}.conf start-db.sh stop-db.sh start-tb.sh upgrade-tb.sh install-tb.sh ${pkg.name}.deb /tmp/
RUN chmod a+x /tmp/*.sh \
&& mv /tmp/start-tb.sh /usr/bin \
&& mv /tmp/upgrade-tb.sh /usr/bin \
&& mv /tmp/install-tb.sh /usr/bin \
&& mv /tmp/start-db.sh /usr/bin \
&& mv /tmp/stop-db.sh /usr/bin
RUN dpkg -i /tmp/${pkg.name}.deb
RUN rm /tmp/${pkg.name}.deb
RUN systemctl --no-reload disable --now ${pkg.name}.service > /dev/null 2>&1 || :
RUN mv /tmp/logback.xml ${pkg.installFolder}/conf \
&& mv /tmp/${pkg.name}.conf ${pkg.installFolder}/conf
ENV DATA_FOLDER=/data
@ -69,23 +41,43 @@ ENV PATH=$PATH:/usr/lib/postgresql/$PG_MAJOR/bin
ENV PGLOG=/var/log/postgres
ENV CASSANDRA_LOG=/var/log/cassandra
# postgres config
RUN mkdir -p $PGLOG
RUN chown -R ${pkg.user}:${pkg.user} $PGLOG
RUN chown -R ${pkg.user}:${pkg.user} /var/log/postgresql
RUN chown -R ${pkg.user}:${pkg.user} /var/run/postgresql
COPY logback.xml ${pkg.name}.conf start-db.sh stop-db.sh start-tb.sh upgrade-tb.sh install-tb.sh ${pkg.name}.deb /tmp/
RUN apt-get update \
&& apt-get install -y curl nmap procps gnupg2 \
&& echo "deb http://apt.postgresql.org/pub/repos/apt/ $(. /etc/os-release && echo -n $VERSION_CODENAME)-pgdg main" | tee --append /etc/apt/sources.list.d/pgdg.list > /dev/null \
&& curl -L https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
&& echo 'deb http://downloads.apache.org/cassandra/debian 40x main' | tee --append /etc/apt/sources.list.d/cassandra.list > /dev/null \
&& curl -L https://downloads.apache.org/cassandra/KEYS | apt-key add - \
&& apt-get update \
&& apt-get install -y cassandra cassandra-tools postgresql-12 \
&& update-rc.d cassandra disable \
&& update-rc.d postgresql disable \
&& sed -i.old '/ulimit/d' /etc/init.d/cassandra \
&& chmod a+x /tmp/*.sh \
&& mv /tmp/start-tb.sh /usr/bin \
&& mv /tmp/upgrade-tb.sh /usr/bin \
&& mv /tmp/install-tb.sh /usr/bin \
&& mv /tmp/start-db.sh /usr/bin \
&& mv /tmp/stop-db.sh /usr/bin \
&& dpkg -i /tmp/${pkg.name}.deb \
&& rm /tmp/${pkg.name}.deb \
&& systemctl --no-reload disable --now ${pkg.name}.service > /dev/null 2>&1 || : \
&& mv /tmp/logback.xml ${pkg.installFolder}/conf \
&& mv /tmp/${pkg.name}.conf ${pkg.installFolder}/conf \
# postgres config
&& mkdir -p $PGLOG \
&& chown -R ${pkg.user}:${pkg.user} $PGLOG \
&& chown -R ${pkg.user}:${pkg.user} /var/log/postgresql \
&& chown -R ${pkg.user}:${pkg.user} /var/run/postgresql \
# cassandra config
RUN rm -rf /var/lib/cassandra
RUN chmod a+w /var/lib
RUN chown -R ${pkg.user}:${pkg.user} $CASSANDRA_LOG
RUN mkdir -p $DATA_FOLDER
RUN chown -R ${pkg.user}:${pkg.user} $DATA_FOLDER
RUN chown -R ${pkg.user}:${pkg.user} /var/log/${pkg.name}
RUN chmod 555 ${pkg.installFolder}/bin/${pkg.name}.jar
&& rm -rf /var/lib/cassandra \
&& chmod a+w /var/lib \
&& chown -R ${pkg.user}:${pkg.user} $CASSANDRA_LOG \
&& mkdir -p $DATA_FOLDER \
&& chown -R ${pkg.user}:${pkg.user} $DATA_FOLDER \
&& chown -R ${pkg.user}:${pkg.user} /var/log/${pkg.name} \
&& chmod 555 ${pkg.installFolder}/bin/${pkg.name}.jar
USER ${pkg.user}

61
msa/tb/docker-postgres/Dockerfile

@ -14,33 +14,9 @@
# limitations under the License.
#
FROM thingsboard/openjdk11
FROM thingsboard/openjdk11:bullseye-slim
RUN apt-get update
RUN apt-get install -y curl gnupg2
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ $(. /etc/os-release && echo -n $VERSION_CODENAME)-pgdg main" | tee --append /etc/apt/sources.list.d/pgdg.list > /dev/null
RUN curl -L https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
ENV PG_MAJOR 12
RUN apt-get update
RUN apt-get install -y postgresql-12
RUN update-rc.d postgresql disable
COPY logback.xml ${pkg.name}.conf start-db.sh stop-db.sh start-tb.sh upgrade-tb.sh install-tb.sh ${pkg.name}.deb /tmp/
RUN chmod a+x /tmp/*.sh \
&& mv /tmp/start-tb.sh /usr/bin \
&& mv /tmp/upgrade-tb.sh /usr/bin \
&& mv /tmp/install-tb.sh /usr/bin \
&& mv /tmp/start-db.sh /usr/bin \
&& mv /tmp/stop-db.sh /usr/bin
RUN dpkg -i /tmp/${pkg.name}.deb
RUN rm /tmp/${pkg.name}.deb
RUN systemctl --no-reload disable --now ${pkg.name}.service > /dev/null 2>&1 || :
RUN mv /tmp/logback.xml ${pkg.installFolder}/conf \
&& mv /tmp/${pkg.name}.conf ${pkg.installFolder}/conf
ENV DATA_FOLDER=/data
@ -55,18 +31,35 @@ ENV SPRING_DATASOURCE_URL=jdbc:postgresql://localhost:5432/thingsboard
ENV SPRING_DATASOURCE_USERNAME=${pkg.user}
ENV SPRING_DATASOURCE_PASSWORD=postgres
ENV PGLOG=/var/log/postgres
RUN mkdir -p $PGLOG
RUN chown -R ${pkg.user}:${pkg.user} $PGLOG
RUN chown -R ${pkg.user}:${pkg.user} /var/run/postgresql
RUN mkdir -p /data
RUN chown -R ${pkg.user}:${pkg.user} /data
COPY logback.xml ${pkg.name}.conf start-db.sh stop-db.sh start-tb.sh upgrade-tb.sh install-tb.sh ${pkg.name}.deb /tmp/
RUN chown -R ${pkg.user}:${pkg.user} /var/log/${pkg.name}
RUN chmod 555 ${pkg.installFolder}/bin/${pkg.name}.jar
RUN apt-get update \
&& apt-get install -y curl gnupg2 \
&& echo "deb http://apt.postgresql.org/pub/repos/apt/ $(. /etc/os-release && echo -n $VERSION_CODENAME)-pgdg main" | tee --append /etc/apt/sources.list.d/pgdg.list > /dev/null \
&& curl -L https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
&& apt-get update \
&& apt-get install -y postgresql-12 \
&& update-rc.d postgresql disable \
&& chmod a+x /tmp/*.sh \
&& mv /tmp/start-tb.sh /usr/bin \
&& mv /tmp/upgrade-tb.sh /usr/bin \
&& mv /tmp/install-tb.sh /usr/bin \
&& mv /tmp/start-db.sh /usr/bin \
&& mv /tmp/stop-db.sh /usr/bin \
&& dpkg -i /tmp/${pkg.name}.deb \
&& rm /tmp/${pkg.name}.deb \
&& systemctl --no-reload disable --now ${pkg.name}.service > /dev/null 2>&1 || : \
&& mv /tmp/logback.xml ${pkg.installFolder}/conf \
&& mv /tmp/${pkg.name}.conf ${pkg.installFolder}/conf \
&& mkdir -p $PGLOG \
&& chown -R ${pkg.user}:${pkg.user} $PGLOG \
&& chown -R ${pkg.user}:${pkg.user} /var/run/postgresql \
&& mkdir -p /data \
&& chown -R ${pkg.user}:${pkg.user} /data \
&& chown -R ${pkg.user}:${pkg.user} /var/log/${pkg.name} \
&& chmod 555 ${pkg.installFolder}/bin/${pkg.name}.jar
USER ${pkg.user}

2
msa/transport/coap/docker/Dockerfile

@ -14,7 +14,7 @@
# limitations under the License.
#
FROM thingsboard/openjdk11
FROM thingsboard/openjdk11:bullseye-slim
COPY start-tb-coap-transport.sh ${pkg.name}.deb /tmp/

2
msa/transport/http/docker/Dockerfile

@ -14,7 +14,7 @@
# limitations under the License.
#
FROM thingsboard/openjdk11
FROM thingsboard/openjdk11:bullseye-slim
COPY start-tb-http-transport.sh ${pkg.name}.deb /tmp/

2
msa/transport/lwm2m/docker/Dockerfile

@ -14,7 +14,7 @@
# limitations under the License.
#
FROM thingsboard/openjdk11
FROM thingsboard/openjdk11:bullseye-slim
COPY start-tb-lwm2m-transport.sh ${pkg.name}.deb /tmp/

2
msa/transport/mqtt/docker/Dockerfile

@ -14,7 +14,7 @@
# limitations under the License.
#
FROM thingsboard/openjdk11
FROM thingsboard/openjdk11:bullseye-slim
COPY start-tb-mqtt-transport.sh ${pkg.name}.deb /tmp/

2
msa/transport/snmp/docker/Dockerfile

@ -14,7 +14,7 @@
# limitations under the License.
#
FROM thingsboard/openjdk11
FROM thingsboard/openjdk11:bullseye-slim
COPY start-tb-snmp-transport.sh ${pkg.name}.deb /tmp/

16
msa/web-ui/docker/Dockerfile

@ -14,16 +14,13 @@
# limitations under the License.
#
FROM node:16.13.1-bullseye-slim
COPY start-web-ui.sh /tmp/
RUN chmod a+x /tmp/*.sh \
&& mv /tmp/start-web-ui.sh /usr/bin
FROM node:16.15.1-bullseye-slim
ENV NODE_ENV production
ENV DOCKER_MODE true
COPY start-web-ui.sh /tmp/
WORKDIR ${pkg.installFolder}
COPY ["src/package.json", "src/yarn.lock", "./"]
@ -33,9 +30,10 @@ COPY package/linux/conf ./config
COPY web ./web
COPY src/server.js ./
RUN chown -R node:node ${pkg.installFolder}
RUN yarn install --production && yarn cache clean --all
RUN chmod a+x /tmp/*.sh \
&& mv /tmp/start-web-ui.sh /usr/bin \
&& chown -R node:node ${pkg.installFolder} \
&& yarn install --production && yarn cache clean --all
USER node

2
msa/web-ui/pom.xml

@ -80,7 +80,7 @@
<goal>install-node-and-yarn</goal>
</goals>
<configuration>
<nodeVersion>v16.13.1</nodeVersion>
<nodeVersion>v16.15.1</nodeVersion>
<yarnVersion>v1.22.17</yarnVersion>
</configuration>
</execution>

2
ui-ngx/pom.xml

@ -56,7 +56,7 @@
<goal>install-node-and-yarn</goal>
</goals>
<configuration>
<nodeVersion>v16.13.0</nodeVersion>
<nodeVersion>v16.15.1</nodeVersion>
<yarnVersion>v1.22.17</yarnVersion>
</configuration>
</execution>

Loading…
Cancel
Save