Skip to content

Commit

Permalink
Make wodby uid/gid configurable via build params #22 (comment)
Browse files Browse the repository at this point in the history
  • Loading branch information
csandanov committed Mar 6, 2018
1 parent 720aaef commit 59e73c2
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 6 deletions.
13 changes: 11 additions & 2 deletions 5.3/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ FROM wodby/base-php:${FROM_TAG}

ARG PHP_DEV

ARG WODBY_USER_ID=1000
ARG WODBY_GROUP_ID=1000

ENV PHP_DEV="${PHP_DEV}" \
SSHD_PERMIT_USER_ENV="yes" \
RABBITMQ_C_VER="0.8.0" \
Expand Down Expand Up @@ -31,8 +34,14 @@ ENV PHP_DEV="${PHP_DEV}" \

RUN set -xe; \
\
addgroup -g 1000 -S wodby; \
adduser -u 1000 -D -S -s /bin/bash -G wodby wodby; \
# Delete existing user/group if uid/gid occupied.
existing_group=$(getent group "${WODBY_GROUP_ID}" | cut -d: -f1); \
if [[ -n "${existing_group}" ]]; then delgroup "${existing_group}"; fi; \
existing_user=$(getent passwd "${WODBY_USER_ID}" | cut -d: -f1); \
if [[ -n "${existing_user}" ]]; then deluser "${existing_user}"; fi; \
\
addgroup -g "${WODBY_GROUP_ID}" -S wodby; \
adduser -u "${WODBY_USER_ID}" -D -S -s /bin/bash -G wodby wodby; \
adduser wodby www-data; \
sed -i '/^wodby/s/!/*/' /etc/shadow; \
echo "PS1='\w\$ '" >> /home/wodby/.bashrc; \
Expand Down
5 changes: 5 additions & 0 deletions 5.3/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ REPO = wodby/php
NAME = php-$(PHP_VER_MINOR)
FROM_TAG = $(PHP_VER)

WODBY_USER_ID ?= 1000
WODBY_GROUP_ID ?= 1000

ifeq ($(TAG),)
ifneq ($(PHP_DEBUG),)
TAG ?= $(PHP_VER_MINOR)-debug
Expand Down Expand Up @@ -42,6 +45,8 @@ build:
--build-arg FROM_TAG=$(FROM_TAG) \
--build-arg PHP_DEV=$(PHP_DEV) \
--build-arg PHP_DEBUG=$(PHP_DEBUG) \
--build-arg WODBY_USER_ID=$(WODBY_USER_ID) \
--build-arg WODBY_GROUP_ID=$(WODBY_GROUP_ID) \
./

test:
Expand Down
13 changes: 11 additions & 2 deletions 5.6/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ FROM wodby/base-php:${FROM_TAG}
ARG PHP_DEV
ARG PHP_DEBUG

ARG WODBY_USER_ID=1000
ARG WODBY_GROUP_ID=1000

ENV PHP_DEV="${PHP_DEV}" \
PHP_DEBUG="${PHP_DEBUG}" \
SSHD_PERMIT_USER_ENV="yes" \
Expand Down Expand Up @@ -53,8 +56,14 @@ ENV APP_ROOT="/var/www/html" \

RUN set -xe; \
\
addgroup -g 1000 -S wodby; \
adduser -u 1000 -D -S -s /bin/bash -G wodby wodby; \
# Delete existing user/group if uid/gid occupied.
existing_group=$(getent group "${WODBY_GROUP_ID}" | cut -d: -f1); \
if [[ -n "${existing_group}" ]]; then delgroup "${existing_group}"; fi; \
existing_user=$(getent passwd "${WODBY_USER_ID}" | cut -d: -f1); \
if [[ -n "${existing_user}" ]]; then deluser "${existing_user}"; fi; \
\
addgroup -g "${WODBY_GROUP_ID}" -S wodby; \
adduser -u "${WODBY_USER_ID}" -D -S -s /bin/bash -G wodby wodby; \
adduser wodby www-data; \
sed -i '/^wodby/s/!/*/' /etc/shadow; \
echo "PS1='\w\$ '" >> /home/wodby/.bashrc; \
Expand Down
5 changes: 5 additions & 0 deletions 5.6/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ REPO = wodby/php
NAME = php-$(PHP_VER_MINOR)
FROM_TAG = $(PHP_VER)

WODBY_USER_ID ?= 1000
WODBY_GROUP_ID ?= 1000

ifeq ($(TAG),)
ifneq ($(PHP_DEBUG),)
TAG ?= $(PHP_VER_MINOR)-debug
Expand Down Expand Up @@ -42,6 +45,8 @@ build:
--build-arg FROM_TAG=$(FROM_TAG) \
--build-arg PHP_DEV=$(PHP_DEV) \
--build-arg PHP_DEBUG=$(PHP_DEBUG) \
--build-arg WODBY_USER_ID=$(WODBY_USER_ID) \
--build-arg WODBY_GROUP_ID=$(WODBY_GROUP_ID) \
./

test:
Expand Down
13 changes: 11 additions & 2 deletions 7/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ FROM wodby/base-php:${FROM_TAG}
ARG PHP_DEV
ARG PHP_DEBUG

ARG WODBY_USER_ID=1000
ARG WODBY_GROUP_ID=1000

ENV PHP_DEV="${PHP_DEV}" \
PHP_DEBUG="${PHP_DEBUG}" \
SSHD_PERMIT_USER_ENV="yes" \
Expand Down Expand Up @@ -56,8 +59,14 @@ ENV APP_ROOT="/var/www/html" \

RUN set -xe; \
\
addgroup -g 1000 -S wodby; \
adduser -u 1000 -D -S -s /bin/bash -G wodby wodby; \
# Delete existing user/group if uid/gid occupied.
existing_group=$(getent group "${WODBY_GROUP_ID}" | cut -d: -f1); \
if [[ -n "${existing_group}" ]]; then delgroup "${existing_group}"; fi; \
existing_user=$(getent passwd "${WODBY_USER_ID}" | cut -d: -f1); \
if [[ -n "${existing_user}" ]]; then deluser "${existing_user}"; fi; \
\
addgroup -g "${WODBY_GROUP_ID}" -S wodby; \
adduser -u "${WODBY_USER_ID}" -D -S -s /bin/bash -G wodby wodby; \
adduser wodby www-data; \
sed -i '/^wodby/s/!/*/' /etc/shadow; \
echo "PS1='\w\$ '" >> /home/wodby/.bashrc; \
Expand Down
5 changes: 5 additions & 0 deletions 7/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ REPO = wodby/php
NAME = php-$(PHP_VER_MINOR)
FROM_TAG = $(PHP_VER)

WODBY_USER_ID ?= 1000
WODBY_GROUP_ID ?= 1000

ifeq ($(TAG),)
ifneq ($(PHP_DEBUG),)
TAG ?= $(PHP_VER_MINOR)-debug
Expand Down Expand Up @@ -42,6 +45,8 @@ build:
--build-arg FROM_TAG=$(FROM_TAG) \
--build-arg PHP_DEV=$(PHP_DEV) \
--build-arg PHP_DEBUG=$(PHP_DEBUG) \
--build-arg WODBY_USER_ID=$(WODBY_USER_ID) \
--build-arg WODBY_GROUP_ID=$(WODBY_GROUP_ID) \
./

test:
Expand Down

0 comments on commit 59e73c2

Please sign in to comment.