From c2f72df80a3472af66f872df886fa56ac5cd0eff Mon Sep 17 00:00:00 2001 From: James Ketrenos Date: Thu, 28 Nov 2019 01:54:02 -0800 Subject: [PATCH] Improved slideshow to support ?holiday URL matching Added docker config Signed-off-by: James Ketrenos --- .dockerignore | 2 + .env | 1 + .gitignore | 2 + Dockerfile | 52 ++++++ README.md | 47 +---- config/default.json | 4 +- docker-compose.yml | 30 +++ entrypoint.sh | 5 + frontend/slideshow.html | 392 +++++++++++++++++++++++----------------- package.json | 4 +- query.sh | 2 +- 11 files changed, 326 insertions(+), 215 deletions(-) create mode 100644 .dockerignore create mode 100644 .env create mode 100644 Dockerfile create mode 100644 docker-compose.yml create mode 100755 entrypoint.sh diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..864179f --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +* +!entrypoint.sh diff --git a/.env b/.env new file mode 100644 index 0000000..6f27435 --- /dev/null +++ b/.env @@ -0,0 +1 @@ +USER_ID=1000:1000 diff --git a/.gitignore b/.gitignore index 78e7b5d..73b4aa9 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ node_modules ./elements frontend/bower_components pictures +db +*.db diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..35172e6 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,52 @@ +FROM ubuntu:disco + +RUN apt-get update + +RUN apt-get install -y wget + +# Upgrade Node +RUN wget -qO- https://deb.nodesource.com/setup_10.x | bash - +RUN DEBIAN_FRONTEND=NONINTERACTIVE apt-get install -y \ + nodejs \ + gcc \ + g++ \ + make \ + cmake + +# You can then install the latest npm, polymer-cli, and bower: +RUN npm install --global npm@latest npx + +# Speed up face-recognition and dev tools +RUN apt-get install -y libopenblas-dev cmake + +# NEF processing uses ufraw-batch +RUN apt-get install -y ufraw-batch + +# Create a user with sudo access +RUN DEBIAN_FRONTEND=noninteractive \ + && apt-get install --no-install-recommends -y \ + sudo + +# NOTE: Requires 'sudo' package to already be installed +RUN groupadd -g 1000 user \ + && useradd --no-log-init \ + -s /bin/bash \ + -u 1000 \ + -m \ + -g user \ + -G sudo \ + -p $(echo "user" | openssl passwd -stdin) user + +# Set 'sudo' to NOPASSWD for all container users +RUN sed -i -e 's,%sudo.*,%sudo ALL=(ALL) NOPASSWD:ALL,g' /etc/sudoers + +COPY /entrypoint.sh /entrypoint.sh + +RUN DEBIAN_FRONTEND=noninteractive \ + && apt-get install --no-install-recommends -y \ + git + +USER user +WORKDIR /website + +CMD [ "/entrypoint.sh" ] diff --git a/README.md b/README.md index 664e736..f6bb5c7 100644 --- a/README.md +++ b/README.md @@ -28,47 +28,6 @@ sudo apt install -y ufraw-batch ### Create `photos` user for DB -You will need to know the root password for your mariadb installation. If you -need to reset the root password, you can perform the following: - -```bash -export PASSWORD=m4g1cP4ssw0rd -sudo service mysql stop -sudo mysqld_safe --skip-grant-tables & -sleep 1 # mysqld_safe can take a bit of time to come online -sudo mysql << EOF -use mysql; -UPDATE user SET PASSWORD=PASSWORD("${PASSWORD}") WHERE USER='root'; -UPDATE user SET plugin='mysql_native_password' WHERE USER='root'; -FLUSH PRIVILEGES; -QUIT -EOF -sudo service mysql stop -sudo service mysql start -``` - -Once you know the root password, you can then create a new user and DB -for the photo app via: - -### Create the USER - -```bash -U='photos' -P='p4$$w0rd' -mysql -u root --password=${PASSWORD} << EOF -CREATE USER '${U}'@'localhost' IDENTIFIED BY '${P}'; -EOF -``` - -### Create the DB 'photos' - -```bash -U='photos' -P='p4$$w0rd' -D='photos' -mysql -u root --password=${PASSWORD} << EOF -DROP DATABASE IF EXISTS ${D}; -CREATE DATABASE ${D} CHARACTER SET utf8 COLLATE utf8_general_ci; -GRANT ALL PRIVILEGES ON ${D}.* TO '${U}'@'localhost' IDENTIFIED BY '${P}'; -EOF -``` +Photos is currently using sqlite, which means you don't need to +do anything fancy beyond having run 'npm install' to get sequelize +and sqlite3 installed. diff --git a/config/default.json b/config/default.json index 85e287a..393573b 100644 --- a/config/default.json +++ b/config/default.json @@ -1,14 +1,14 @@ { "db": { "photos": { - "host": "sqlite:photos.db", + "host": "sqlite:db/photos.db", "options": { "logging" : false, "timezone": "+00:00" } }, "users": { - "host": "sqlite:users.db", + "host": "sqlite:db/users.db", "options": { "logging" : false, "timezone": "+00:00" diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..2802b2f --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,30 @@ +version: '3.1' + +services: + +# db: +# image: mariadb +# restart: always +# environment: +# MYSQL_ROOT_PASSWORD: photos +# PHOTOS_DB_USER: photos +# PHOTOS_DB_PASSWD: ph0t0z +# PHOTOS_DB: photos +# volumes: +# - ${PWD}/db:/var/lib/mysql +# - ./init.sql:/data/application/init.sql + + photos: + user: ${USER_ID} + build: . + image: photos:latest + container_name: photos + # depends_on: + # - db + restart: always + ports: + - 8123:8123 + volumes: + - ${PWD}/photos:/photos + - ${PWD}/db:/db + - ${PWD}:/website diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..c0a30b0 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,5 @@ +#!/bin/bash +while true; do + npm start + sleep 3 +done diff --git a/frontend/slideshow.html b/frontend/slideshow.html index c5e0361..841f62b 100755 --- a/frontend/slideshow.html +++ b/frontend/slideshow.html @@ -1,167 +1,225 @@ - - - - - - -
-
-
- Loading photoset... -
- - + + + + + +
+
+ + + diff --git a/package.json b/package.json index bc53fdc..5f3d948 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,9 @@ }, "author": "James Ketrenos", "license": "Apache-2.0", + "unused": { + "face-recognition": "^0.9.4" + }, "dependencies": { "bluebird": "^3.5.3", "body-parser": "^1.18.3", @@ -21,7 +24,6 @@ "exif-reader": "github:paras20xx/exif-reader", "express": "^4.16.4", "express-session": "^1.15.6", - "face-recognition": "^0.9.4", "handlebars": "^4.0.12", "ldapauth-fork": "^4.0.2", "ldapjs": "^1.0.2", diff --git a/query.sh b/query.sh index 7ad9448..ae5b46e 100755 --- a/query.sh +++ b/query.sh @@ -1,2 +1,2 @@ #!/bin/bash -sqlite3 photos.db +sqlite3 db/photos.db