diff options
-rw-r--r-- | Dockerfile | 11 | ||||
-rw-r--r-- | README.md | 34 | ||||
-rw-r--r-- | docker-entrypoint.sh | 18 |
3 files changed, 61 insertions, 2 deletions
@@ -5,7 +5,6 @@ COPY ui ./ RUN npm ci && \
node_modules/.bin/ng build --prod
-
FROM python:3.8-alpine
WORKDIR /app
@@ -17,15 +16,23 @@ RUN apk add --update ffmpeg && \ 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 DOWNLOAD_DIR /downloads
ENV STATE_DIR /downloads/.metube
VOLUME /downloads
EXPOSE 8081
-CMD ["python3", "app/main.py"]
+ENTRYPOINT [ "/opt/scripts/docker-entrypoint.sh" ]
@@ -9,12 +9,45 @@ 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
```
## 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:
@@ -28,6 +61,7 @@ services: volumes:
- /path/to/downloads:/downloads
```
+
## Configuration via environment variables
Certain values can be set via environment variables, using the `-e` parameter on the docker command line, or the `environment:` section in docker-compose.
diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100644 index 0000000..3c6dc08 --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +echo "You are running with user `id -u`:`id -g`" + +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" + fi + echo "Setting umask to ${UMASK}" + umask ${UMASK} + mkdir -p "${DOWNLOAD_DIR}" "${STATE_DIR}" + chown -R "${UID}":"${GID}" /app "${DOWNLOAD_DIR}" "${STATE_DIR}" + su-exec "${UID}":"${GID}" python3 app/main.py +else + echo "Running in Legacy Mode" + python3 app/main.py +fi |