Skip to content
This repository has been archived by the owner on Mar 30, 2022. It is now read-only.

Commit

Permalink
feat: support for running the latest version of editor locally (#705)
Browse files Browse the repository at this point in the history
Adds a docker-compose file that can be used to run the latest version of Libero Editor locally.
  • Loading branch information
NuclearRedeye authored Mar 16, 2021
1 parent 21227cd commit 5ea134e
Show file tree
Hide file tree
Showing 9 changed files with 171 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .localstack/config/notification.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"QueueConfigurations": [
{
"QueueArn": "http://localhost:4566/000000000000/EditorImportQueue",
"Events": [
"s3:ObjectCreated:*"
]
}
]
}
8 changes: 8 additions & 0 deletions .localstack/startup/01-init-s3.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

echo "Initializing S3"
declare -a BUCKETS=("s3-editor-source-bucket" "s3-editor-destination-bucket")
for BUCKET in ${BUCKETS[@]}; do
echo "- Creating Bucket '$BUCKET'"
awslocal s3 mb s3://$BUCKET
done
7 changes: 7 additions & 0 deletions .localstack/startup/02-init-sqs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
echo "Initializing SQS"
awslocal sqs create-queue --queue-name EditorImportQueue
echo 'SQS queue created'
echo 'setting up bucket notifications'
awslocal s3api put-bucket-notification-configuration --bucket s3-editor-source-bucket --notification-configuration file:///etc/localstackconf/notification.json
echo 'bucket notifications ready'
10 changes: 10 additions & 0 deletions .localstack/startup/03-provision-s3.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

echo "Provisioning S3"
for ARTICLE in /tmp/articles/*
do
if [[ -f $ARTICLE ]]; then
echo "- Adding '${ARTICLE##*/}' to Bucket 's3-editor-source-bucket'"
awslocal s3 cp $ARTICLE s3://s3-editor-source-bucket/
fi
done
24 changes: 24 additions & 0 deletions .nginx/nginx.conf.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
events {
worker_connections 1024;
}
http {
server {
listen 80;
listen [::]:80;

server_name localhost;

location /api/v1 {
rewrite /api/v1/(.*) /$1 break;
proxy_pass http://${PREFIX}-article-store:8080/;
proxy_set_header Host $host;
proxy_redirect http://${PREFIX}-localstack:4566/ http://localhost:4566/;
}

location / {
proxy_pass http://${PREFIX}-client:80/;
proxy_set_header Host $host;
}

}
}
File renamed without changes.
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,35 @@ Libero Editor is a work in progress with ProseMirror at its core. ProseMirror is

---

## Quick Start

If you want to try out the latest version of Libero Editor, then it's pretty simple to run an instance on you own machine. All you need is to install [Docker](https://www.docker.com/), and then...

```
git clone https://github.com/libero/editor.git
cd editor
docker-compose up
```

Startup will take around 20 seconds, then visit http://localhost:4000 in your web browser.

## Cleaning Up

Once you've had enough, or if you want discard any changes that you've made, then run...

```
docker-compose rm
```
## Trying Your Own Content

**NOTE:** Libero Editor is still under development, and hence your mileage will vary when testing your own content. If you do encounter any issues then please feel free to raise a bug [here](https://github.com/libero/editor/issues/new/choose).

If you would like to try the Editor with your own JATS XML content, then take your XML and any other assets and place them in a folder that follows the naming scheme `<journal>-<id>-<version>`, e.g. `libero-12345-v1`. Next, ZIP the folder following the same naming scheme, e.g `libero-12345-v1.zip` and then copy/move the archive to the `articles` directory in this repository.

Lastly, using the instructions above start the Editor and navigate to http://localhost:4000 adding the `articleId` query parameter and setting the value to the `<id>` you used above, e.g. http://localhost:4000?articleId=12345.

---

## Contributing to Libero Editor

Guides for making feature requests and design suggestions.
Expand Down Expand Up @@ -74,3 +103,7 @@ State your feature request as simply and clearly as possible so that your idea i
#### Keep feedback constructive

Voice your opinions clearly, constructively and calmly. Design feedback should ideally be measured against supporting user stories, taking the time to carefully work through the pros and cons of a proposed solution.

## License

Licensed under [MIT](https://github.com/libero/editor/blob/master/LICENSE.md)
Binary file added articles/elife-54296-vor-r1.zip
Binary file not shown.
79 changes: 79 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
version: '3.5'

services:
localstack:
image: localstack/localstack
container_name: ${PREFIX-editor}-localstack
restart: unless-stopped
environment:
- SERVICES=s3,sqs
volumes:
- './.localstack/startup:/docker-entrypoint-initaws.d:ro'
- './.localstack/config:/etc/localstackconf:ro'
- './articles:/tmp/articles:ro'
ports:
- 4566:4566
healthcheck:
test: 'echo -e "GET /health\n\n" | nc ${PREFIX-editor}-localstack 4566'
interval: 1m
timeout: 10s
retries: 3
start_period: 60s

mongo:
image: mongo
container_name: ${PREFIX-editor}-mongo
restart: unless-stopped
environment:
- MONGO_INITDB_ROOT_USERNAME=root
- MONGO_INITDB_ROOT_PASSWORD=password
ports:
- 27017:27017
healthcheck:
test: echo 'db.runCommand("ping").ok' | mongo ${PREFIX-editor}-mongo:27017/test --quiet
interval: 10s
timeout: 10s
retries: 3
start_period: 20s

editor-article-store:
image: liberoadmin/editor-article-store:${TAG-latest}
container_name: ${PREFIX-editor}-article-store
restart: unless-stopped
depends_on:
- mongo
- localstack
environment:
- PORT=8080
- DB_ENDPOINT=${PREFIX-editor}-mongo:27017
- DB_NAME=editor
- DB_USER=root
- DB_PASSWORD=password
- AWS_REGION=eu-west-1
- AWS_ACCESS_KEY=key
- AWS_SECRET_ACCESS_KEY=secret
- AWS_BUCKET_INPUT_EVENT_QUEUE_URL=http://${PREFIX-editor}-localstack:4566/000000000000/EditorImportQueue
- AWS_ENDPOINT=http://${PREFIX-editor}-localstack:4566
- AWS_SRC_BUCKET=s3-editor-source-bucket
- AWS_EDITOR_BUCKET=s3-editor-destination-bucket

editor-client:
image: liberoadmin/editor-client:${TAG-latest}
container_name: ${PREFIX-editor}-client
restart: unless-stopped
depends_on:
- editor-article-store

nginx:
image: nginx:alpine
container_name: ${PREFIX-editor}-nginx
depends_on:
- editor-article-store
- editor-client
environment:
- PREFIX=${PREFIX-editor}
- NGINX_ENVSUBST_OUTPUT_DIR=/etc/nginx
volumes:
- './.nginx:/etc/nginx/templates'
ports:
- ${PORT-4000}:80

0 comments on commit 5ea134e

Please sign in to comment.