ActivityPub-federated video streaming platform using P2P directly in your web browser
use gosu to fix /data permissions errors
Florent Poinsaut399d20eae6ec
diff --git a/support/doc/docker.md b/support/doc/docker.mdindex 3d25d06c46..e0c03a1dc2 100644--- a/support/doc/docker.md+++ b/support/doc/docker.md@@ -50,18 +50,6 @@ balancer, although any HTTP reverse proxy will work fine. See the exampleNginx configuration `support/nginx/peertube` file to get an idea ofrecommendations and requirements to run PeerTube the most efficiently.-When starting the containers for the first time, you will get permissions errors for the data volume, like this one:--```-Error: EACCES: permission denied, mkdir '/data/logs'-```--The peertube user inside the container has a UID and GID of 991 so you have to change the folder's owner, in the case you're using `./data`:--```-chown -R 991:991 data/-```-**Important**: note that you'll get the initial `root` user password from theprogram output, so check out your logs to find them.diff --git a/support/docker/production/Dockerfile.stretch b/support/docker/production/Dockerfile.stretchindex b1905b3a8a..bf2bae510d 100644--- a/support/docker/production/Dockerfile.stretch+++ b/support/docker/production/Dockerfile.stretch@@ -1,13 +1,45 @@FROM node:8-stretch+RUN set -ex; \+ if ! command -v gpg > /dev/null; then \+ apt-get update; \+ apt-get install -y --no-install-recommends \+ gnupg \+ dirmngr \+ ; \+ rm -rf /var/lib/apt/lists/*; \+fi+# Install dependenciesRUN apt-get update \&& apt-get -y install ffmpeg \&& rm /var/lib/apt/lists/* -fR# Add peertube user-RUN groupadd -g 991 peertube \- && useradd -u 991 -g peertube -m peertube+RUN groupadd -r peertube \+ && useradd -r -g peertube -m peertube++# grab gosu for easy step-down from root+# https://github.com/tianon/gosu/releases+ENV GOSU_VERSION 1.10+RUN set -ex; \+ \+ fetchDeps='ca-certificates wget'; \+ apt-get update; \+ apt-get install -y --no-install-recommends $fetchDeps; \+ rm -rf /var/lib/apt/lists/*; \+ \+ dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')"; \+ wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch"; \+ wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch.asc"; \+ export GNUPGHOME="$(mktemp -d)"; \+ gpg --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4; \+ gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu; \+ rm -r "$GNUPGHOME" /usr/local/bin/gosu.asc; \+ chmod +x /usr/local/bin/gosu; \+ gosu nobody true; \+ \+ apt-get purge -y --auto-remove wget# Download the latest versionRUN git clone https://github.com/Chocobozzz/PeerTube /app \@@ -25,7 +57,13 @@ RUN cp /app/config/default.yaml /app/support/docker/production/config/default.yaENV NODE_ENV productionENV NODE_CONFIG_DIR /app/support/docker/production/config+USER root+RUN mkdir /data && chown peertube:peertube /data+VOLUME /data++COPY docker-entrypoint.sh /usr/local/bin/+ENTRYPOINT ["docker-entrypoint.sh"]+# Run the applicationCMD ["npm", "start"]-VOLUME ["/data"]EXPOSE 9000diff --git a/support/docker/production/docker-entrypoint.sh b/support/docker/production/docker-entrypoint.shnew file mode 100644index 0000000000..79f0e60f65--- /dev/null+++ b/support/docker/production/docker-entrypoint.sh@@ -0,0 +1,16 @@+#!/bin/sh+set -e++# first arg is `-f` or `--some-option`+# or first arg is `something.conf`+if [ "${1#-}" != "$1" ] || [ "${1%.conf}" != "$1" ]; then+ set -- npm "$@"+fi++# allow the container to be started with `--user`+if [ "$1" = 'npm' -a "$(id -u)" = '0' ]; then+ chown -R peertube: /data+ exec gosu peertube "$0" "$@"+fi++exec "$@"