Upgrade Go to 1.12.5, improve Makefile and add chromium-browser

This commit is contained in:
Michael Mayer
2019-05-09 06:18:22 +02:00
parent 24a205314a
commit c5e2783b8d
19 changed files with 169 additions and 162 deletions

1
.gitignore vendored
View File

@@ -4,6 +4,7 @@
/assets/photos/import/*
/assets/photos/export/*
/node_modules
/frontend/.eslintcache
/frontend/node_modules/*
/frontend/tests/result.html
/assets/testdata

View File

@@ -1,4 +1,4 @@
FROM photoprism/development:20190507
FROM photoprism/development:20190509
# Set up project directory
WORKDIR "/go/src/github.com/photoprism/photoprism"

View File

@@ -5,8 +5,17 @@ DOCKER_TAG=`date -u +%Y%m%d`
TIDB_VERSION=2.1.8
DARKTABLE_VERSION="$(awk '$2 == "DARKTABLE_VERSION" { print $3; exit }' docker/darktable/Dockerfile)"
all: download dep js build
all: dep build
dep: dep-tensorflow dep-js dep-go
build: build-js build-go
install: install-bin install-assets install-config
test: test-js test-go
fmt: fmt-js fmt-go
upgrade: upgrade-js upgrade-go
start:
go run cmd/photoprism/photoprism.go start
migrate:
go run cmd/photoprism/photoprism.go migrate
install-bin:
scripts/build.sh prod /usr/local/bin/$(BINARY_NAME)
install-assets:
@@ -19,20 +28,19 @@ install-assets:
install-config:
mkdir -p /etc/photoprism
test -e /etc/photoprism/photoprism.yml || cp -n configs/photoprism.yml /etc/photoprism/photoprism.yml
build:
scripts/build.sh debug $(BINARY_NAME)
js:
(cd frontend && npm install --production)
(cd frontend && env NODE_ENV=production npm run build)
dep-js:
(cd frontend && npm install)
dep-go:
go build -v ./...
dep-tensorflow:
scripts/download-nasnet.sh
build-js:
(cd frontend && env NODE_ENV=production npm run build)
build-go:
scripts/build.sh debug $(BINARY_NAME)
test-js:
(cd frontend && env NODE_ENV=development npm run test)
start:
go run cmd/photoprism/photoprism.go start
migrate:
go run cmd/photoprism/photoprism.go migrate
test:
test-go:
go test -tags=slow -timeout 20m -v ./internal/... | scripts/colorize-tests.sh
test-short:
go test -short -timeout 5m -v ./internal/... | scripts/colorize-tests.sh
@@ -51,8 +59,6 @@ clean:
rm -rf assets/testdata
rm -rf assets/backups
rm -rf frontend/node_modules
download:
scripts/download-nasnet.sh
docker-development:
scripts/docker-build.sh development $(DOCKER_TAG)
scripts/docker-push.sh development $(DOCKER_TAG)
@@ -71,13 +77,17 @@ docker-darktable:
docker-tidb:
scripts/docker-build.sh tidb $(TIDB_VERSION)
scripts/docker-push.sh tidb $(TIDB_VERSION)
fmt:
lint-js:
(cd frontend && npm run lint)
fmt-js:
(cd frontend && npm run fmt)
fmt-go:
goimports -w internal cmd
go fmt ./internal/... ./cmd/...
dep:
go build -v ./...
tidy:
go mod tidy
upgrade:
upgrade-js:
(cd frontend && npm update --depth 1)
upgrade-go:
go mod tidy
go get -u

View File

@@ -42,10 +42,8 @@ RUN apt-get update && apt-get upgrade && \
mysql-client \
libgtk-3-bin \
tzdata \
gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libgcc1 \
libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 \
libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 \
libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils
gconf-service \
chromium-browser
# Install darktable (RAW to JPEG converter)
RUN add-apt-repository ppa:pmjdebruijn/darktable-release && \
@@ -76,12 +74,12 @@ RUN npm install -g npm
RUN npm config set cache ~/.cache/npm
# Install Go
ENV GOLANG_VERSION 1.12.4
ENV GOLANG_VERSION 1.12.5
RUN set -eux; \
\
url="https://golang.org/dl/go${GOLANG_VERSION}.linux-amd64.tar.gz"; \
wget -O go.tgz "$url"; \
echo "d7d1f1f88ddfe55840712dc1747f37a790cbcaa448f6c9cf51bbe10aa65442f5 *go.tgz" | sha256sum -c -; \
echo "aea86e3c73495f205929cfebba0d63f1382c8ac59be081b6351681415f4063cf *go.tgz" | sha256sum -c -; \
tar -C /usr/local -xzf go.tgz; \
rm go.tgz; \
export PATH="/usr/local/go/bin:$PATH"; \

View File

@@ -1,4 +1,4 @@
FROM photoprism/development:20190507 as build
FROM photoprism/development:20190509 as build
# Set up project directory
WORKDIR "/go/src/github.com/photoprism/photoprism"

View File

@@ -1,4 +1,4 @@
FROM photoprism/development:20190507
FROM photoprism/development:20190509
# Install Python and TensorFlow
RUN apt-get update && apt-get install -y --no-install-recommends \

View File

@@ -1,15 +1,16 @@
const path = require('path');
const findChrome = require('chrome-finder');
process.env.CHROME_BIN = require('puppeteer').executablePath()
process.env.CHROME_BIN = findChrome();
module.exports = (config) => {
config.set({
frameworks: ['mocha'],
browsers: ['PhotoPrism'],
browsers: ['LocalChrome'],
customLaunchers: {
PhotoPrism: {
LocalChrome: {
base: 'ChromeHeadless',
flags: ['--disable-translate', '--disable-extensions', '--no-sandbox', '--disable-web-security'],
}

View File

@@ -2146,6 +2146,11 @@
"resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.1.tgz",
"integrity": "sha512-j38EvO5+LHX84jlo6h4UzmOwi0UgW61WRyPtJz4qaadK5eY3BTS5TY/S1Stc3Uk2lIM6TPevAlULiEJwie860g=="
},
"chrome-finder": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/chrome-finder/-/chrome-finder-1.0.5.tgz",
"integrity": "sha512-IPzq22cqDpRKufySe6tnxP/s1543DBJHKxwi58NtYSiVe+3PUdFTQBIKJFjYAg8HX5Ix3xWHhHVVIzmCmF64Fw=="
},
"chrome-trace-event": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/chrome-trace-event/-/chrome-trace-event-1.0.0.tgz",
@@ -3592,6 +3597,20 @@
"resolved": "https://registry.npmjs.org/eslint-config-standard/-/eslint-config-standard-12.0.0.tgz",
"integrity": "sha512-COUz8FnXhqFitYj4DTqHzidjIL/t4mumGZto5c7DrBpvWoie+Sn3P4sLEzUGeYhRElWuFEf8K1S1EfvD1vixCQ=="
},
"eslint-formatter-pretty": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/eslint-formatter-pretty/-/eslint-formatter-pretty-2.1.1.tgz",
"integrity": "sha512-gWfagucSWBn82WxzwFloBTLAcwYDgnpAfiV5pQfyAV5YpZikuLflRU8nc3Ts9wnNvLhwk4blzb42/C495Yw7BA==",
"requires": {
"ansi-escapes": "^3.1.0",
"chalk": "^2.1.0",
"eslint-rule-docs": "^1.1.5",
"log-symbols": "^2.0.0",
"plur": "^3.0.1",
"string-width": "^2.0.0",
"supports-hyperlinks": "^1.0.1"
}
},
"eslint-friendly-formatter": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/eslint-friendly-formatter/-/eslint-friendly-formatter-4.0.1.tgz",
@@ -3794,6 +3813,11 @@
"resolved": "https://registry.npmjs.org/eslint-plugin-standard/-/eslint-plugin-standard-4.0.0.tgz",
"integrity": "sha512-OwxJkR6TQiYMmt1EsNRMe5qG3GsbjlcOhbGUBY4LtavF9DsLaTcoR+j2Tdjqi23oUwKNUqX7qcn5fPStafMdlA=="
},
"eslint-rule-docs": {
"version": "1.1.107",
"resolved": "https://registry.npmjs.org/eslint-rule-docs/-/eslint-rule-docs-1.1.107.tgz",
"integrity": "sha512-MHTOofREWNSijPPuw8Vsirzfk25fzDgO2cVorDeGDmFoiq7gpS/k/SBdyEIycKm0mxzfdizYenr2kfUlWskoRg=="
},
"eslint-scope": {
"version": "3.7.1",
"resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-3.7.1.tgz",
@@ -5657,6 +5681,11 @@
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.0.tgz",
"integrity": "sha512-M4Sjn6N/+O6/IXSJseKqHoFc+5FdGJ22sXqnjTpdZweHK64MzEPAyQZyEU3R/KRv2GLoa7nNtg/C2Ev6m7z+eA=="
},
"irregular-plurals": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/irregular-plurals/-/irregular-plurals-2.0.0.tgz",
"integrity": "sha512-Y75zBYLkh0lJ9qxeHlMjQ7bSbyiSqNW/UOPWDmzC7cXskL1hekSITh1Oc6JV0XCWWZ9DE8VYSB71xocLk3gmGw=="
},
"is-absolute-url": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/is-absolute-url/-/is-absolute-url-2.1.0.tgz",
@@ -6064,11 +6093,6 @@
"which": "^1.2.1"
}
},
"karma-firefox-launcher": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/karma-firefox-launcher/-/karma-firefox-launcher-1.1.0.tgz",
"integrity": "sha512-LbZ5/XlIXLeQ3cqnCbYLn+rOVhuMIK9aZwlP6eOLGzWdo1UVp7t6CN3DP4SafiRLjexKwHeKHDm0c38Mtd3VxA=="
},
"karma-htmlfile-reporter": {
"version": "0.3.8",
"resolved": "https://registry.npmjs.org/karma-htmlfile-reporter/-/karma-htmlfile-reporter-0.3.8.tgz",
@@ -7441,6 +7465,14 @@
"find-up": "^3.0.0"
}
},
"plur": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/plur/-/plur-3.1.1.tgz",
"integrity": "sha512-t1Ax8KUvV3FFII8ltczPn2tJdjqbd1sIzu6t4JL7nQ3EyeL/lTrj5PWKb06ic5/6XYDr65rQ4uzQEGN70/6X5w==",
"requires": {
"irregular-plurals": "^2.0.0"
}
},
"pluralize": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/pluralize/-/pluralize-7.0.0.tgz",
@@ -8581,10 +8613,10 @@
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz",
"integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A=="
},
"puppeteer": {
"puppeteer-core": {
"version": "1.15.0",
"resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-1.15.0.tgz",
"integrity": "sha512-D2y5kwA9SsYkNUmcBzu9WZ4V1SGHiQTmgvDZSx6sRYFsgV25IebL4V6FaHjF6MbwLK9C6f3G3pmck9qmwM8H3w==",
"resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-1.15.0.tgz",
"integrity": "sha512-AH82x8Tx0/JkubeF6U12y8SuVB5vFgsw8lt/Ox5MhXaAktREFiotCTq324U2nPtJUnh2A8yJciDnzAmhbHidqQ==",
"requires": {
"debug": "^4.1.0",
"extract-zip": "^1.6.6",
@@ -9934,6 +9966,22 @@
"has-flag": "^3.0.0"
}
},
"supports-hyperlinks": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/supports-hyperlinks/-/supports-hyperlinks-1.0.1.tgz",
"integrity": "sha512-HHi5kVSefKaJkGYXbDuKbUGRVxqnWGn3J2e39CYcNJEfWciGq2zYtOhXLTlvrOZW1QU7VX67w7fMmWafHX9Pfw==",
"requires": {
"has-flag": "^2.0.0",
"supports-color": "^5.0.0"
},
"dependencies": {
"has-flag": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz",
"integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE="
}
}
},
"svg-url-loader": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/svg-url-loader/-/svg-url-loader-2.3.2.tgz",

View File

@@ -7,7 +7,8 @@
"scripts": {
"dev": "webpack --watch",
"build": "webpack --optimize-minimize",
"lint": "eslint app/ webpack.*.js --cache",
"lint": "eslint --cache src/ webpack.*.js",
"fmt": "eslint --cache --fix src/ webpack.*.js",
"test": "karma start"
},
"babel": {
@@ -35,6 +36,7 @@
"chai": "^4.2.0",
"chalk": "^2.4.2",
"chart.js": "^2.5.0",
"chrome-finder": "^1.0.5",
"clean-webpack-plugin": "^2.0.2",
"connect-history-api-fallback": "^1.3.0",
"copy-webpack-plugin": "^5.0.3",
@@ -43,6 +45,7 @@
"cssnano": "^4.1.10",
"eslint": "^5.16.0",
"eslint-config-standard": "^12.0.0",
"eslint-formatter-pretty": "^2.1.1",
"eslint-friendly-formatter": "^4.0.1",
"eslint-loader": "^2.1.2",
"eslint-plugin-html": "^5.0.3",
@@ -58,7 +61,6 @@
"inject-loader": "^4.0.1",
"karma": "^4.1.0",
"karma-chrome-launcher": "^2.2.0",
"karma-firefox-launcher": "^1.1.0",
"karma-htmlfile-reporter": "^0.3.8",
"karma-mocha": "^1.3.0",
"karma-webdriver-launcher": "^1.0.5",
@@ -79,7 +81,7 @@
"postcss-reporter": "^6.0.1",
"postcss-url": "^8.0.0",
"pubsub-js": "^1.7.0",
"puppeteer": "^1.15.0",
"puppeteer-core": "^1.15.0",
"resolve-url-loader": "^3.1.0",
"sass-loader": "^7.1.0",
"style-loader": "^0.23.1",

View File

@@ -1,57 +0,0 @@
import Api from 'common/api';
class Captcha {
constructor() {
this.image = '';
this.token = '';
}
setToken(token) {
this.token = token;
}
getToken() {
return this.token;
}
deleteToken() {
this.token = '';
}
setImage(phrase) {
this.image = phrase;
}
getImage() {
return this.image;
}
deleteImage() {
this.image = '';
}
isValid(token, phrase) {
this.deleteToken();
return Api.post('session', { email: email, password: password }).then(
(result) => {
this.setToken(result.data.token);
this.setUser(new User(result.data.user));
}
);
}
refresh() {
const token = this.getToken();
this.deleteToken();
Api.delete('session/' + token).then(
() => {
window.location = '/';
}
);
}
}
export default Captcha;

View File

@@ -1,5 +1,5 @@
import PhotoSwipe from 'photoswipe'
import PhotoSwipeUI_Default from 'photoswipe/dist/photoswipe-ui-default.js'
import PhotoSwipe from 'photoswipe';
import PhotoSwipeUI_Default from 'photoswipe/dist/photoswipe-ui-default.js';
class Gallery {
constructor() {
@@ -16,7 +16,7 @@ class Gallery {
src: photo.getThumbnailUrl('fit', height),
w: photo.calculateWidth(height),
h: height,
title: photo.PhotoTitle
title: photo.PhotoTitle,
});
return {
@@ -26,8 +26,8 @@ class Gallery {
m: createPhotoSize(1280),
l: createPhotoSize(1920),
xl: createPhotoSize(2560),
xxl: createPhotoSize(3840)
}
xxl: createPhotoSize(3840),
};
}
getEl() {
@@ -35,7 +35,7 @@ class Gallery {
const elements = document.querySelectorAll('.pswp');
if(elements.length !== 1) {
let err = "There should be only one PhotoSwipe element";
let err = 'There should be only one PhotoSwipe element';
console.log(err, elements);
throw err;
}
@@ -48,8 +48,8 @@ class Gallery {
show(photos, index = 0) {
if (!Array.isArray(photos) || photos.length === 0 || index >= photos.length) {
console.log("Array passed to gallery was empty:", photos);
return
console.log('Array passed to gallery was empty:', photos);
return;
}
this.photos = photos;
@@ -84,12 +84,12 @@ class Gallery {
realViewportHeight = gallery.viewportSize.y * window.devicePixelRatio;
if (!previousSize) {
previousSize = 'm'
previousSize = 'm';
}
nextSize = this.constructor.mapViewportToImageSize(realViewportWidth, realViewportHeight, photosWithSizes[index])
nextSize = this.constructor.mapViewportToImageSize(realViewportWidth, realViewportHeight, photosWithSizes[index]);
if (nextSize !== previousSize) {
photoSrcWillChange = true
photoSrcWillChange = true;
}
if (photoSrcWillChange && !firstResize) {
@@ -118,7 +118,7 @@ class Gallery {
static mapViewportToImageSize(viewportWidth, viewportHeight, item) {
for (const [sizeKey, photo] of Object.entries(item)) {
if (photo.w > viewportWidth || photo.h > viewportHeight) {
return sizeKey
return sizeKey;
}
}
}

View File

@@ -14,7 +14,7 @@ components.install = (Vue) => {
Icon.Default.mergeOptions({
iconRetinaUrl: require('./marker/marker-icon-2x-red.png'),
iconUrl: require('./marker/marker-icon-red.png'),
shadowUrl: require('./marker/marker-shadow.png')
shadowUrl: require('./marker/marker-shadow.png'),
});
};

View File

@@ -79,24 +79,24 @@ class Photo extends Abstract {
if (this.LocationID) {
if (this.LocName && !this.LocCity && !this.LocCounty) {
location.push(this.LocName)
location.push(this.LocName);
} else if (this.LocCity) {
location.push(this.LocCity)
location.push(this.LocCity);
} else if (this.LocCounty) {
location.push(this.LocCounty)
location.push(this.LocCounty);
}
if (this.LocState && this.LocState !== this.LocCity) {
location.push(this.LocState)
location.push(this.LocState);
}
if (this.LocCountry) {
location.push(this.LocCountry)
location.push(this.LocCountry);
}
} else if (this.CountryName) {
location.push(this.CountryName)
location.push(this.CountryName);
} else {
location.push('Unknown')
location.push('Unknown');
}
return location.join(', ');
@@ -107,32 +107,32 @@ class Photo extends Abstract {
if (this.LocationID) {
if (this.LocName) {
location.push(this.LocName)
location.push(this.LocName);
}
if (this.LocCity) {
location.push(this.LocCity)
location.push(this.LocCity);
}
if (this.LocPostcode) {
location.push(this.LocPostcode)
location.push(this.LocPostcode);
}
if (this.LocCounty) {
location.push(this.LocCounty)
location.push(this.LocCounty);
}
if (this.LocState) {
location.push(this.LocState)
location.push(this.LocState);
}
if (this.LocCountry) {
location.push(this.LocCountry)
location.push(this.LocCountry);
}
} else if (this.CountryName) {
location.push(this.CountryName)
location.push(this.CountryName);
} else {
location.push('Unknown')
location.push('Unknown');
}
return location.join(', ');
@@ -140,17 +140,17 @@ class Photo extends Abstract {
getCamera() {
if (this.CameraModel) {
return this.CameraModel
return this.CameraModel;
}
return 'Unknown'
return 'Unknown';
}
like(liked) {
if (liked === true) {
return Api.post(this.getEntityResource() + "/like");
return Api.post(this.getEntityResource() + '/like');
} else {
return Api.delete(this.getEntityResource() + "/like");
return Api.delete(this.getEntityResource() + '/like');
}
}

View File

@@ -22,7 +22,7 @@ class User extends Abstract {
changePassword(oldPassword, newPassword) {
return Api.put(this.getEntityResource() + '/password', {
password: oldPassword,
new_password: newPassword
new_password: newPassword,
}).then((response) => Promise.resolve(response.data));
}

View File

@@ -42,24 +42,28 @@ const config = {
performance: {
hints: 'warning',
maxEntrypointSize: 1512000,
maxAssetSize: 1512000
maxAssetSize: 1512000,
},
module: {
rules: [
{
test: /\.(js)$/,
test: /\.js$/,
include: PATHS.app,
exclude: /node_modules/,
enforce: 'pre',
loader: 'eslint-loader',
options: {
formatter: require('eslint-formatter-pretty'),
},
},
{
test: /\.vue$/,
loader: "vue-loader",
loader: 'vue-loader',
options: {
loaders: {
js: 'babel-loader',
css: 'css-loader',
}
},
},
},
{
@@ -70,7 +74,7 @@ const config = {
),
query: {
presets: ['@babel/preset-env'],
compact: false
compact: false,
},
},
{
@@ -90,7 +94,7 @@ const config = {
loader: 'css-loader',
options: {
importLoaders: 1,
sourceMap: isDev
sourceMap: isDev,
},
},
{
@@ -107,14 +111,14 @@ const config = {
publicPath: PATHS.build,
},
},
"css-loader",
]
'css-loader',
],
},
{
test: /\.css$/,
include: /node_modules/,
loaders: [
"vue-style-loader",
'vue-style-loader',
'style-loader',
{
loader: 'css-loader',
@@ -129,13 +133,13 @@ const config = {
},
},
},
'resolve-url-loader'
]
'resolve-url-loader',
],
},
{
test: /\.s[c|a]ss$/,
use: [
"vue-style-loader",
'vue-style-loader',
'style-loader',
{
loader: 'css-loader',
@@ -151,8 +155,8 @@ const config = {
},
},
'resolve-url-loader',
'sass-loader'
]
'sass-loader',
],
},
{
@@ -162,7 +166,7 @@ const config = {
name: '[hash].[ext]',
publicPath: '/assets/build/img',
outputPath: 'img',
}
},
},
{
test: /\.(woff(2)?|ttf|eot)(\?v=\d+\.\d+\.\d+)?$/,
@@ -171,7 +175,7 @@ const config = {
name: '[hash].[ext]',
publicPath: '/assets/build/fonts',
outputPath: 'fonts',
}
},
},
{
test: /\.svg/,

View File

@@ -6,7 +6,7 @@ if [[ -z $TRAVIS_BRANCH ]]; then
fi
if [[ $TRAVIS_BRANCH == "develop" ]]; then
docker-compose -f docker-compose.travis.yml exec photoprism make all test-js install migrate test-codecov;
docker-compose -f docker-compose.travis.yml exec photoprism make all test-js test-codecov install migrate;
else
docker-compose -f docker-compose.travis.yml exec photoprism make all test-js install migrate test;
docker-compose -f docker-compose.travis.yml exec photoprism make all test install migrate;
fi