Skip to content

Commit

Permalink
Merge branch 'iss21-fork-rename' into pianistica
Browse files Browse the repository at this point in the history
  • Loading branch information
maizy committed Jan 2, 2021
2 parents b30c569 + 70e2937 commit 2e1f1a2
Show file tree
Hide file tree
Showing 76 changed files with 2,778 additions and 5,039 deletions.
10 changes: 7 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,18 @@ module.exports = {
"no-console": "off",
"no-unused-vars": "off",
"no-empty": "off",

"no-constant-condition": [
"error",
{ "checkLoops": false }
],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"double"
],
"double",
{ "avoidEscape": true }
]
}
};
29 changes: 25 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
FROM leafo/lapis-archlinux-itchio:latest
MAINTAINER leaf corcoran <leafot@gmail.com>
FROM archlinux/base:latest AS build_image

RUN pacman -Sy tup nginx git nodejs-lts-fermium npm sassc python3 python-pip --noconfirm && (yes | pacman -Scc || :)

WORKDIR /site/pianistica

# init npm as separate step, for better caching
ADD package.json package.json
ADD package-lock.json package-lock.json
RUN npm install

WORKDIR /site/sightreading.training
ADD . .
ENTRYPOINT ./ci.sh

RUN python3 -m pip install -r requirements.txt && \
tup init && \
tup generate build.sh && \
sed -i.bak '2iset -o xtrace' build.sh && \
./build.sh && \
rm -r node_modules .tup

FROM nginx:1.17.6-alpine as final_image
WORKDIR /site/pianistica
COPY --from=build_image /site/pianistica/static /site/pianistica/static
COPY --from=build_image /site/pianistica/serverless /site/pianistica/serverless
COPY --from=build_image /site/pianistica/mime.types /site/pianistica/mime.types

ENTRYPOINT nginx -c /site/pianistica/serverless/nginx.conf
38 changes: 1 addition & 37 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,41 +1,5 @@

.PHONY: new_migration migrate init_schema test_db lint lint_js checkpoint restore_checkpoint annotate_models

new_migration:
(echo " [$$(date +%s)]: =>"; echo) >> migrations.moon

migrate:
lapis migrate
make schema.sql

schema.sql:
pg_dump -s -U postgres sightreading > schema.sql
pg_dump -a -t lapis_migrations -U postgres sightreading >> schema.sql

init_schema:
createdb -U postgres sightreading
cat schema.sql | psql -U postgres sightreading

test_db:
-dropdb -U postgres sightreading_test
createdb -U postgres sightreading_test
pg_dump -s -U postgres sightreading | psql -U postgres sightreading_test
pg_dump -a -t lapis_migrations -U postgres sightreading | psql -U postgres sightreading_test

lint:
git ls-files | grep '\.moon$$' | grep -v config.moon | xargs -n 100 moonc -l
.PHONY: lint_js

lint_js:
node_modules/.bin/eslint $$(git ls-files | grep \.es6$$ | grep -v spec)

checkpoint:
mkdir -p dev_backup
pg_dump -F c -U postgres sightreading > dev_backup/$$(date +%F_%H-%M-%S).dump

restore_checkpoint:
-dropdb -U postgres sightreading
createdb -U postgres sightreading
pg_restore -U postgres -d sightreading $$(find dev_backup | grep \.dump | sort -V | tail -n 1)

annotate_models:
lapis annotate $$(find models -type f | grep moon$$)
57 changes: 34 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
# Fork of Sight Reading Trainer
# Pianistica

Fork of Sight Reading Trainer.

All kudos go to original
[sightreading.training](https://github.com/leafo/sightreading.training) authored by [@leaf](https://github.com/leafo).
[sightreading.training](https://github.com/leafo/sightreading.training) written by [@leaf](https://github.com/leafo).


## Static version

https://pianistica.maizy.ru/

## In this fork

Expand All @@ -10,35 +17,36 @@ Branch | Description
[setup-fork](https://github.com/maizy/sightreading.training/pull/2/files) | Fork setup, fix file names for macOS
[iss4-serverless-build](https://github.com/maizy/sightreading.training/pull/7/files) | Serverless version: build docker container
[iss5-macos-dev-support](https://github.com/maizy/sightreading.training/pull/6/files) | Dev automation for serverless version, especially for macOS
[iss5-ios-support](https://github.com/maizy/sightreading.training/pull/8/files) | iOS + Web MIDI Browser support (authored by [@MaienM](https://github.com/MaienM/sightreading.training))
[iss5-ios-support](https://github.com/maizy/sightreading.training/pull/8/files) | iOS + Web MIDI Browser support (written by [@MaienM](https://github.com/MaienM/sightreading.training))
[iss4-python-guides-converter](https://github.com/maizy/sightreading.training/pull/9/files) | Remove lua requirements for building statics, use python instead. Lightweight final docker image.
[disable-backend](https://github.com/maizy/sightreading.training/pull/13/files) | Disable lua files compiling
[iss11-notes-label](https://github.com/maizy/sightreading.training/pull/15) | Show notes label
[iss14-decrease-octave-num](https://github.com/maizy/sightreading.training/pull/16/files) | decrease octave number (ex: C5 -> C4). done with a very dirty hack.
[iss21-fork-rename](https://github.com/maizy/sightreading.training/pull/27) | fork renamed to Pianistica, lua backend removed, static version added, upgraded from upstream

## Serverless version

Version without lua backend. Only nginx serving statics.

#### Prebuild containers for releases

https://hub.docker.com/r/maizy/sightreading-training-static/tags
https://github.com/users/maizy/packages/container/package/pianistica

```
docker run -d --name=sightreading-training --restart=always \
-p 8080:80 maizy/sightreading-training-static:latest
docker run -d --name=pianistica --restart=always \
-p 8080:80 ghcr.io/maizy/pianistica:latest
```

#### Build

```
docker build -t st-serverless:latest -f serverless.dockerfile .
docker build -t pianistica:latest .
```

#### Run

```
docker run -p 127.0.0.1:8080:80 st-serverless:latest
docker run -p 127.0.0.1:8080:80 pianistica:latest
```

Server started at [http://127.0.0.1:8080/](http://127.0.0.1:8080/)
Expand All @@ -48,35 +56,34 @@ Server started at [http://127.0.0.1:8080/](http://127.0.0.1:8080/)
#### 1\.

```
brew cask install osxfuse # restart may required
brew install sassc npm tup python
brew install --cask osxfuse # restart may required
brew install sassc nvm tup python
python -m pip install -r requirements.txt
```

#### 2\. comment line with moon

in `static/guides/Tupfile`
#### 2\. setup nvm, install nodejs 14.15.x, init node modules

```diff
--- a/static/guides/Tupfile
+++ b/static/guides/Tupfile
@@ -1,3 +1,3 @@
.gitignore
See `brew info nvm` for nvm setup instructions.

-: foreach *.md |> moon convert_to_json.moon %f > %o |> %B.json
+#: foreach *.md |> moon convert_to_json.moon %f > %o |> %B.json
```

nvm install 14.15.3
nvm use 14.15.3
node --version
# v14.15.3
npm --version
# 6.14.9
```

#### 3\. init tup DB

```
tup init
```

#### 4\. update generated files
#### 4\. update libs & generated files

```
npm install
tup
```

Expand All @@ -87,7 +94,7 @@ rm -rf .tup/
./cleanup.sh
```

Then do 3rd & 4th steps again.
Then do steps #3, 4 again.

## Run dev serverless version

Expand All @@ -103,6 +110,10 @@ For macOS see instruction above.
docker-compose -f dev-docker-compose.yml up
```

#### 4\. Go to

http://127.0.0.1:8080/

#### 4\. After any changes

Run tup for regenerating files
Expand Down
1 change: 0 additions & 1 deletion Tuprules.tup
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ TOP = $(TUP_CWD)
!pegjs = |> cat %f | $(TOP)/node_modules/.bin/pegjs --format amd | sed -e 's/^define(/define("st\/%O", /' > %o |>

: foreach *.scss |> !scss |> %B.css
#: foreach *.moon |> moonc %f |> %B.lua
108 changes: 0 additions & 108 deletions app.moon

This file was deleted.

1 change: 0 additions & 1 deletion applications/Tupfile

This file was deleted.

51 changes: 0 additions & 51 deletions applications/admin.moon

This file was deleted.

Loading

0 comments on commit 2e1f1a2

Please sign in to comment.