Skip to content

Commit

Permalink
Fix Dockerfile global Python package install issue (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
ianwal authored Jul 13, 2024
1 parent e11a5da commit 484f160
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 9 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Test that the Dockerfile builds successfully.
# This does not test that the newest Python changes work, since the package is installed from pypi.

on:
push:
branches:
- main
- develop
paths:
- Dockerfile
- docker-entrypoint.sh
- .github/workflows/build-docker.yml
pull_request:
branches:
- main
- develop
paths:
- Dockerfile
- docker-entrypoint.sh
- .github/workflows/build-docker.yml
workflow_dispatch:

jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build image
uses: docker/build-push-action@v6
with:
push: false
13 changes: 10 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
FROM ubuntu:latest
FROM ubuntu:24.04
WORKDIR /usr/src/app
RUN apt-get update && apt-get install -y \
python3.11 \
python3 \
python3-pip \
python3-venv \
git \
ffmpeg \
&& rm -rf /var/lib/apt/lists/*
RUN python3.11 -m pip install hydrusvideodeduplicator

# Need to make a venv because Ubuntu doesn't allow globally installed Python packages anymore (PEP 668)
ENV VIRTUAL_ENV=/opt/venv
RUN python3 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

RUN python -m pip install hydrusvideodeduplicator
COPY ./docker-entrypoint.sh ./entrypoint.sh

ENV DEDUP_DATABASE_DIR=/usr/src/app/db
Expand Down
8 changes: 4 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
version: "3.8"
# Example compose file

services:
hydrusvideodeduplicator:
build: .
container_name: hydrusvideodeduplicator
volumes:
- ./db:/usr/src/app/db # Database directory
- ./db:/usr/src/app/db # Database directory
# - <cert file>:/usr/src/app/cert # Optional, SSL cert
environment:
API_KEY: <your key>
Expand All @@ -15,6 +15,6 @@ services:
# See full list of options on the wiki

# If default API_URL does not connect to Hydrus on Docker host,
# try using host network mode and set API_URL to https://localhost:45869
#network_mode: host
# try using network_mode: host and set API_URL to https://localhost:45869
network_mode: host

4 changes: 2 additions & 2 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

Command="python3.11 -m hydrusvideodeduplicator"
Command="python -m hydrusvideodeduplicator"
[[ -n "${API_KEY}" ]] && Command="${Command} --api-key='${API_KEY}'"
[[ -n "${API_URL}" ]] && Command="${Command} --api-url='${API_URL}'"
[[ -n "${THRESHOLD}" ]] && Command="${Command} --threshold=${THRESHOLD}"
Expand All @@ -13,4 +13,4 @@ Command="python3.11 -m hydrusvideodeduplicator"
[[ ${CLEAR_SEARCH_CACHE} = "true" ]] && Command="${Command} --clear-search-cache" || Command="${Command} --no-clear-search-cache"
[[ ${VERBOSE} = "true" ]] && Command="${Command} --verbose" || Command="${Command} --no-verbose"
echo "${Command}"
eval "${Command}"
eval "${Command}"

0 comments on commit 484f160

Please sign in to comment.