create user in dockerfile, add start script for container

This commit is contained in:
Wolfgang Hottgenroth 2019-06-11 22:55:54 +02:00
parent 1b83780327
commit 5bf0db7108
Signed by: wn
GPG Key ID: 6C1E5E531E0D5D7F
2 changed files with 27 additions and 1 deletions

View File

@ -3,9 +3,16 @@ FROM debian:latest
LABEL Maintainer="Wolfgang Hottgenroth <woho@hottis.de>"
LABEL ImageName="registry.gitlab.com/wolutator/mosquitto-with-auth"
ARG MOSQ_USER="mosquitto"
ARG MOSQ_UID="1883"
ARG MOSQ_GID="1883"
RUN \
apt update && \
apt install -y mariadb-client openssl libwebsockets8
apt install -y mariadb-client openssl libwebsockets8 && \
groupadd -r -g $MOSQ_GID $MOSQ_USER && \
useradd -m -r -u $MOSQ_UID -g $MOSQ_USER $MOSQ_USER
COPY opt/ /opt
COPY etc/ /opt/etc

19
mosquitto-start.sh Executable file
View File

@ -0,0 +1,19 @@
#!/bin/bash
IMAGE=registry.gitlab.com/wolutator/mosquitto-with-auth:latest
VOLUME=mosquitto-config
docker volume inspect $VOLUME > /dev/null || docker volume create $VOLUME
docker pull $IMAGE
docker run \
-it \
--rm \
-p1883:1883 \
-v $VOLUME:/opt/etc/mosquitto \
--link mariadb \
--name mosquitto \
$IMAGE /bin/bash