diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index e7e0d8b..119b293 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -31,24 +31,6 @@ jobs: base: ${{ github.event.repository.default_branch }} head: HEAD extra_args: --debug --only-verified - - - # Use Caching for npm - - name: Cache node modules - uses: actions/cache@v2 - with: - working-directory: ./ui - path: | - node_modules - key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-npm- - - - name: Install npm dependencies and build UI - run: | - cd ui - npm install - npm run build - name: Login to Docker Hub uses: docker/login-action@v1 @@ -62,7 +44,7 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - - name: Build and push + - name: Build and Push uses: docker/build-push-action@v4 env: VERSION: ${{ env.VERSION }} diff --git a/Dockerfile b/Dockerfile index de7ead5..681641e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,30 +1,36 @@ -FROM python:3.9 +# Build Stage 1 +# Build the UI +FROM node:12 AS node-builder -ENV DOCKER_DEPLOYMENT=1 +WORKDIR /app/ui -RUN pip install torch +COPY ./ui/package.json . +RUN npm install --silent --production -COPY ./app/requirements.txt /tmp/requirements.txt +COPY ./ui . +RUN npm run build -RUN pip install -r /tmp/requirements.txt +# Build Stage 2 +# Builds the backend as well as gets the built UI from Stage 1 +FROM python:3.9 ENV CAPTURE_TELEMETRY=1 -COPY ./app/models.py /tmp/models.py +WORKDIR /app -# cache the models -RUN python3 /tmp/models.py +COPY ./app/requirements.txt . +RUN pip install -r /app/requirements.txt COPY ./app /app -COPY ./ui/build /ui - -COPY ./run.sh /app/run.sh +# Cache the models +COPY ./app/models.py /tmp/models.py +RUN python3 /tmp/models.py -WORKDIR /app +COPY --from=node-builder /app/ui/build /ui +COPY ./run.sh . -VOLUME [ "/opt/storage" ] +ENV DOCKER_DEPLOYMENT=1 EXPOSE 80 - CMD ./run.sh diff --git a/README.md b/README.md index 59baaa0..bf2291e 100644 --- a/README.md +++ b/README.md @@ -82,8 +82,8 @@ add `-d` if you want to detach the container. ## Run from source See CONTRIBUTING.md - - + + - **gerev is also popular with some big names. 😉** --- diff --git a/app/__init__.py b/app/__init__.py index e69de29..8b13789 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -0,0 +1 @@ + diff --git a/app/paths.py b/app/paths.py index f8085b7..ad65a4b 100644 --- a/app/paths.py +++ b/app/paths.py @@ -6,7 +6,7 @@ if os.name == 'nt': STORAGE_PATH = Path(".gerev\\storage") else: - STORAGE_PATH = Path('/opt/storage/') if IS_IN_DOCKER else Path(f'/home/{os.getlogin()}/.gerev/storage/') + STORAGE_PATH = Path('/tmp/storage/') if IS_IN_DOCKER else Path(f'/home/{os.getlogin()}/.gerev/storage/') if not STORAGE_PATH.exists(): STORAGE_PATH.mkdir(parents=True)