Skip to content

Commit 6802e17

Browse files
authored
Merge pull request #32 from specsnl/add-default-user-and-fixuid
Add default user code and fixuid tool and config
2 parents 29fd31a + 8f45623 commit 6802e17

4 files changed

Lines changed: 134 additions & 0 deletions

File tree

‎.github/prompts/update-project.prompt.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ All three Dockerfiles share the same versions for the following builder-stage to
100100
`composer/composer`
101101
- `XDEBUG_VERSION` — `xdebug/xdebug` on Packagist
102102
- `PCOV_VERSION` — `pecl/pcov` on Packagist
103+
- `FIXUID_VERSION` — check the GitHub Releases API for `boxboat/fixuid`
103104

104105
Process each tool individually and in order:
105106

‎apache/Dockerfile‎

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,50 @@ RUN apt-get update \
185185
&& rm -rf /var/lib/apt/lists/* \
186186
&& rm -rf /tmp/*
187187

188+
# Latest version of fixuid: https://github.com/boxboat/fixuid/releases/latest
189+
ARG FIXUID_VERSION=0.6.0
190+
191+
ARG USER=code
192+
ARG GROUP=code
193+
ARG USER_UID=1000
194+
ARG USER_GID=1000
195+
ARG TARGETARCH
196+
197+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
198+
199+
RUN curl -fsSLo /tmp/fixuid.tar.gz "https://github.com/boxboat/fixuid/releases/download/v$FIXUID_VERSION/fixuid-${FIXUID_VERSION}-linux-${TARGETARCH}.tar.gz" \
200+
&& tar -xf /tmp/fixuid.tar.gz -C /usr/local/bin fixuid \
201+
&& chown root:root /usr/local/bin/fixuid \
202+
&& chmod 4755 /usr/local/bin/fixuid \
203+
&& rm /tmp/fixuid.tar.gz \
204+
# Create user and group, and setup fixuid configuration
205+
&& existing_group="$(getent group "$USER_GID" | cut -d: -f1 || true)" \
206+
&& if [ -z "$existing_group" ]; then \
207+
groupadd --gid "$USER_GID" "$GROUP"; \
208+
existing_group="$GROUP"; \
209+
fi \
210+
&& useradd --uid "$USER_UID" --gid "$USER_GID" --create-home "$USER" --shell /bin/bash \
211+
&& mkdir -p \
212+
/etc/fixuid \
213+
"/data" \
214+
"/config" \
215+
"/cache" \
216+
&& chown -R "$USER_UID":"$USER_GID" \
217+
"/data" \
218+
"/config" \
219+
"/cache" \
220+
&& cat <<EOF > /etc/fixuid/config.yml
221+
user: $USER
222+
group: $existing_group
223+
paths:
224+
- /var/www
225+
- /home/$USER
226+
- /data
227+
- /config
228+
- /cache
229+
230+
EOF
231+
188232
FROM builder AS builder_nodejs
189233

190234
ARG TARGETARCH

‎fpm/Dockerfile‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ ARG XDEBUG_VERSION=3.5.1
148148
# Latest version of pcov: https://packagist.org/packages/pecl/pcov
149149
ARG PCOV_VERSION=1.0.12
150150

151+
151152
RUN apt-get update \
152153
&& apt-get install --assume-yes --no-install-recommends \
153154
# Needed for xdebug extension configuration
@@ -185,6 +186,50 @@ RUN apt-get update \
185186
&& rm -rf /var/lib/apt/lists/* \
186187
&& rm -rf /tmp/*
187188

189+
# Latest version of fixuid: https://github.com/boxboat/fixuid/releases/latest
190+
ARG FIXUID_VERSION=0.6.0
191+
192+
ARG USER=code
193+
ARG GROUP=code
194+
ARG USER_UID=1000
195+
ARG USER_GID=1000
196+
ARG TARGETARCH
197+
198+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
199+
200+
RUN curl -fsSLo /tmp/fixuid.tar.gz "https://github.com/boxboat/fixuid/releases/download/v$FIXUID_VERSION/fixuid-${FIXUID_VERSION}-linux-${TARGETARCH}.tar.gz" \
201+
&& tar -xf /tmp/fixuid.tar.gz -C /usr/local/bin fixuid \
202+
&& chown root:root /usr/local/bin/fixuid \
203+
&& chmod 4755 /usr/local/bin/fixuid \
204+
&& rm /tmp/fixuid.tar.gz \
205+
# Create user and group, and setup fixuid configuration
206+
&& existing_group="$(getent group "$USER_GID" | cut -d: -f1 || true)" \
207+
&& if [ -z "$existing_group" ]; then \
208+
groupadd --gid "$USER_GID" "$GROUP"; \
209+
existing_group="$GROUP"; \
210+
fi \
211+
&& useradd --uid "$USER_UID" --gid "$USER_GID" --create-home "$USER" --shell /bin/bash \
212+
&& mkdir -p \
213+
/etc/fixuid \
214+
"/data" \
215+
"/config" \
216+
"/cache" \
217+
&& chown -R "$USER_UID":"$USER_GID" \
218+
"/data" \
219+
"/config" \
220+
"/cache" \
221+
&& cat <<EOF > /etc/fixuid/config.yml
222+
user: $USER
223+
group: $existing_group
224+
paths:
225+
- /var/www
226+
- /home/$USER
227+
- /data
228+
- /config
229+
- /cache
230+
231+
EOF
232+
188233
FROM builder AS builder_nodejs
189234

190235
ARG TARGETARCH

‎frankenphp/Dockerfile‎

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,50 @@ RUN apt-get update \
189189
&& rm -rf /var/lib/apt/lists/* \
190190
&& rm -rf /tmp/*
191191

192+
# Latest version of fixuid: https://github.com/boxboat/fixuid/releases/latest
193+
ARG FIXUID_VERSION=0.6.0
194+
195+
ARG USER=code
196+
ARG GROUP=code
197+
ARG USER_UID=1000
198+
ARG USER_GID=1000
199+
ARG TARGETARCH
200+
201+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
202+
203+
RUN curl -fsSLo /tmp/fixuid.tar.gz "https://github.com/boxboat/fixuid/releases/download/v$FIXUID_VERSION/fixuid-${FIXUID_VERSION}-linux-${TARGETARCH}.tar.gz" \
204+
&& tar -xf /tmp/fixuid.tar.gz -C /usr/local/bin fixuid \
205+
&& chown root:root /usr/local/bin/fixuid \
206+
&& chmod 4755 /usr/local/bin/fixuid \
207+
&& rm /tmp/fixuid.tar.gz \
208+
# Create user and group, and setup fixuid configuration
209+
&& existing_group="$(getent group "$USER_GID" | cut -d: -f1 || true)" \
210+
&& if [ -z "$existing_group" ]; then \
211+
groupadd --gid "$USER_GID" "$GROUP"; \
212+
existing_group="$GROUP"; \
213+
fi \
214+
&& useradd --uid "$USER_UID" --gid "$USER_GID" --create-home "$USER" --shell /bin/bash \
215+
&& mkdir -p \
216+
/etc/fixuid \
217+
"/data" \
218+
"/config" \
219+
"/cache" \
220+
&& chown -R "$USER_UID":"$USER_GID" \
221+
"/data" \
222+
"/config" \
223+
"/cache" \
224+
&& cat <<EOF > /etc/fixuid/config.yml
225+
user: $USER
226+
group: $existing_group
227+
paths:
228+
- /var/www
229+
- /home/$USER
230+
- /data
231+
- /config
232+
- /cache
233+
234+
EOF
235+
192236
FROM builder AS builder_nodejs
193237

194238
ARG TARGETARCH

0 commit comments

Comments
 (0)