diff --git a/.gitignore b/.gitignore index 06b34da..a14f8c8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,6 @@ *.css *.map +/.dart_tool/ +/.packages +/pubspec.lock +/.sass-cache/ diff --git a/Dockerfile b/Dockerfile index 8fe9775..6780ded 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,6 +11,7 @@ ADD pubspec.* /app/ RUN pub get RUN pub get --offline +# Get Ruby Sass RUN apt update && apt install ruby-sass ruby-dev build-essential -y RUN gem install sass-listen diff --git a/README.org b/README.org index 6ccd9eb..ccb7ecd 100644 --- a/README.org +++ b/README.org @@ -54,18 +54,39 @@ This is everything you need for beautiful org-generated websites. *** Running locally - You could install Dart on your machine, as well as the Ruby implementation - of SASS with its dependencies. Then, all you have to do is run ~start.sh~, - and you’re good to go! Content will be delivered on the 8080 port. If you - wish to deliver content to another port, you can edit this file. + You could install Dart on your machine, as well as the Ruby implementation + of SASS with its dependencies. Next, you will need to install ~webdev~ and + install the Dart dependencies: + #+BEGIN_SRC sh + $ pub global activate webdev + $ pub get + #+END_SRC + + By the way, you have to ensure your Dart cache’s bins are in your ~$PATH~. + They are generally installed in your ~$HOME/.pub-cache/bin~ directory. + + Then, you have to run ~start.sh~, and you’re good to go! Content will be + delivered on the 8080 port. If you wish to deliver content to another port, + you can edit this file. + #+BEGIN_SRC sh + # Release mode + RELEASE="release" ./start.sh + + # Debug mode + ./start.sh + #+END_SRC *** Docker A Dockerfile is also provided so you can run this server inside a Docker container, and thus you can avoid the hassle of installing Dart and Ruby - Sass. In order to run OWB, you can run the following: + Sass. In order to run OWB, you can first build the Docker image: #+BEGIN_SRC sh - $ docker build . --tag owb:1.0 - $ docker run \ + docker build . --tag owb:1.0 + #+END_SRC + + And then you can run it: + #+BEGIN_SRC sh + docker run \ -p 8080:8080 \ -e RELEASE="release" \ --restart always \ @@ -79,10 +100,9 @@ filesystem. This will also make ~webserver~ run in development mode; expect shorter Dart compilation time, but slower Dart code execution. #+BEGIN_SRC sh - $ docker run \ + docker run \ -p 8080:8080 \ -v ./web:/app/web \ - -e RELEASE="debug" \ --restart always \ --detach \ --name owb \ diff --git a/docker-compose.yml b/docker-compose.yml index 48b9d02..28a6c84 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,5 +6,3 @@ services: ports: - 8010:8080 restart: always - volumes: - - ./web/:/app/web/ diff --git a/start.sh b/start.sh index c655788..3ba8de3 100755 --- a/start.sh +++ b/start.sh @@ -1,3 +1,18 @@ #!/bin/bash -sass --watch web/style/:web/style -tcompressed & -webdev serve --release --hostname 0.0.0.0 + +function start_release() { + echo "Starting backend in RELEASE mode" + sass --watch web/style/:web/style -tcompressed & + webdev serve --release --hostname 0.0.0.0 +} + +function start_debug() { + echo "Starting backend in DEBUG mode" + sass --watch web/style/:web/style -tcompressed & + webdev serve --hostname 0.0.0.0 +} + +echo Relase: $RELEASE +[ "$RELEASE" == "release" ] \ + && start_release \ + || start_debug