Use the local user's user id in the container when building and running, otherwise bind mounts don't have the correct ownership.

Correct output from steamcmd to avoid red herrings by creating a directory it expects as well as providing a shared object it also expects.
Update docs.
This commit is contained in:
Daniel Ceregatti 2023-10-12 18:44:37 -07:00
parent 4d546241ad
commit f153f3db18
5 changed files with 27 additions and 6 deletions

View file

@ -31,6 +31,12 @@ git clone https://ceregatti.org/git/daniel/dayzdockerserver.git
cd dayzdockerserver cd dayzdockerserver
``` ```
Create a `.env` file that contains your user id. Usually the `${UID}` shell variable has this:
```shell
echo "export USER_ID=${UID}" | tee .env
```
Build the Docker images: Build the Docker images:
```shell ```shell

View file

@ -19,7 +19,11 @@ volumes:
services: services:
web: web:
build: web build:
context: web
args:
- USER_ID
user: ${USER_ID}
volumes: volumes:
- homedir_main:/home/user - homedir_main:/home/user
- serverfiles:/serverfiles - serverfiles:/serverfiles
@ -37,7 +41,11 @@ services:
- .env - .env
server: server:
build: server build:
context: server
args:
- USER_ID
user: ${USER_ID}
volumes: volumes:
- homedir_server:/home/user - homedir_server:/home/user
- serverfiles:/serverfiles - serverfiles:/serverfiles

View file

@ -37,8 +37,10 @@ ENV PATH /files/bin:/server:${PATH}
RUN cd /usr/local && git clone https://github.com/indepth666/py3rcon.git RUN cd /usr/local && git clone https://github.com/indepth666/py3rcon.git
# Setup a non-privileged user # Setup a non-privileged user
RUN groupadd user && \ ARG USER_ID
useradd -l -g user user && \
RUN groupadd -g ${USER_ID} user && \
useradd -l -u ${USER_ID} -m -g user user && \
mkdir -p /home/user /serverfiles/mpmissions /mods /mpmissions /profiles && \ mkdir -p /home/user /serverfiles/mpmissions /mods /mpmissions /profiles && \
chown -R user:user /home/user /serverfiles /mods /mpmissions /profiles chown -R user:user /home/user /serverfiles /mods /mpmissions /profiles

View file

@ -61,11 +61,16 @@ ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH
RUN cd /usr/local && git clone https://github.com/indepth666/py3rcon.git RUN cd /usr/local && git clone https://github.com/indepth666/py3rcon.git
# Setup a non-privileged user # Setup a non-privileged user
RUN groupadd user && \ ARG USER_ID
useradd -l -g user user && \
RUN groupadd -g ${USER_ID} user && \
useradd -l -u ${USER_ID} -m -g user user && \
mkdir -p /home/user /serverfiles/mpmissions /serverfiles/steamapps/workshop/content /web && \ mkdir -p /home/user /serverfiles/mpmissions /serverfiles/steamapps/workshop/content /web && \
chown -R user:user /home/user /serverfiles /web chown -R user:user /home/user /serverfiles /web
# Shut steamcmd up
RUN cd /usr/lib/i386-linux-gnu && ln -s /web/bin/steamservice.so
# Add our startup script, as this rarely changes. # Add our startup script, as this rarely changes.
COPY --chown=user:user start.sh /usr/local/bin/start.sh COPY --chown=user:user start.sh /usr/local/bin/start.sh

BIN
web/bin/steamservice.so Executable file

Binary file not shown.