diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/backend.yml similarity index 98% rename from .github/workflows/docker-publish.yml rename to .github/workflows/backend.yml index 54f4dba9d4b4ba1b29a80abde1e0af3cec4e2a9a..97c1f631e491220f51fd425f3a4c9bb857501f1d 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/backend.yml @@ -1,4 +1,4 @@ -name: Docker +name: backend on: repository_dispatch: @@ -31,7 +31,7 @@ jobs: - name: Run tests run: docker build ./backend - myEvent: + build: # Ensure test job passes before pushing image. needs: test diff --git a/.github/workflows/frontend.yml b/.github/workflows/frontend.yml new file mode 100644 index 0000000000000000000000000000000000000000..8fa4c2a2e54373d65205b605703a50db2ab74615 --- /dev/null +++ b/.github/workflows/frontend.yml @@ -0,0 +1,66 @@ +name: frontend + +on: + repository_dispatch: + types: frontend-commit-event + + push: + # Publish `dev` as Docker `latest` image. + branches: + - dev + + # Publish `v1.2.3` tags as releases. + tags: + - v* + + # Run tests for any PRs. + pull_request: + +env: + IMAGE_NAME: librephotos-frontend + +jobs: + # Run tests. + # See also https://docs.docker.com/docker-hub/builds/automated-testing/ + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Run tests + run: docker build ./frontend + + build: + # Ensure test job passes before pushing image. + needs: test + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Build image + run: docker build ./frontend --tag $IMAGE_NAME + + - name: Login to Docker Hub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} + + - name: Push image + run: | + IMAGE_ID=reallibrephotos/$IMAGE_NAME + # Change all uppercase to lowercase + IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') + # Strip git ref prefix from version + VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') + # Strip "v" prefix from tag name + [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') + # Use Docker `dev` tag + VERSION=dev + echo IMAGE_ID=$IMAGE_ID + echo VERSION=$VERSION + docker tag $IMAGE_NAME $IMAGE_ID:$VERSION + docker push $IMAGE_ID:$VERSION diff --git a/backend/Dockerfile b/backend/Dockerfile index ddb0d68050d10b2bcf0d4675066810f421ded329..e9e4972c744fe366a38b3e2072fd1c82c48cb39d 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -13,7 +13,7 @@ RUN curl -SL https://s3.eu-central-1.amazonaws.com/ownphotos-deploy/places365_mo RUN curl -SL https://s3.eu-central-1.amazonaws.com/ownphotos-deploy/im2txt_model.tar.gz | tar -zxC /data_models/im2txt/ RUN curl -SL https://s3.eu-central-1.amazonaws.com/ownphotos-deploy/im2txt_data.tar.gz | tar -zxC /data_models/im2txt/ RUN curl -SL https://download.pytorch.org/models/resnet152-b121ed2d.pth -o /root/.cache/torch/hub/checkpoints/resnet152-b121ed2d.pth -RUN pip install torch==1.7.1+cpu torchvision==0.8.2+cpu -f https://download.pytorch.org/whl/torch_stable.html +RUN pip install torch==1.8.0+cpu torchvision==0.9.0+cpu -f https://download.pytorch.org/whl/torch_stable.html RUN pip install -v --install-option="--no" --install-option="DLIB_USE_CUDA" --install-option="--no" --install-option="USE_AVX_INSTRUCTIONS" --install-option="--no" --install-option="USE_SSE4_INSTRUCTIONS" dlib # actual project ARG DEBUG diff --git a/backend/entrypoint.sh b/backend/entrypoint.sh index b97aaa0b68550818cc8aeef3cebeccc63b0766c8..e9b591eea42e96e4d7a55748a714ca3254f94349 100755 --- a/backend/entrypoint.sh +++ b/backend/entrypoint.sh @@ -1,7 +1,7 @@ #! /bin/bash export PYTHONUNBUFFERED=TRUE mkdir -p /logs - +service statd start python image_similarity/main.py 2>&1 | tee /logs/gunicorn_image_similarity.log & python manage.py showmigrations | tee /logs/show_migrate.log python manage.py migrate | tee /logs/command_migrate.log diff --git a/docker-compose.yml b/docker-compose.yml index 6b687fc88f80583f0fab1c5bd761c8f0c60acbf1..6b1a2e057fc41fb0260f85496ae08400df1c17c7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -22,7 +22,7 @@ services: - frontend db: - image: postgres + image: postgres:13 restart: always environment: - POSTGRES_USER=${dbUser} @@ -66,11 +66,12 @@ services: - WEB_CONCURRENCY=${gunniWorkers} - SKIP_PATTERNS=${skipPatterns} - DEBUG=0 + - HEAVYWEIGHT_PROCESS=${HEAVYWEIGHT_PROCESS} # Wait for Postgres depends_on: - db redis: - image: redis + image: redis:6 restart: always diff --git a/librephotos.env b/librephotos.env index 14a44bc9a8da92cc43bd67c55e3b3450b390e348..4004ddc8406aa60fc90880e86a2b1e232a67b6da 100644 --- a/librephotos.env +++ b/librephotos.env @@ -61,12 +61,16 @@ dbUser=docker # The password used by the database. dbPass=AaAa1234 -# This setting can dramatically affect how resource-intensive and the speed of scanning photos +# Number of workers, which take care of the request to the api. This setting can dramatically affect the ram usage. # A positive integer generally in the 2-4 x $(NUM_CORES) range. # You’ll want to vary this a bit to find the best for your particular workload. # Each worker needs 800MB of RAM. Change at your own will. Default is 2. gunniWorkers=2 +# Number of workers, when scanning pictures. This setting can dramatically affect the ram usage. +# Each worker needs 800MB of RAM. Change at your own will. Default is 1. +HEAVYWEIGHT_PROCESS=1 + # --------------------------------------------------------------------------------------------- # If you are not a developer ignore the following parameters: you will never need them.