dockerhost name support

This commit is contained in:
Jan Prochazka 2022-04-21 18:59:07 +02:00
parent 66da21804b
commit e5bbf5eca3
3 changed files with 28 additions and 2 deletions

View File

@ -1,10 +1,18 @@
FROM node:14
RUN apt-get update && apt-get install -y \
iputils-ping \
iproute2 \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /home/dbgate-docker
COPY . .
RUN ["chmod", "+x", "/home/dbgate-docker/entrypoint.sh"]
WORKDIR /home/dbgate-docker
EXPOSE 3000
VOLUME /root/dbgate-data
CMD node bundle.js
CMD ["/home/dbgate-docker/entrypoint.sh"]

View File

@ -2,9 +2,16 @@ FROM node:14-alpine
WORKDIR /home/dbgate-docker
RUN apk --no-cache upgrade \
&& apk --no-cache add \
iputils
COPY . .
RUN ["chmod", "+x", "/home/dbgate-docker/entrypoint.sh"]
WORKDIR /home/dbgate-docker
EXPOSE 3000
VOLUME /root/dbgate-data
CMD node bundle.js
CMD ["/home/dbgate-docker/entrypoint.sh"]

11
docker/entrypoint.sh Normal file
View File

@ -0,0 +1,11 @@
#!/bin/sh
HOST_DOMAIN="dockerhost"
ping -q -c1 $HOST_DOMAIN > /dev/null 2>&1
if [ $? != 0 ]
then
HOST_IP=$(ip route | awk 'NR==1 {print $3}')
echo "$HOST_IP $HOST_DOMAIN" >> /etc/hosts
fi
node bundle.js