Docker fixes

This commit is contained in:
dave 2018-09-11 22:25:09 -07:00
parent 69902d942d
commit 508e44f490
4 changed files with 54 additions and 4 deletions

12
.dockerignore Normal file
View File

@ -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 Normal file
View File

@ -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"]

View File

@ -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"

View File

@ -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)