question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How can I deploy openrouteservice-app headless? I would like to dockerize it and start it with the openrouteservice through a combined docker-compose.

First obstacle: the dev mode always tries to xdg-open, which will fail with an error on headless mode.

UnhandledPromiseRejectionWarning: Error: Exited with code 3

If you reach this via google: A solution to prevent that is setting open: false in the Gruntfile.js.

The next obstacle seems network related. On an EC2 instance I cannot connect to the grunt web server. It always fails with Unable to connect, even with all ports open. When launching the openrouteservice-app from a docker container, I can only connect when I run docker run --network host .... Wireshark seems to catch plenty of communication via the 50624-50634 or the 53080-53116 range, but exposing these does not seem to fix it.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
docquantumcommented, Aug 9, 2019

I am trying to build a docker stack that has both ors and ors-app on the same network, both in docker containers. I am doing this through docker compose pulling ors from docker hub and I wrote a dockerfile for ors-app and built it locally. After making the described changes above, I did get it working in a docker container, I just have issues with CORS accessing the backend (ors) locally, but I can access the ors public api.

For reference, here’s the dockerfile:

FROM node:lts-alpine AS build

# Set environment variables
ENV LANG="en_US.UTF-8" LANGUAGE="en_US.UTF-8" DEBIAN_FRONTEND="noninteractive" TERM="xterm"

WORKDIR /src

COPY *.json /src/
COPY .snyk .snyk
COPY .bowerrc .bowerrc

RUN apk --no-cache update && apk --no-cache add git \ 
  && npm install \
  && node_modules/bower/bin/bower install --allow-root\
  && cd bower_components/angularjs-slider \
  && npm install \
  && npm audit fix \
  && cd ../../ \
  && npm audit fix 


FROM node:lts-alpine AS production
LABEL MAINTAINER="Daniel Shchur (DocQuantum) <shchurgood@gmail.com>"
ENV API_KEY="" PATH="/app/node_modules/.bin:$PATH"
WORKDIR /app

COPY --from=build /src ./
COPY app app
RUN echo ${API_KEY} > app/weathercheck.txt
COPY Gruntfile.default.js Gruntfile.js
COPY main.js main.js
COPY bs-config.js bs-config.js

EXPOSE 3035 8888

CMD [ "grunt", "production" ]

Docker-compose:

version: '3'

services:
    ors-back:
        image: giscience/openrouteservice:release_5.0.2
        container_name: ors-back
        restart: on-failure
        expose:
            - 8080
        volumes:
            - /home/rancher/containers/ors-back/graphs:/ors-core/data/graphs
            - /home/rancher/containers/ors-back/elevation_cache:/ors-core/data/elevation_cache
            - /home/rancher/containers/ors-back/logs/ors/:/var/log/ors/
            - /home/rancher/containers/ors-back/logs/tomcat/:/usr/local/tomcat/logs
        healthcheck:
            test: ["CMD", "wget", "http://localhost:8080/ors/health"]
            interval: 1m30s
            timeout: 10s
            retries: 3

    ors-front:
        image: orsapp:latest
        container_name: ors-front
        restart: on-failure
        ports:
            -  8888:8888

And directives of my Gruntfile.js

production: {
    options: {
        hostname: "0.0.0.0",
        port: 8888,
        base: "./build",
        middleware: function(connect) {
            return [
                connect().use(function (req, res, next) {
                    res.setHeader('Access-Control-Allow-Origin', '*');
                    return next();
                }),
                //modRewrite(['^[^\\.]*$ /index.html [L]']),
                modRewrite([
                    "!\\.html|\\.js|\\.txt|\\.ico|\\.svg|\\.map|\\.woff2|\\.woff|\\.ttf|\\.css|\\.png$ /index.html [L]"
                ]),
                serveStatic("./build")
            ];
        }
    }
}

...

build: {
    options: {
        dest: "app/js/config.js"
    },
    constants: {
        ENV: {
            name: "build",
            // change name_of_war_archive to the name of the ors backend war version you are using (e.g. openrouteservice-4.4.0)
            geocode:
                "http://ors-back:8080/ors/geocode",
            directions:
                "http://ors-back:8080/ors/routes",
            isochrones:
                "http://ors-back:8080/ors/isochrones",
            matrix:
                "http://ors-back:8080/ors/matrix",
            pois:
                "https://api.openrouteservice.org/pois",
            shortenlink: "https://api-ssl.bitly.com/v3/shorten",
            mapsurfer:
                "https://api.openrouteservice.org/mapsurfer/{z}/{x}/{y}.png",
            landmarks: 'https://landmarks-api.openrouteservice.org/',
            fuel: "https://api.openrouteservice.org/fuel"
        }
    }
}

I am currently running both of these on a headless server running RancherOS (docker-only OS).

I am documenting my findings on this issue thread in case others wish to run headless as well and wish to find a way to run this application in a docker container for testing or production.

0reactions
Doevcommented, Jun 9, 2020

Hello docquantum, thank you very much for sharing your state of dockerize. I will need some time to work with it, cause I have no deep experience with docker.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Headless Deployment Is Hard – These 6 Tips Make It Easier
1. Always start with a discovery workshop before your headless deployment. Headless commerce is the “how,” not the “why” to solving operational ...
Read more >
3 Steps to Rapidly Deploy a Headless Single Page Application
Headless single page applications don't necessarily require any back-end code—they can give you freedom to deploy quickly and easily.
Read more >
Headless deployment of a monitor model - IBM
This is called headless deployment, meaning that it does not require a user interface. Headless deployment is useful for automated development and testing, ......
Read more >
What's a Headless CMS? The Beginner's Guide - Netlify
What's a headless CMS, and how are they different from traditional content management systems? Learn the basics of headless CMSes and deploy ......
Read more >
Headless architecture: the new normal | Accenture
In simple language, headless architecture means wrapping up all the business logic and functionalities in a set of APIs, which are powered by ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found