Skip to content

Commit

Permalink
reform frontend out of Docker stuff + other Docker
Browse files Browse the repository at this point in the history
+ other Docker things

to get all images on cli:
docker build -t t:latest-celery-fast . --target=celery-fast
docker build -t t:latest-celery-slow . --target=celery-slow
docker build -t t:latest . --target=api
docker build -t t:latest-gpu -f gpu.Dockerfile .
(compose: see docker-compose files)
  • Loading branch information
jtagcat committed Feb 13, 2022
1 parent 1e6ea8a commit d34bd07
Show file tree
Hide file tree
Showing 13 changed files with 61 additions and 100 deletions.
2 changes: 0 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
.git
*Dockerfile*
*docker-compose*
web-entrypoint.sh

docs
env
Expand All @@ -11,5 +10,4 @@ screenshots

frontend/assets/
frontend/node_modules
frontend/src
frontend/webpack-stats.json
40 changes: 31 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,41 @@
FROM python:3.7-buster
FROM python:3.7-buster AS celery-fast

ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

RUN mkdir -p /webapp/media /webapp/staticfiles
WORKDIR /webapp
RUN mkdir -p /webapp/{media,staticfiles}

RUN apt-get update && apt-get install -y --no-install-recommends \
ffmpeg libasound2-dev libsndfile-dev \
&& rm -rf /var/lib/apt/lists/*
COPY requirements.txt /webapp/

# Install all dependencies
RUN apt-get update && apt-get install -y --no-install-recommends ffmpeg libasound2-dev libsndfile-dev && pip install --upgrade pip -r requirements.txt
RUN pip install -r requirements.txt

COPY . .

# Copy over entrypoint script
COPY api-entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/api-entrypoint.sh && ln -s /usr/local/bin/api-entrypoint.sh /
ENTRYPOINT ["api-entrypoint.sh"]

COPY celery-fast-entrypoint.sh .
ENTRYPOINT ["./celery-fast-entrypoint.sh"]

FROM celery-fast AS celery-slow
COPY celery-slow-entrypoint.sh .
ENTRYPOINT ["./celery-slow-entrypoint.sh"]


FROM node:14-buster AS frontend
WORKDIR /webapp/frontend
RUN mkdir -p /webapp/frontend/assets

COPY frontend/package.json .
COPY frontend/package-lock.json .
RUN npm install

COPY frontend/ .
RUN ./entrypoint.sh


FROM celery-fast AS api
COPY --from=frontend /webapp/frontend/assets /webapp/frontend/assets
COPY api-entrypoint.sh .
ENTRYPOINT ["./api-entrypoint.sh"]
5 changes: 0 additions & 5 deletions api-entrypoint.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@

# Collect static files
if [[ -z "${DJANGO_DEVELOPMENT}" ]]; then
echo "Waiting for asset creation"
while [ ! -d /webapp/frontend/assets/dist ]; do
sleep 1
done
echo "Collect static files"
python3.7 manage.py collectstatic --noinput
fi

Expand Down
9 changes: 2 additions & 7 deletions docker-compose.build.gpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,11 @@ services:
nginx:
build: ./nginx
api:
build:
context: .
dockerfile: gpu.Dockerfile
build: .
celery-fast:
build:
context: .
dockerfile: gpu.Dockerfile
target: celery-fast
celery-slow:
build:
context: .
dockerfile: gpu.Dockerfile
frontend:
build: ./frontend
5 changes: 3 additions & 2 deletions docker-compose.build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ services:
build: ./nginx
api:
build: .
target: api
celery-fast:
build: .
target: celery-fast
celery-slow:
build: .
frontend:
build: ./frontend
target: celery-slow
6 changes: 0 additions & 6 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,3 @@ services:
volumes:
- ./api:/webapp/api
- ./media:/webapp/media
frontend:
environment:
- DJANGO_DEVELOPMENT=true
volumes:
- ./frontend/src:/webapp/frontend/src
restart: always
17 changes: 3 additions & 14 deletions docker-compose.gpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,8 @@ services:
- api
restart: always
api:
image: jeffreyca/spleeter-web-backend:${TAG:-latest}-gpu
image: jeffreyca/spleeter-web-backend:${TAG:-latest}
volumes:
- assets:/webapp/frontend/assets
- sqlite-data:/webapp/sqlite
- staticfiles:/webapp/staticfiles
stdin_open: true
Expand All @@ -59,11 +58,9 @@ services:
- YOUTUBE_API_KEY
depends_on:
- redis
- frontend
restart: always
celery-fast:
image: jeffreyca/spleeter-web-backend:${TAG:-latest}-gpu
entrypoint: ./celery-fast-entrypoint.sh
image: jeffreyca/spleeter-web-backend:${TAG:-latest}-celery-fast
volumes:
- celery-data:/webapp/celery
- pretrained-models:/webapp/pretrained_models
Expand All @@ -74,8 +71,7 @@ services:
- redis
restart: always
celery-slow:
image: jeffreyca/spleeter-web-backend:${TAG:-latest}-gpu
entrypoint: ./celery-slow-entrypoint.sh
image: jeffreyca/spleeter-web-celery-slow:${TAG:-latest}-gpu
volumes:
- celery-data:/webapp/celery
- pretrained-models:/webapp/pretrained_models
Expand All @@ -85,14 +81,7 @@ services:
depends_on:
- redis
restart: always
frontend:
image: jeffreyca/spleeter-web-frontend:${TAG:-latest}
volumes:
- assets:/webapp/frontend/assets
stdin_open: true
tty: true
volumes:
assets:
celery-data:
pretrained-models:
redis-data:
Expand Down
2 changes: 0 additions & 2 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,3 @@ services:
api:
expose:
- "8000"
frontend:
restart: "no"
15 changes: 2 additions & 13 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ services:
api:
image: jeffreyca/spleeter-web-backend:${TAG:-latest}
volumes:
- assets:/webapp/frontend/assets
- sqlite-data:/webapp/sqlite
- staticfiles:/webapp/staticfiles
stdin_open: true
Expand All @@ -57,11 +56,9 @@ services:
- YOUTUBE_API_KEY
depends_on:
- redis
- frontend
restart: always
celery-fast:
image: jeffreyca/spleeter-web-backend:${TAG:-latest}
entrypoint: ./celery-fast-entrypoint.sh
image: jeffreyca/spleeter-web-backend:${TAG:-latest}-celery-fast
volumes:
- celery-data:/webapp/celery
- pretrained-models:/webapp/pretrained_models
Expand All @@ -73,8 +70,7 @@ services:
- "8.8.8.8"
restart: always
celery-slow:
image: jeffreyca/spleeter-web-backend:${TAG:-latest}
entrypoint: ./celery-slow-entrypoint.sh
image: jeffreyca/spleeter-web-backend:${TAG:-latest}-celery-slow
volumes:
- celery-data:/webapp/celery
- pretrained-models:/webapp/pretrained_models
Expand All @@ -83,14 +79,7 @@ services:
depends_on:
- redis
restart: always
frontend:
image: jeffreyca/spleeter-web-frontend:${TAG:-latest}
volumes:
- assets:/webapp/frontend/assets
stdin_open: true
tty: true
volumes:
assets:
celery-data:
pretrained-models:
redis-data:
Expand Down
17 changes: 0 additions & 17 deletions frontend/Dockerfile

This file was deleted.

7 changes: 7 additions & 0 deletions frontend/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

if [ -z "${DJANGO_DEVELOPMENT}" ]; then
npm run build
else
npm run dev
fi
9 changes: 0 additions & 9 deletions frontend/frontend-entrypoint.sh

This file was deleted.

27 changes: 13 additions & 14 deletions gpu.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

# Install all dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
RUN apt-get update && apt-get install -y --no-install-recommends \
software-properties-common \
curl \
ffmpeg \
Expand All @@ -18,22 +17,22 @@ RUN apt-get update \
rsync \
ssh \
wget \
&& add-apt-repository universe \
&& apt-get update \
&& apt-get -y install python3.7 python3.7-gdbm python3-distutils \
&& curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py \
&& add-apt-repository universe && apt-get update && apt-get install -y \
python3.7 \
python3.7-gdbm \
python3-distutils \
&& rm -rf /var/lib/apt/lists/*
RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py \
&& python3.7 get-pip.py \
&& ln -s /usr/local/cuda-11.2/targets/x86_64-linux/lib/libcudart.so.11.0 /usr/lib/x86_64-linux-gnu/libcudart.so.11.0

RUN mkdir -p /webapp/media /webapp/staticfiles

WORKDIR /webapp
COPY requirements.txt /webapp/
RUN pip3 install --upgrade pip -r requirements.txt
RUN mkdir -p /webapp/{media,staticfiles}

COPY . .
COPY requirements.txt .
RUN pip install -r requirements.txt

COPY api-entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/api-entrypoint.sh && ln -s /usr/local/bin/api-entrypoint.sh /
COPY . .

ENTRYPOINT ["api-entrypoint.sh"]
COPY celery-slow-entrypoint.sh .
ENTRYPOINT ["./celery-slow-entrypoint.sh"]

0 comments on commit d34bd07

Please sign in to comment.