-
Notifications
You must be signed in to change notification settings - Fork 184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding Packages in Docker Compose within Portainer Stack #476
Comments
I'm not familiar with |
Creating the following services:
shiny:
build: .
ports:
- 3838:3838 FROM rocker/shiny-verse:latest
RUN install2.r --error -n -1 sf Please check https://docs.docker.com/compose/gettingstarted/. (Note that we are currently considering adding examples of such usage to the Rocker Project site) |
I have successfully built a package using the docker file code provided by @eitsupi , however I am getting an error in my log stating that the package isn’t available when I run my shiny app:
It sounds like it may be a similar issue to this one: r-spatial/sf#1158 I’m not sure how to move forward at this point given the GDAL package is already packaged into Rocker. Any suggestions? ————————— As background for anyone who comes across this thread and is attempting something similar: I am using Portainer to manage Docker on a Synology NAS. The Docker implementation on Synology is more limited than in other environments, however Portainer augments the functionality and allows for a nice UI to do most things. Portainer does allow for building images, but at this moment it is not possible to incorporate the build process into stack deployment - they are working on it (portainer/portainer#6639). To build a rocker image with additional R packages within this framework: In Portainer select
FROM rocker/shiny-verse:latest
RUN install2.r --error --skipinstalled \
Rcpp \
sf \
readr \
xlsx \
sqldf \
sf \
tmap \
DT \
shiny \ (note: in the code above the list of items after '-skip installed' are the R package I am adding to the base rocker/shiny-verse image). Once you have your custom image you can build the stack. To build a stack in Portioner: select version: '3'
services:
shiny:
image: rocker:yourtag
restart: always
networks:
- shinyservers
ports:
- "3838:3838"
- "8787:8787"
volumes:
- "/volume1/docker/Shiny/Logs:/var/log/shiny-server"
- "/volume1/docker/Shiny/Apps:/srv/shiny-server"
networks:
shinyservers:
driver: bridge In the code above volumes references the volumes you are making available to the package on your file system. If you are using Synology - use file station to make folders for your log and apps and then insert the path to both folders in the code above before the |
Seems the dependent package are not installed; try installing FROM rocker/shiny-verse:latest
RUN apt-get update -y && apt-get install -y libudunits2-dev && install2.r --error -n -1 sf |
(As an aside if you wanted to make it easier you could rely on r2u to install all packages as binaries easily by having |
I tried: in the log throws an error - it looks like the program expects input 'Do you want to continue? [Y/n] Abort.' however since I'm not in command line it isn't available. Here is the readout from the log: WARNING: apt does not have a stable CLI interface. Use with caution in scripts. Reading package lists... Building dependency tree... Reading state information... The following additional packages will be installed: libudunits2-0 libudunits2-data The following NEW packages will be installed: libudunits2-0 libudunits2-data libudunits2-dev 0 upgraded, 3 newly installed, 0 to remove and 20 not upgraded. The command '/bin/sh -c apt update && apt install libudunits2-dev && install2.r --error -n -1 sf' returned a non-zero code: 1 |
@frabau1 Sorry, I used the wrong apt command in my post above. FROM rocker/shiny-verse:latest
RUN apt-get update -y && apt-get install -y libudunits2-dev && install2.r --error -n -1 sf If you want to ensure a reliable installation, the
FROM rocker/shiny-verse:latest
RUN /rocker_scripts/install_geospatial.sh |
@frabau1I have tested sf package on FROM rocker/shiny-verse:latest
RUN apt-get update -y && apt-get install -y libudunits2-dev libproj-dev libgdal-dev && install2.r --error -n -1 sf |
@eitsupi Thanks - that last block of code worked for me! I was able to build my image and deploy my app successfully using: FROM rocker/shiny-verse:latest I totally get you guys are volunteers and I have to say the level of support you all provide is amazing. I really appreciate all of your help. I have an unusual implementation, so ultimately testing for my environment is going to have to fall to me simply because of that. |
Installing from source is not easy, especially when you have build dependencies. But there are alternatives to consider:
This quick demo launches the r2u container (not yet a Rocker product, but related, and we do have some for the alternate / smaller c2d4u setup) and I then launch one No tricks. You should be able to reproduce and customize as needed. |
As further documentation for anyone else trying to run packages on a NAS via Portainer. You can build the custom image natively within Portainer. I was unaware this was an option in Portainer previously as I had only deployed pre-built packages. In Portainer
Additional options specific to Synology
You should be able to navigate to your shiny server using the shiny.XXXX.synology.me hostname you specified. |
Preventing index access in Rocker/Using a custom configuration file in RockerBy default it is possible to edit the url for a shiny app and view an index which lists all apps available on the shiny server. This index access can be disabled by altering the shiny config file. This took me a while to figure out so I wanted to document it for anyone else looking to do something similar. How to block access to the index.You must edit the config file and copy this edited config file into your image when building it. For information regarding the configuration file see https://docs.posit.co/shiny-server/#default-configuration Before editing the config file, you have to get a copy of the current file. This can be done by copying the current config file out of the container and saving it somewhere you can access it. My setup is on a Synology running docker/synology container manager with Portainer. I used the container console window (https://docs.portainer.io/user/docker/containers/console) within Portainer and used this code to copy the file from the container to a directory I could access NOTE: /srv/shiny-server is mapped to the root app folder so I copied it there. You could do something similar with ssh:
Once you have a copy of the config file you can open it with a text editor and altered the file to say “directory_index off” instead of the default “directory_index on”. Save your custom config file How to use a custom configuration file in RockerTo use your custom configuration file you have to copy it into your image when building it. I submitted documentation on the process of building an image using Portainer previously here: #476 (comment). This line of code copies your custom configuration file into the image being built "COPY shiny-customized.config /etc/shiny-server/shiny-server.conf" Example:
Once the image is built, you do not need to do anything special with the docker compose statement when deploying the container. Documentation issues: The documentation found here: https://github.com/rocker-org/shiny#custom-configuration mentions a commented block of code in the dockerfile that can be uncommented in order to use a custom configuration file. Looking at the docker file within the GitHub page here: https://github.com/rocker-org/shiny/blob/master/Dockerfile the referenced commented line of code with “COPY shiny-customized.config /etc/shiny-server/shiny-server.conf” does not exist. My initial question was where should this line of code appear in the dockerfile as it wasn’t included in the example code. |
Dirk/Carl,
I had emailed you in June of 2022 regarding a custom docker file that I was building. My desire was to create a combination of the Rocker geospatial image with the shiny-verse image. I picked this back up last month and I’m now using the method your team employs using helper functions to build the image. I created a git repository for my docker file here: https://github.com/frabau1/GeoShinyVerse/blob/main/Dockerfile.dockerfile
NOTE: the ‘RUN chmod +x’ was necessary due to permissions issues when trying to run the *.sh files
I’m pulling from the geospatial and shiny-verse repositories for the vast majority of the build, but I also created a helper function based on your helper functions to install a few additional R packages. My helper function is saved here:
https://github.com/frabau1/GeoShinyVerse/blob/main/install_additionalpackages.sh
When running the code the docker build will successfully complete, however I’m getting an error when trying build a container with the image:
failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "/init": stat /init: no such file or directory: unknown
Have you encountered this type of error before? I assume the init error is regarding line 56 of my docker file "CMD ["/init”]”.
Any information your could provide would be greatly appreciated.
Sincerely,
Frank Baumgardner
… On Jun 6, 2022, at 2:42 PM, Dirk Eddelbuettel ***@***.***> wrote:
Installing from source is not easy, especially when you have build dependencies. But there are alternatives to consider:
use a container that can use binaries such as r2u with all of CRAN for Ubuntu
install the packages in one go
then maybe manually / via shell command install the shiny-server .deb package and customize
<https://user-images.githubusercontent.com/673121/172225347-b31feb15-eca5-4d11-9e9f-bf77ec4c5bbf.gif>
This quick demo launches the r2u container (not yet a Rocker product, but related, and we do have some for the alternate / smaller c2d4u setup) and I then launch one install.r to install all your desired package and their dependencies as binaries.
No tricks. You should be able to reproduce and customize as needed.
—
Reply to this email directly, view it on GitHub <#476 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AZN7WNOSKKGHIOQ77TQ2OMLVNZBCFANCNFSM5XR4U3PA>.
You are receiving this because you were mentioned.
|
Is it possible to add packages via a Docker Compose statement in a Portainer stack? I typically deploy my docker containers as stacks and I’ve written the following code to deploy this stack:
My issue revolves around the environmental variables with RUN commands above. I’m not familiar with the syntax to install additional packages when deploying Rocker as a stack, and have been unable to find any examples. The documentation on the Rocker website references command line code https://www.rocker-project.org/use/extending/, which is what I attempted to insert above in a failed experiment.
I have successfully deployed test programs that do not require any additional packages using the rest of the code above, however the project I’m working on needs the ’sf’ package in addition to those bundled with the shiny-verse image. I’ve experimented with additional syntax beyond what I inserted above without success.
Is there a way to deploy a Rocker stack and include additional packages? Any guidance would be greatly appreciated.
The text was updated successfully, but these errors were encountered: