chore: remove ability to define custom UID/GID at container creation

This commit is contained in:
Michael Serajnik 2020-01-07 00:32:00 +01:00
parent 89ec63b24f
commit 96ddca1cce
No known key found for this signature in database
GPG Key ID: B390A5CBA3ECB74D
5 changed files with 32 additions and 41 deletions

View File

@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## [Unreleased] ## [Unreleased]
### Removed
+ Removed the ability to define custom UID and GID for the Docker container at
container creation due to several issues arising from that
## [3.22.0] - 2020-01-05 ## [3.22.0] - 2020-01-05
### Added ### Added

View File

@ -1,16 +1,18 @@
FROM python:3.8-slim-buster FROM python:3.8-slim-buster
ARG USER_ID=1000
ARG GROUP_ID=1000
ENV \
USER_ID=$USER_ID \
GROUP_ID=$GROUP_ID
WORKDIR /usr/src/app WORKDIR /usr/src/app
COPY ./hydrus . COPY ./hydrus .
COPY ./deb . COPY ./deb .
RUN \ RUN \
chmod +x \
server.py \
bin/swfrender_linux \
bin/upnpc_linux && \
mkdir /data && \
apt-get update && apt-get install --no-install-recommends -y \ apt-get update && apt-get install --no-install-recommends -y \
build-essential \ build-essential \
ffmpeg \ ffmpeg \
@ -41,13 +43,16 @@ RUN \
rm -r ~/.cache && \ rm -r ~/.cache && \
apt-get remove build-essential --purge -y && \ apt-get remove build-essential --purge -y && \
apt-get clean && apt-get autoremove --purge -y && \ apt-get clean && apt-get autoremove --purge -y && \
rm -rf /var/lib/apt/lists/* rm -rf /var/lib/apt/lists/* && \
chown -R ${USER_ID}:${GROUP_ID} /usr/src/app && \
chmod +x \
server.py \
bin/swfrender_linux \
bin/upnpc_linux && \
mkdir /data && chown -R ${USER_ID}:${GROUP_ID} /data
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint COPY docker-cmd-start.sh /usr/local/bin/start
COPY docker-start.sh /usr/local/bin/docker-start RUN chmod +x /usr/local/bin/start
RUN \
chmod +x /usr/local/bin/docker-entrypoint && \
chmod +x /usr/local/bin/docker-start
EXPOSE 45870/tcp 45871/tcp 45872/tcp EXPOSE 45870/tcp 45871/tcp 45872/tcp
@ -57,5 +62,6 @@ HEALTHCHECK --interval=1m --timeout=10s --retries=3 \
VOLUME /data VOLUME /data
ENTRYPOINT ["docker-entrypoint"] USER ${USER_ID}:${GROUP_ID}
CMD ["docker-start"]
CMD ["start"]

View File

@ -17,7 +17,6 @@ The latest build runs [hydrus server version 379][hydrus-server-version].
+ [Usage](#usage) + [Usage](#usage)
+ [Ports](#ports) + [Ports](#ports)
+ [Storage](#storage) + [Storage](#storage)
+ [UID/GID](#uidgid)
+ [Donate](#donate) + [Donate](#donate)
+ [Maintainer](#maintainer) + [Maintainer](#maintainer)
+ [Contribute](#contribute) + [Contribute](#contribute)
@ -38,9 +37,7 @@ specific version of hydrus server, provide the version number as tag, e.g.:
user@local:~$ docker pull mserajnik/hydrus-server-docker:379 user@local:~$ docker pull mserajnik/hydrus-server-docker:379
``` ```
See [here][docker-hub-tags] for all the available version numbers/tags. Alternatively, you can also build the image yourself:
Alternatively, you can clone this repository and build the image yourself:
```zsh ```zsh
user@local:~$ git clone --recurse-submodules https://github.com/mserajnik/hydrus-server-docker.git user@local:~$ git clone --recurse-submodules https://github.com/mserajnik/hydrus-server-docker.git
@ -48,6 +45,10 @@ user@local:~$ cd hydrus-server-docker
user@local:hydrus-server-docker$ docker build . -t hydrus-server-docker user@local:hydrus-server-docker$ docker build . -t hydrus-server-docker
``` ```
The user that is used inside the container has UID `1000` and GID `1000` by
default. You can adjust this (e.g., to match your host UID/GID) by providing
the arguments `USER_ID` and `GROUP_ID` when making a build.
### Dependencies ### Dependencies
+ [Docker][docker] + [Docker][docker]
@ -118,22 +119,11 @@ mount that over it:
user@local:~$ docker volume create hydrus-server-data user@local:~$ docker volume create hydrus-server-data
``` ```
### UID/GID After creating your named volume, you can run the container. Here is a full
example with all the options mentioned above:
The user that owns the data and runs the server inside the container has the
UID `1000` and the GID `1000` by default. You can change these by providing the
environment variables `CUSTOM_UID` and `CUSTOM_GID` when creating a container.
This is useful if you want to access the data outside the container with a user
with different IDs without hassle. In such a case, `CUSTOM_UID` and
`CUSTOM_GID` should match the user that is going to access the data on the
host.
Here is a full example for running the container with all the options mentioned
above:
```zsh ```zsh
user@local:~$ docker run -p 45870:45870 -p 45871:45871 -p 45872:45872 -v hydrus-server-data:/data -e CUSTOM_UID=1000 -e CUSTOM_GID=1000 -d mserajnik/hydrus-server-docker user@local:~$ docker run -p 45870:45870 -p 45871:45871 -p 45872:45872 -v hydrus-server-data:/data -d mserajnik/hydrus-server-docker
``` ```
Specifying the same named volume every time a container is created gives each Specifying the same named volume every time a container is created gives each

View File

@ -1,10 +0,0 @@
#!/bin/bash
USER_ID=${CUSTOM_UID:-1000}
GROUP_ID=${CUSTOM_GID:-1000}
echo "Setting permissions to UID/GID ${USER_ID}/${GROUP_ID}."
chown ${USER_ID}:${GROUP_ID} -R /usr/src/app
chown ${USER_ID}:${GROUP_ID} -R /data
exec gosu ${USER_ID}:${GROUP_ID} "$@"