From 1e185d15026f285e403525822120170170a922a4 Mon Sep 17 00:00:00 2001 From: jonaswinkler Date: Sun, 10 Jan 2021 19:59:05 +0100 Subject: [PATCH] don't build front end with docker --- .github/workflows/ci.yml | 18 ++++++++++++------ Dockerfile | 39 ++++++++++++++++----------------------- compile-frontend.sh | 7 +++++++ src-ui/angular.json | 1 + 4 files changed, 36 insertions(+), 29 deletions(-) create mode 100755 compile-frontend.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e2918d276..f0df7e608 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -72,17 +72,18 @@ jobs: with: node-version: '15' - name: build - run: | - cd src-ui/ - npm install -g @angular/cli - npm install - ng build --prod + run: ./build-frontend.sh + - uses: actions/upload-artifact@v2 + with: + name: frontend-compiled + path: src/documents/static/frontend/ # build and push image to docker hub. build-docker-image: if: github.event_name == 'push' && (github.ref == 'refs/heads/travis-multiarch-builds' || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev' || github.ref == 'refs/tags/ng-*') runs-on: ubuntu-latest # needs: tests + needs: frontend steps: - name: Prepare @@ -99,6 +100,11 @@ jobs: - name: Checkout uses: actions/checkout@v2 + - + uses: actions/download-artifact@v2 + with: + name: frontend-compiled + path: src/documents/static/frontend/ - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 @@ -125,7 +131,7 @@ jobs: with: context: . file: ./Dockerfile - platforms: linux/amd64,linux/arm/v7,linux/arm64 + platforms: linux/amd64 # ,linux/arm/v7,linux/arm64 push: true tags: jonaswinkler/paperless-ng:${{ steps.prepare.outputs.version }} cache-from: type=local,src=/tmp/.buildx-cache diff --git a/Dockerfile b/Dockerfile index ee19e0cc0..4a52568ea 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,27 +8,15 @@ RUN git clone https://github.com/agl/jbig2enc . RUN ./autogen.sh RUN ./configure && make - -FROM node:15 AS frontend - -WORKDIR /usr/src/paperless/src-ui/ - -COPY src-ui/package* ./ -RUN npm install - -COPY src-ui . -RUN node_modules/.bin/ng build --prod --output-hashing none --sourceMap=false - FROM python:3.7-slim WORKDIR /usr/src/paperless/ COPY requirements.txt ./ -#Dependencies +# Binary dependencies RUN apt-get update \ && apt-get -y --no-install-recommends install \ - build-essential \ curl \ file \ fonts-liberation \ @@ -37,13 +25,6 @@ RUN apt-get update \ gnupg \ icc-profiles-free \ imagemagick \ - libatlas-base-dev \ - liblept5 \ - libmagic-dev \ - libpoppler-cpp-dev \ - libpq-dev \ - libqpdf-dev \ - libxml2 \ libxslt1-dev \ mime-support \ optipng \ @@ -59,8 +40,21 @@ RUN apt-get update \ tzdata \ unpaper \ zlib1g \ - && pip3 install --upgrade supervisor \ - && python3 -m pip install -r requirements.txt \ + && rm -rf /var/lib/apt/lists/* + +# Python dependencies +RUN apt-get update \ + && apt-get -y --no-install-recommends install \ + build-essential \ + libatlas-base-dev \ + liblept5 \ + libmagic-dev \ + libpoppler-cpp-dev \ + libpq-dev \ + libqpdf-dev \ + libxml2 \ + && python3 -m pip install --upgrade --no-cache-dir supervisor \ + && python3 -m pip install --no-cache-dir -r requirements.txt \ && apt-get -y purge build-essential libqpdf-dev \ && apt-get -y autoremove --purge \ && rm -rf /var/lib/apt/lists/* \ @@ -81,7 +75,6 @@ COPY --from=jbig2enc /usr/src/jbig2enc/src/*.h /usr/local/include/ # copy app COPY src/ ./src/ -COPY --from=frontend /usr/src/paperless/src-ui/dist/paperless-ui/ /usr/src/paperless/src/documents/static/frontend/ # add users, setup scripts RUN addgroup --gid 1000 paperless \ diff --git a/compile-frontend.sh b/compile-frontend.sh new file mode 100755 index 000000000..98b88d033 --- /dev/null +++ b/compile-frontend.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +set -e + +cd src-ui +npm install +./node_modules/.bin/ng build --prod diff --git a/src-ui/angular.json b/src-ui/angular.json index 414cd4f64..829a482af 100644 --- a/src-ui/angular.json +++ b/src-ui/angular.json @@ -58,6 +58,7 @@ "with": "src/environments/environment.prod.ts" } ], + "outputPath": "../src/documents/static/frontend/", "optimization": true, "outputHashing": "none", "sourceMap": false,