aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Shnitman <alexta69@gmail.com>2022-06-19 22:15:42 +0300
committerAlex Shnitman <alexta69@gmail.com>2022-06-19 22:19:13 +0300
commitdccf8d5bf67ffbf52584b24f1d8c82eb28e3ce36 (patch)
tree67b4a8a9b752bcd64af49664fb68c0cee6ac76e8
parentMerge branch 'master' of https://github.com/alexta69/metube into VergilGao/ma... (diff)
downloadmetube-dccf8d5bf67ffbf52584b24f1d8c82eb28e3ce36.tar.gz
metube-dccf8d5bf67ffbf52584b24f1d8c82eb28e3ce36.tar.bz2
metube-dccf8d5bf67ffbf52584b24f1d8c82eb28e3ce36.zip
refactor of the entrypoint feature
-rw-r--r--Dockerfile18
-rw-r--r--README.md40
-rw-r--r--docker-entrypoint.sh15
3 files changed, 20 insertions, 53 deletions
diff --git a/Dockerfile b/Dockerfile
index 3f5d490..c959dff 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -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" ]
diff --git a/README.md b/README.md
index 5b32f90..0e1528a 100644
--- a/README.md
+++ b/README.md
@@ -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
bgstack15