diff --git a/CHANGELOG.md b/CHANGELOG.md index 51f1b03..4d30331 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [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 ### Added diff --git a/Dockerfile b/Dockerfile index 2b97d9e..6905181 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,18 @@ 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 COPY ./hydrus . COPY ./deb . RUN \ - chmod +x \ - server.py \ - bin/swfrender_linux \ - bin/upnpc_linux && \ - mkdir /data && \ apt-get update && apt-get install --no-install-recommends -y \ build-essential \ ffmpeg \ @@ -41,13 +43,16 @@ RUN \ rm -r ~/.cache && \ apt-get remove build-essential --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-start.sh /usr/local/bin/docker-start -RUN \ - chmod +x /usr/local/bin/docker-entrypoint && \ - chmod +x /usr/local/bin/docker-start +COPY docker-cmd-start.sh /usr/local/bin/start +RUN chmod +x /usr/local/bin/start EXPOSE 45870/tcp 45871/tcp 45872/tcp @@ -57,5 +62,6 @@ HEALTHCHECK --interval=1m --timeout=10s --retries=3 \ VOLUME /data -ENTRYPOINT ["docker-entrypoint"] -CMD ["docker-start"] +USER ${USER_ID}:${GROUP_ID} + +CMD ["start"] diff --git a/README.md b/README.md index e234484..4d532af 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,6 @@ The latest build runs [hydrus server version 379][hydrus-server-version]. + [Usage](#usage) + [Ports](#ports) + [Storage](#storage) - + [UID/GID](#uidgid) + [Donate](#donate) + [Maintainer](#maintainer) + [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 ``` -See [here][docker-hub-tags] for all the available version numbers/tags. - -Alternatively, you can clone this repository and build the image yourself: +Alternatively, you can also build the image yourself: ```zsh 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 ``` +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 + [Docker][docker] @@ -118,22 +119,11 @@ mount that over it: user@local:~$ docker volume create hydrus-server-data ``` -### UID/GID - -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: +After creating your named volume, you can run the container. Here is a full +example with all the options mentioned above: ```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 diff --git a/docker-start.sh b/docker-cmd-start.sh similarity index 100% rename from docker-start.sh rename to docker-cmd-start.sh diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh deleted file mode 100644 index 62937a4..0000000 --- a/docker-entrypoint.sh +++ /dev/null @@ -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} "$@"