fix: clean up logic and only apply group if needed

This commit is contained in:
will Farrell 2018-06-30 15:23:27 -06:00
parent b89e312569
commit 02a89f6dac
2 changed files with 7 additions and 4 deletions

View File

@ -3,8 +3,7 @@ FROM library/docker:stable
ENV HOME_DIR=/opt/crontab
RUN apk add --no-cache --virtual .run-deps bash jq \
&& mkdir -p ${HOME_DIR}/jobs ${HOME_DIR}/projects \
&& adduser -S docker -D \
&& sed -i "s/999/99/" /etc/group
&& adduser -S docker -D
COPY docker-entrypoint /
ENTRYPOINT ["/docker-entrypoint"]

View File

@ -25,8 +25,12 @@ mkdir -p ${HOME_DIR}/jobs ${HOME_DIR}/projects
# Create docker group using correct gid from host, and add docker user to it
if ! grep -q "^docker:" /etc/group; then
DOCKER_GID=$(stat -c '%g' ${DOCKER_SOCK})
addgroup -g ${DOCKER_GID} docker
adduser docker docker
if [ "${DOCKER_GID}" != "0" ]; then
addgroup -g ${DOCKER_GID} docker
adduser docker docker
else
adduser docker root
fi
fi
slugify() {