These are just some of the ways in which one can deploy an ambiorix application.
Remember to open the open the port used by the application on your server.
Also remember to define a
port in the app or it will serve
on a dynamic port unknown at run time.
There is now a load balancer for ambiorix applications so one can serve concurrent users with ease. The load balancer is documented here.
The application can be deployed as a service on any Linux server. Create a new
.service in the
The name of the file defines the name of the service.
.service file place the following, it creates a service that runs the application at the defined path (
ExecStart=cd path/to/app && /usr/bin/Rscript --no-save --slave -f app.R
One the service is added restart the daemon, you might have to run it as
You can then start and enable the service, again, you might have to run it as
systemctl start ambiorix
systemctl enable ambiorix
Once the app has started, check its status to make sure that everything runs well.
systemctl status ambiorix
The easiest way to deploy an ambiorix app is using docker.
This project comes with an image you can pull and use.
docker pull jcoenep/ambiorix
By default the image will use an internal very basic application and binds it to port
docker run -p 3000:3000 jcoenep/ambiorix
To use your own application mount your app in the images
/app directory, so from the root of the app this would look like this:
docker run -v "$(pwd)"/.:/app -p 3000:3000 jcoenep/ambiorix
Or you can generate your own dockerfile.
create_dockerfile(port = 3000L)
create_dockerfile will parse the
DESCRIPTION file to create a
Dockerfile, below is an example of the output.
RUN echo "options(repos = c(CRAN = 'https://packagemanager.rstudio.com/all/latest'), download.file.method = 'libcurl')" >> /usr/local/lib/R/etc/Rprofile.site
RUN R -e 'install.packages("remotes")'
RUN R -e "remotes::install_github('JohnCoene/echarts4r')"
COPY . .
RUN R -e "options(ambiorix.host='0.0.0.0', 'ambiorix.port'=3000);source('app.R')"
You can then build the image.
docker build -t ambiorix .
Finally, run it.
docker run ambiorix
With docker installed this will work just as well on your machine as on a remote server.