Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added local dev environment via separated docker containers #39

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Dockerfile-dev-backend
Original file line number Diff line number Diff line change
@@ -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 changes: 10 additions & 0 deletions Dockerfile-dev-frontend
Original file line number Diff line number Diff line change
@@ -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 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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 .
22 changes: 17 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,23 @@ If you're using the [linuxserver/swag](https://docs.linuxserver.io/general/swag)

## Build and run 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.

```bash
Expand All @@ -90,11 +107,6 @@ pipenv install
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

Expand Down
29 changes: 29 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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