diff options
-rw-r--r-- | Dockerfile | 18 | ||||
-rw-r--r-- | README.md | 40 | ||||
-rw-r--r-- | docker-entrypoint.sh | 15 |
3 files changed, 20 insertions, 53 deletions
@@ -5,34 +5,32 @@ COPY ui ./ RUN npm ci && \
node_modules/.bin/ng build --prod
+
FROM python:3.8-alpine
WORKDIR /app
-COPY Pipfile* ./
+COPY Pipfile* docker-entrypoint.sh ./
-RUN apk add --update ffmpeg && \
+RUN chmod +x docker-entrypoint.sh && \
+ apk add --update ffmpeg coreutils shadow su-exec && \
apk add --update --virtual .build-deps gcc g++ musl-dev && \
pip install --no-cache-dir pipenv && \
pipenv install --system --deploy --clear && \
pip uninstall pipenv -y && \
- apk add --update coreutils shadow su-exec && \
apk del .build-deps && \
rm -rf /var/cache/apk/*
-ADD docker-entrypoint.sh /opt/scripts/docker-entrypoint.sh
-RUN chmod +x /opt/scripts/docker-entrypoint.sh
-
COPY favicon ./favicon
COPY app ./app
COPY --from=builder /metube/dist/metube ./ui/dist/metube
-ENV UID=0
-ENV GID=0
-ENV UMASK=000
+ENV UID=1000
+ENV GID=1000
+ENV UMASK=022
ENV DOWNLOAD_DIR /downloads
ENV STATE_DIR /downloads/.metube
VOLUME /downloads
EXPOSE 8081
-ENTRYPOINT [ "/opt/scripts/docker-entrypoint.sh" ]
+CMD [ "./docker-entrypoint.sh" ]
@@ -9,45 +9,11 @@ Web GUI for youtube-dl (using the [yt-dlp](https://github.com/yt-dlp/yt-dlp) for ## Run using Docker
-### New Mode(recommend)
-
-```bash
-docker run -d -p 8081:8081 -v /path/to/downloads:/downloads -e UID=1001 -e GID=1001 -e UMASK=000 alexta69/metube
-```
-
-***Warning, if you also set the `--user` parameter, the `UID` and `GID` environment variable will be invalid. And it will run in legacy mode.***
-
-### Legacy Mode(not recommend)
-
```bash
-docker run -d -p 8081:8081 -v /path/to/downloads:/downloads --user 1001:1001 alexta69/metube
+docker run -d -p 8081:8081 -v /path/to/downloads:/downloads alexta69/metube
```
-
## Run using docker-compose
-### New Mode(recommend)
-
-```yaml
-version: "3"
-services:
- metube:
- image: alexta69/metube
- container_name: metube
- restart: unless-stopped
- environment:
- - UID=1001
- - GID=1001
- - UMASK=000
- ports:
- - "8081:8081"
- volumes:
- - /path/to/downloads:/downloads
-```
-
-***Warning, if you also set the `--user` parameter, the `UID` and `GID` environment variable will be invalid. And it will run in legacy mode.***
-
-### Legacy Mode(not recommend)
-
```yaml
version: "3"
services:
@@ -55,7 +21,6 @@ services: image: alexta69/metube
container_name: metube
restart: unless-stopped
- user: "1001:1001"
ports:
- "8081:8081"
volumes:
@@ -66,6 +31,9 @@ services: Certain values can be set via environment variables, using the `-e` parameter on the docker command line, or the `environment:` section in docker-compose.
+* __UID__: user under which MeTube will run. Defaults to `1000`.
+* __GID__: group under which MeTube will run. Defaults to `1000`.
+* __UMASK__: umask value used by MeTube. Defaults to `022`.
* __DOWNLOAD_DIR__: path to where the downloads will be saved. Defaults to `/downloads` in the docker image, and `.` otherwise.
* __AUDIO_DOWNLOAD_DIR__: path to where audio-only downloads will be saved, if you wish to separate them from the video downloads. Defaults to the value of `DOWNLOAD_DIR`.
* __STATE_DIR__: path to where the queue persistence files will be saved. Defaults to `/downloads/.metube` in the docker image, and `.` otherwise.
diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 3c6dc08..ccf58d7 100644 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -1,18 +1,19 @@ #!/bin/sh -echo "You are running with user `id -u`:`id -g`" +echo "Setting umask to ${UMASK}" +umask ${UMASK} +echo "Creating download directory ${DOWNLOAD_DIR} and state directory ${STATE_DIR}" +mkdir -p "${DOWNLOAD_DIR}" "${STATE_DIR}" if [ `id -u` -eq 0 ] && [ `id -g` -eq 0 ]; then - echo "Running in New Mode" if [ "${UID}" -eq 0 ]; then - echo "Warning, it is not recommended to run as root user, please check if you have set the UID environment variable" + echo "Warning: it is not recommended to run as root user, please check your setting of the UID environment variable" fi - echo "Setting umask to ${UMASK}" - umask ${UMASK} - mkdir -p "${DOWNLOAD_DIR}" "${STATE_DIR}" + echo "Changing ownership of download and state directories to ${UID}:${GID}" chown -R "${UID}":"${GID}" /app "${DOWNLOAD_DIR}" "${STATE_DIR}" + echo "Running MeTube as user ${UID}:${GID}" su-exec "${UID}":"${GID}" python3 app/main.py else - echo "Running in Legacy Mode" + echo "User set by docker; running MeTube as `id -u`:`id -g`" python3 app/main.py fi |