This commit is contained in:
Виктор Диктор 2023-11-16 23:17:30 +03:00 committed by GitHub
commit d2966178e5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 90 additions and 5 deletions

18
Dockerfile-dev-backend Normal file
View file

@ -0,0 +1,18 @@
FROM python:3.8-alpine
COPY . /app
WORKDIR /app
RUN apk add --update ffmpeg && \
apk add --update --virtual .build-deps gcc musl-dev && \
pip install --no-cache-dir pipenv && \
pipenv install --system --deploy --clear && \
pip uninstall pipenv -y && \
apk del .build-deps && \
rm -rf /var/cache/apk/*
ENV DOWNLOAD_DIR /downloads
VOLUME /downloads
EXPOSE 8081
CMD ["python3", "app/main.py"]

10
Dockerfile-dev-frontend Normal file
View file

@ -0,0 +1,10 @@
FROM node:16-alpine
COPY ./ui /app
WORKDIR /app
RUN npm ci && \
node_modules/.bin/ng build
CMD ["node_modules/.bin/ng", "build", "--watch"]

16
Makefile Normal file
View file

@ -0,0 +1,16 @@
.PHONY: serve-dev build build-dev attach-dev-frontend attach-dev-backend
serve-dev:
docker-compose up
attach-dev-frontend:
docker exec -it -t metube-dev-frontend /bin/sh
attach-dev-backend:
docker exec -it -t metube-dev-backend /bin/sh
build-dev:
docker-compose build
build:
docker build -t metube .

View file

@ -211,6 +211,23 @@ Once there, you can use the yt-dlp command freely.
## Building and running locally ## Building and running locally
A Docker image can be built locally (it will build the UI too):
```bash
make build
```
### Run dev mode with local docker
```bash
make serve-dev
```
It will launch two containers: `metube-dev-frontend` and `metube-dev-backend`. Frontend will be started in watching mode but backend need to be restarted after code changes - `docker restart metube-dev-backend`
After first start `metube-dev-backend` may crashed with error about nonexistent files - it's normal, just wait while frontend will be build and restart backend.
### Run without docker
Make sure you have node.js and Python 3.8 installed. Make sure you have node.js and Python 3.8 installed.
```bash ```bash
@ -226,11 +243,6 @@ pipenv install
pipenv run python3 app/main.py pipenv run python3 app/main.py
``` ```
A Docker image can be built locally (it will build the UI too):
```bash
docker build -t metube .
```
## Development notes ## Development notes

29
docker-compose.yml Normal file
View file

@ -0,0 +1,29 @@
version: "3"
services:
backend:
build:
context: .
dockerfile: Dockerfile-dev-backend
container_name: metube-dev-backend
image: metube-dev-backend
expose:
- 8081
ports:
- "8081:8081"
links:
- frontend
volumes:
- ./ui:/app/ui
- ./app:/app/app
frontend:
build:
context: .
dockerfile: Dockerfile-dev-frontend
container_name: metube-dev-frontend
image: metube-dev-frontend
expose:
- 4200
volumes:
- ./ui:/app