Fixed issues with running backend

This commit is contained in:
Lucien Cartier-Tilet 2020-05-05 16:41:16 +02:00
parent 19f2b99d7e
commit d86bb23c88
Signed by: phundrak
GPG Key ID: BD7789E705CB8DCA
3 changed files with 25 additions and 55 deletions

View File

@ -69,10 +69,6 @@
delivered on the 8080 port. If you wish to deliver content to another port, delivered on the 8080 port. If you wish to deliver content to another port,
you can edit this file. you can edit this file.
#+BEGIN_SRC sh #+BEGIN_SRC sh
# Release mode
RELEASE="release" ./start.sh
# Debug mode
./start.sh ./start.sh
#+END_SRC #+END_SRC
@ -85,20 +81,6 @@
#+END_SRC #+END_SRC
And then you can run it: And then you can run it:
#+BEGIN_SRC sh
docker run \
-p 8080:8080 \
-e RELEASE="release" \
--restart always \
--detach \
--name owb \
owb:1.0
#+END_SRC
If you wish to run this in development mode, you could attach a volume so
the Dart and SCSS code are linked between your container and your
filesystem. This will also make ~webserver~ run in development mode; expect
shorter Dart compilation time, but slower Dart code execution.
#+BEGIN_SRC sh #+BEGIN_SRC sh
docker run \ docker run \
-p 8080:8080 \ -p 8080:8080 \
@ -117,22 +99,12 @@
docker-compose up --detach docker-compose up --detach
#+END_SRC #+END_SRC
If, as above, you wish to enter development mode, you could modify the ** Running in development mode
~docker-compose.yml~ file like so: To run this backend in development mode, you will have to remove the
#+BEGIN_SRC yaml ~--release~ option from the ~webdev~ command in the ~start.sh~ file. This
version: '3' will allow webdev to compile Dart files faster, but at the price of slower
compiled Javascript files. If you use Docker, dont forget to rebuild your
services: image.
web:
build: .
environment:
- RELEASE="debug"
ports:
- 8080:8080
restart: always
volumes:
- ./web/:/app/web/
#+END_SRC
** How can I use this in my org files? ** How can I use this in my org files?
Lets say you serve your files on org.example.com, add the following lines to Lets say you serve your files on org.example.com, add the following lines to
@ -152,11 +124,22 @@
such as Nginx. You could have for example the following lines: such as Nginx. You could have for example the following lines:
#+BEGIN_SRC nginx #+BEGIN_SRC nginx
location /dart { location /dart {
root http://localhost:8080/dart; proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://localhost:8080/dart;
} }
location /style { location /style {
root http://localhost:8080/style; proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://localhost:8080/style;
}
location /packages {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://localhost:8080/packages;
} }
#+END_SRC #+END_SRC

View File

@ -1,8 +1,10 @@
version: '3' version: '3'
services: services:
web: owb:
build: . build: .
ports: ports:
- 8010:8080 - 8010:8080
restart: always restart: always
volumes:
- ./web:/app/web

View File

@ -1,18 +1,3 @@
#!/bin/bash #!/bin/bash
function start_release() {
echo "Starting backend in RELEASE mode"
sass --watch web/style/:web/style -tcompressed & sass --watch web/style/:web/style -tcompressed &
webdev serve --release --hostname 0.0.0.0 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