Browse Source

Docker fixes

api
dave 3 years ago
parent
commit
508e44f490
  1. 12
      .dockerignore
  2. 37
      Dockerfile
  3. 5
      photoapp/daemon.py
  4. 4
      photoapp/library.py

12
.dockerignore

@ -0,0 +1,12 @@
build/
cache/
dist/
dropbox/
library/
node_modules/
photoapp.egg-info/
photos.db
styles/css/
styles/dist/
styles/mincss/
testenv/

37
Dockerfile

@ -0,0 +1,37 @@
FROM ubuntu:bionic
RUN apt-get update && \
apt-get install -y wget software-properties-common && \
echo "deb https://deb.nodesource.com/node_10.x bionic main" | tee /etc/apt/sources.list.d/nodesource.list && \
wget -O- https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - && \
apt-get update && \
apt-get install -y nodejs
ADD . /tmp/code/
RUN cd /tmp/code && \
npm install && \
./node_modules/.bin/grunt
FROM ubuntu:bionic
ADD . /tmp/code/
COPY --from=0 /tmp/code/styles/dist/style.css /tmp/code/styles/dist/style.css
RUN apt-get update && \
apt-get install -y python3-pip
RUN pip3 install -U pip && \
cd /tmp/code && \
pip install -r requirements.txt && \
python3 setup.py install && \
useradd --uid 1000 app
VOLUME /srv/library
VOLUME /srv/cache
VOLUME /srv/db
USER app
ENTRYPOINT ["photoappd", "--library", "/srv/library", "--database", "/srv/db/photos.db", "--cache", "/srv/cache"]

5
photoapp/daemon.py

@ -230,7 +230,8 @@ def main():
parser.add_argument('-p', '--port', default=8080, type=int, help="tcp port to listen on")
parser.add_argument('-l', '--library', default="./library", help="library path")
parser.add_argument('-s', '--database-path', default="./photos.db", help="path to persistent sqlite database")
parser.add_argument('-c', '--cache', default="./cache", help="cache path")
parser.add_argument('-s', '--database', default="./photos.db", help="path to persistent sqlite database")
parser.add_argument('--debug', action="store_true", help="enable development options")
args = parser.parse_args()
@ -238,7 +239,7 @@ def main():
logging.basicConfig(level=logging.INFO if args.debug else logging.WARNING,
format="%(asctime)-15s %(levelname)-8s %(filename)s:%(lineno)d %(message)s")
library = PhotoLibrary(args.database_path, args.library)
library = PhotoLibrary(args.database, args.library, args.cache)
tpl_dir = os.path.join(APPROOT, "templates") if not args.debug else "templates"

4
photoapp/library.py

@ -13,9 +13,9 @@ from PIL import Image, ImageOps
class PhotoLibrary(object):
def __init__(self, db_path, lib_path):
def __init__(self, db_path, lib_path, cache_path):
self.path = lib_path
self.cache_path = "./cache" # TODO param
self.cache_path = cache_path
self.engine = create_engine('sqlite:///{}'.format(db_path),
connect_args={'check_same_thread': False}, poolclass=StaticPool, echo=False)
Base.metadata.create_all(self.engine)

Loading…
Cancel
Save