Commit 9e7056b6 authored by Sam Galson's avatar Sam Galson Committed by Giannis Kopanas

feat(xpub): update to pubsweet version using postgres

parent 4202c1cd
*.log
.bash_history
.env
.env.*
dist/
......
......@@ -2,7 +2,7 @@ variables:
IMAGE_ORG: xpub
IMAGE_NAME: xpub
BASE_DOMAIN: gateway.xpub.semioticsquares.com
CONFIGURATION_REPOSITORY: https://gitlab.coko.foundation/xpub/deployment-config.git
CONFIGURATION_REPOSITORY: https://gitlab.coko.foundation/yld/xpub-deployment-config-postgres.git
stages:
- build
......@@ -38,9 +38,19 @@ lint:
stage: test
variables:
GIT_STRATEGY: none
# setup data for postgres image
POSTGRES_USER: test
POSTGRES_PASSWORD: pw
# connection details for tests
PGUSER: test
PGPASSWORD: pw
NODE_ENV: test
services:
- postgres
script:
- cd ${HOME}
- npm run test
# specify host here else it confuses the linked postgres image
- PGHOST=postgres npm run test
push:latest:
image: docker:latest
......
FROM xpub/xpub:base
WORKDIR ${HOME}
COPY package.json yarn.lock app.js .babelrc .eslintignore .eslintrc .prettierrc .stylelintignore .stylelintrc ./
COPY static static
COPY api api
COPY webpack webpack
COPY config config
COPY app app
EXPOSE 3000
CMD []
# xpub-collabra
An MVP implementation of the first design sessions with [Collabra Psychology](https://www.collabra.org/), which allows a user to go through the process of creating a submission, assigning editors and reviewers, submitting reviews and submitting a decision.
## Quickstart
Note: xpub is still _very_ new. This repository contains an initial set of components but is not yet ready for use.
```
npm start # or docker-compose up
```
**Note**: yarn will be run automatically inside the container to install dependencies. If dependencies were already installed on the host, this may cause problems as the binaries are compiled for the wrong platform. If you encounter errors about "invalid ELF header", do `npm run clean` and then `npm start` again.
See `pubsweet-cli` for detailed documentation on running the app
## Notes
An MVP implementation of the first design sessions with [Collabra Psychology](https://www.collabra.org/), which allows a user to go through the process of creating a submission, assigning editors and reviewers, submitting reviews and submitting a decision.
## Roadmap
......
......@@ -2,8 +2,6 @@ const path = require('path')
const components = require('./components.json')
const logger = require('winston')
const environment = process.env.NODE_ENV || 'development'
module.exports = {
authsome: {
mode: path.resolve(__dirname, 'authsome.js'),
......@@ -16,10 +14,10 @@ module.exports = {
components,
},
'pubsweet-server': {
dbPath:
process.env.PUBSWEET_DB ||
path.join(__dirname, '..', 'api', 'db', environment),
db: {},
port: 3000,
logger,
uploads: 'uploads',
},
'pubsweet-client': {
API_ENDPOINT: '/api',
......
const { deferConfig } = require('config/defer')
module.exports = {
'pubsweet-server': {
baseUrl: deferConfig(
cfg => `http://localhost:${cfg['pubsweet-server'].port}`,
),
},
dbManager: {
username: 'admin',
password: 'password',
email: 'admin@example.com',
admin: true,
},
}
const { deferConfig } = require('config/defer')
module.exports = {
'pubsweet-server': {
db: { database: 'test' },
port: 4000,
},
baseUrl: deferConfig(
cfg => `http://localhost:${cfg['pubsweet-server'].port}`,
),
secret: 'test',
'password-reset': deferConfig(
cfg => `http://localhost:${cfg['pubsweet-server'].port}/password-reset`,
),
mailer: {
transport: {
sendmail: false,
port: 1025,
auth: {
user: 'user',
pass: 'pass',
},
},
},
}
version: '3'
services:
app:
build:
context: .
dockerfile: ./Dockerfile-development
command: sh -c "yarn install --frozen-lockfile && ./scripts/wait-for-it.sh postgres:5432 -s -t 40 -- npx pubsweet server"
ports:
- ${PORT:-3000}:3000
volumes:
- ./:/home/xpub
depends_on:
- postgres
environment:
NODE_ENV: development
PGHOST: postgres
PGUSER: $USER
postgres:
image: postgres:10
ports:
- 5432:5432
environment:
POSTGRES_USER: $USER
volumes:
- postgres-volume:/var/lib/postgresql/data
- ./scripts/test.sql:/docker-entrypoint-initdb.d/test.sql
volumes:
postgres-volume:
......@@ -2,6 +2,7 @@
"name": "xpub-collabra",
"version": "0.0.1",
"private": true,
"workspaces": [],
"description": "xpub configured for Collabra",
"license": "MIT",
"engines": {
......@@ -24,8 +25,8 @@
"loadable-components": "^0.3.0",
"moment": "^2.18.1",
"prop-types": "^15.5.10",
"pubsweet": "^1.1.1",
"pubsweet-client": "^2.1.1",
"pubsweet": "^2.0.0",
"pubsweet-component-ink-backend": "^0.1.1",
"pubsweet-component-ink-frontend": "^1.0.0",
"pubsweet-component-login": "^1.0.1",
......@@ -37,7 +38,7 @@
"pubsweet-component-xpub-review": "^0.0.3",
"pubsweet-component-xpub-review-backend": "^0.1.0",
"pubsweet-component-xpub-submit": "^0.0.3",
"pubsweet-server": "^1.0.1",
"pubsweet-server": "^2.0.0",
"react": "^16.2.0",
"react-dom": "^16.2.0",
"react-router-dom": "^4.2.2",
......@@ -91,13 +92,17 @@
},
"scripts": {
"test": "echo YOU HAVE NO TESTS, FOOOL!",
"clean": "rm -rf node_modules",
"lint": "npm run lint:js && npm run lint:style",
"lint:js": "eslint .",
"lint:style": "stylelint app/**/*.scss app/**/*.css",
"setupdb": "pubsweet setupdb ./",
"precommit": "lint-staged",
"reset": "pubsweet setupdb --clobber ./",
"start": "pubsweet start",
"setupdb": "pubsweet setupdb",
"reset": "pubsweet setupdb --clobber",
"start": "docker-compose up",
"start:services": "docker-compose up postgres",
"server": "pubsweet server",
"build": "NODE_ENV=production pubsweet build"
},
"lint-staged": {
......
CREATE DATABASE test;
#!/usr/bin/env bash
# Use this script to test if a given TCP host/port are available
cmdname=$(basename $0)
echoerr() { if [[ $QUIET -ne 1 ]]; then echo "$@" 1>&2; fi }
usage()
{
cat << USAGE >&2
Usage:
$cmdname host:port [-s] [-t timeout] [-- command args]
-h HOST | --host=HOST Host or IP under test
-p PORT | --port=PORT TCP port under test
Alternatively, you specify the host and port as host:port
-s | --strict Only execute subcommand if the test succeeds
-q | --quiet Don't output any status messages
-t TIMEOUT | --timeout=TIMEOUT
Timeout in seconds, zero for no timeout
-- COMMAND ARGS Execute command with args after the test finishes
USAGE
exit 1
}
wait_for()
{
if [[ $TIMEOUT -gt 0 ]]; then
echoerr "$cmdname: waiting $TIMEOUT seconds for $HOST:$PORT"
else
echoerr "$cmdname: waiting for $HOST:$PORT without a timeout"
fi
start_ts=$(date +%s)
while :
do
if [[ $ISBUSY -eq 1 ]]; then
nc -z $HOST $PORT
result=$?
else
(echo > /dev/tcp/$HOST/$PORT) >/dev/null 2>&1
result=$?
fi
if [[ $result -eq 0 ]]; then
end_ts=$(date +%s)
echoerr "$cmdname: $HOST:$PORT is available after $((end_ts - start_ts)) seconds"
break
fi
sleep 1
done
return $result
}
wait_for_wrapper()
{
# In order to support SIGINT during timeout: http://unix.stackexchange.com/a/57692
if [[ $QUIET -eq 1 ]]; then
timeout $BUSYTIMEFLAG $TIMEOUT $0 --quiet --child --host=$HOST --port=$PORT --timeout=$TIMEOUT &
else
timeout $BUSYTIMEFLAG $TIMEOUT $0 --child --host=$HOST --port=$PORT --timeout=$TIMEOUT &
fi
PID=$!
trap "kill -INT -$PID" INT
wait $PID
RESULT=$?
if [[ $RESULT -ne 0 ]]; then
echoerr "$cmdname: timeout occurred after waiting $TIMEOUT seconds for $HOST:$PORT"
fi
return $RESULT
}
# process arguments
while [[ $# -gt 0 ]]
do
case "$1" in
*:* )
hostport=(${1//:/ })
HOST=${hostport[0]}
PORT=${hostport[1]}
shift 1
;;
--child)
CHILD=1
shift 1
;;
-q | --quiet)
QUIET=1
shift 1
;;
-s | --strict)
STRICT=1
shift 1
;;
-h)
HOST="$2"
if [[ $HOST == "" ]]; then break; fi
shift 2
;;
--host=*)
HOST="${1#*=}"
shift 1
;;
-p)
PORT="$2"
if [[ $PORT == "" ]]; then break; fi
shift 2
;;
--port=*)
PORT="${1#*=}"
shift 1
;;
-t)
TIMEOUT="$2"
if [[ $TIMEOUT == "" ]]; then break; fi
shift 2
;;
--timeout=*)
TIMEOUT="${1#*=}"
shift 1
;;
--)
shift
CLI=("$@")
break
;;
--help)
usage
;;
*)
echoerr "Unknown argument: $1"
usage
;;
esac
done
if [[ "$HOST" == "" || "$PORT" == "" ]]; then
echoerr "Error: you need to provide a host and port to test."
usage
fi
TIMEOUT=${TIMEOUT:-15}
STRICT=${STRICT:-0}
CHILD=${CHILD:-0}
QUIET=${QUIET:-0}
# check to see if timeout is from busybox?
# check to see if timeout is from busybox?
TIMEOUT_PATH=$(realpath $(which timeout))
if [[ $TIMEOUT_PATH =~ "busybox" ]]; then
ISBUSY=1
BUSYTIMEFLAG="-t"
else
ISBUSY=0
BUSYTIMEFLAG=""
fi
if [[ $CHILD -gt 0 ]]; then
wait_for
RESULT=$?
exit $RESULT
else
if [[ $TIMEOUT -gt 0 ]]; then
wait_for_wrapper
RESULT=$?
else
wait_for
RESULT=$?
fi
fi
if [[ $CLI != "" ]]; then
if [[ $RESULT -ne 0 && $STRICT -eq 1 ]]; then
echoerr "$cmdname: strict mode, refusing to execute subprocess"
exit $RESULT
fi
exec "${CLI[@]}"
else
exit $RESULT
fi
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment