nginx unit works
This commit is contained in:
		@@ -2,23 +2,22 @@
 | 
			
		||||
## pull official base image
 | 
			
		||||
FROM nginx/unit:1.22.0-python3.9
 | 
			
		||||
EXPOSE 80
 | 
			
		||||
 | 
			
		||||
ENV AM_DOCKER_INSTANCE Yes
 | 
			
		||||
## set work directory
 | 
			
		||||
WORKDIR /usr/src/app
 | 
			
		||||
WORKDIR /app
 | 
			
		||||
 | 
			
		||||
## install dependencies
 | 
			
		||||
COPY ./requirements.txt .
 | 
			
		||||
RUN pip install -r requirements.txt
 | 
			
		||||
 | 
			
		||||
## copy project
 | 
			
		||||
COPY ./CalibreWebCompanion ./CalibreWebCompanion
 | 
			
		||||
COPY ./deployment/entrypoints/* /docker-entrypoint.d/
 | 
			
		||||
 | 
			
		||||
# perms
 | 
			
		||||
RUN chown -R unit:unit /usr/src/app 
 | 
			
		||||
RUN chown -R unit:unit /app 
 | 
			
		||||
COPY ./deployment/entrypoints/* /docker-entrypoint.d/
 | 
			
		||||
RUN chmod +x /docker-entrypoint.d/start.sh
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# docker run --publish 80:80 \
 | 
			
		||||
# -v '/home/MassiveAtoms/Desktop/logs:/usr/src/app/data' \
 | 
			
		||||
# -v '/home/MassiveAtoms/windows/Users/MassiveAtoms/Documents/Calibre Library/:/usr/src/app/calibredir' \
 | 
			
		||||
# -v '/home/MassiveAtoms/Desktop/logs:/app/data' \
 | 
			
		||||
# -v '/home/MassiveAtoms/windows/Users/MassiveAtoms/Documents/Calibre Library/:/app/calibredir' \
 | 
			
		||||
# --name cw calibreweb:1.0
 | 
			
		||||
 
 | 
			
		||||
@@ -6,14 +6,30 @@
 | 
			
		||||
    },
 | 
			
		||||
    "routes": [
 | 
			
		||||
        {
 | 
			
		||||
            "match": {"uri": "/static/*"},
 | 
			
		||||
            "action": {"share": "/usr/src/app/CalibreWebCompanion/static"}
 | 
			
		||||
            "match": {
 | 
			
		||||
                "uri": [
 | 
			
		||||
                    "/content/*",
 | 
			
		||||
                    "!~\\.db"
 | 
			
		||||
                ]
 | 
			
		||||
            },
 | 
			
		||||
            "action": {
 | 
			
		||||
                "share": "/app/"
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            "match": {"uri": "/download/*"},
 | 
			
		||||
            "action": {"share": "/usr/src/app/calibredir"}
 | 
			
		||||
            "match": {
 | 
			
		||||
                "uri": "/static/*"
 | 
			
		||||
            },
 | 
			
		||||
            "action": {
 | 
			
		||||
                "share": "/app/CalibreWebCompanion/"
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            "match": {
 | 
			
		||||
                "uri": [
 | 
			
		||||
                    "!~\\.db", "*"
 | 
			
		||||
                ]
 | 
			
		||||
            },
 | 
			
		||||
            "action": {
 | 
			
		||||
                "pass": "applications/django"
 | 
			
		||||
            }
 | 
			
		||||
@@ -22,12 +38,16 @@
 | 
			
		||||
    "applications": {
 | 
			
		||||
        "django": {
 | 
			
		||||
            "type": "python 3",
 | 
			
		||||
            "path": "/usr/src/app/CalibreWebCompanion/",
 | 
			
		||||
            "path": "/app/CalibreWebCompanion/",
 | 
			
		||||
            "module": "CalibreWebCompanion.wsgi",
 | 
			
		||||
            "environment": {
 | 
			
		||||
                "DJANGO_SETTINGS_MODULE": "CalibreWebCompanion.settings",
 | 
			
		||||
                "DB_ENGINE": "django.db.backends.sqlite3"
 | 
			
		||||
 | 
			
		||||
            },
 | 
			
		||||
            "processes" : {
 | 
			
		||||
                "max": 25,
 | 
			
		||||
                "spare": 1,
 | 
			
		||||
                "idle_timeout": 20
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,22 @@
 | 
			
		||||
path=/usr/src/app/CalibreWebCompanion
 | 
			
		||||
chown -R unit:unit /usr/src/app
 | 
			
		||||
CAL_DIR="/app/content/"
 | 
			
		||||
DATA_DIR="/app/data/"
 | 
			
		||||
CWC_PATH="/app/CalibreWebCompanion"
 | 
			
		||||
if [ ! -d "$CAL_DIR" ]; then
 | 
			
		||||
  echo "Calibre Library not mounted at the correct location."
 | 
			
		||||
  echo "Mount it at /app/content/"
 | 
			
		||||
  echo "Exiting..."
 | 
			
		||||
  exit 1
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
python "${path}/manage.py" makemigrations
 | 
			
		||||
python "${path}/manage.py" migrate
 | 
			
		||||
if [ ! -d "$DATA_DIR" ]; then
 | 
			
		||||
  echo "A data directory not mounted at the correct location, exiting"
 | 
			
		||||
  echo "This is used to store the database and logs"
 | 
			
		||||
  echo "mount something at /app/data/"
 | 
			
		||||
  echo "exiting"
 | 
			
		||||
  exit 1
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
cp -R -u -p "/app/CalibreWebCompanion/db.sqlite3" "/app/data/"
 | 
			
		||||
ls -l /app
 | 
			
		||||
python "${CWC_PATH}/manage.py" makemigrations
 | 
			
		||||
python "${CWC_PATH}/manage.py" migrate
 | 
			
		||||
 
 | 
			
		||||
@@ -8,12 +8,12 @@
 | 
			
		||||
Here's an example of step 5
 | 
			
		||||
```
 | 
			
		||||
docker run --publish 80:80 \
 | 
			
		||||
-v '/home/MassiveAtoms/Desktop/logs:/usr/src/app/data' \
 | 
			
		||||
-v '/home/MassiveAtoms/windows/Users/MassiveAtoms/Documents/Calibre\ Library/:/usr/src/app/calibredir' \
 | 
			
		||||
-v '/home/MassiveAtoms/Desktop/logs:/app/data' \
 | 
			
		||||
-v '/home/MassiveAtoms/windows/Users/MassiveAtoms/Documents/Calibre\ Library/:/app/calibredir' \
 | 
			
		||||
--name cw calibreweb:1.0
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
your Calibre path/volume/whatever needs to be mounted at `/usr/src/app/calibredir`, and you need to mount a volume for the db and logs at `/usr/src/app/data`
 | 
			
		||||
your Calibre path/volume/whatever needs to be mounted at `/app/calibredir`, and you need to mount a volume for the db and logs at `/app/data`
 | 
			
		||||
 | 
			
		||||
Issues with it at the moment:
 | 
			
		||||
1. we still need to do something to create a random secret key. Atm, this would still 
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user