rubenarslan / formr.org

Chain simple surveys into longer runs to build complex studies. Use R to generate pretty feedback and complex designs.
https://formr.org
Other
131 stars 36 forks source link

Feature request: Docker container #497

Open kasnder opened 1 year ago

kasnder commented 1 year ago

We would love to host a formr instance by our research group but have a limited server environment. To set up an instance, it'd be great if there was a ready-to-use docker container to install formr with a few clicks. @ulyngs

ulyngs commented 1 year ago

I believe we've tried to follow the instructions currently available but were unable to make it work! :(

rubenarslan commented 1 year ago

Send me an email please :-)

jvanalst commented 1 year ago

Just started working on a Docker Composition for Formr for a researcher. There's definitely demand for a working Docker container.

jvanalst commented 1 year ago

v10.0.5 working in a Docker Container without a DB, Cron, or OpenCPU (yet). I know for the Database I'll be using MySQL official image in a docker-compose.yml. Not sure what to do about the Cron or OpenCPU.

There is an official OpenCPU Image on Docker Hub, but I'm not sure how to use it in a composition yet. And I don't know what it is or how to use the API anyways to test it. Heck, at this point I don't even know if I should be using the base image or the rstudio image.

Putting the cron on the same machine as the PHP-Apache violates Docker's philosophy of separation (1 machine for 1 job). Hence not sure what to do... whether to install Supervisor (a hacky way of getting around the issue), or just spool up cron specific machine (probably the correct way to do it).


# syntax=docker/dockerfile:1

FROM php:7.4.33-apache

# Install System & PHP Dependencies
RUN apt-get update 
RUN apt-get upgrade -y
RUN apt-get install -y pandoc libzip-dev libxml2-dev libpng-dev libonig-dev libsodium-dev libcurl4-openssl-dev git
RUN docker-php-ext-install zip xml gd intl mbstring curl pdo pdo_mysql

# Install Composer from Official Composer Image
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer

# Configure PHP
COPY formr/usr/local/etc/php/php.ini /usr/local/etc/php/php.ini

# Install & Configure FormR
WORKDIR /var/www
RUN rm -r html
RUN git clone https://github.com/rubenarslan/formr.org.git html
WORKDIR /var/www/html
RUN git checkout v10.0.5
RUN chown -R www-data:www-data /var/www/html
RUN composer install
COPY formr/var/www/html/config /var/www/html/config

# Configure Apache2
RUN a2enmod rewrite headers
COPY formr/etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/000-default.conf
RUN service apache2 restart
cyriltata commented 1 year ago

Dear Jeffery

Thanks for trying out the Docker configuration. I think it would be difficult to entirely separate the supervisor tasks since it is an integral part of the formr application and generates files needed by the core application. I think supervisor can be installed in same container and the configuration should be mounted in a volume (similar to what should be done with the formr config) So formr config, apache config and supervisor config should be mounted via a volume. Formr has a "config" folder that should make this easy (hopefully;))

If the host has enough resources and you are using docker compose, mysql and opencpu could be added as other "services". Mysql already has an image but no idea about opencpu. Opencpu could be based on an Ubuntu image.

The if you place all your services under the same network, the services should communicate seamlessly via various configurations.

If I may ask, why did you try with an old version of formr?

Best Cyril

On Thu, Feb 9, 2023, 19:50 Jeffrey D. Van Alstine @.***> wrote:

v10.0.5 working in a Docker Container without a DB, Cron, or OpenCPU (yet). I know for the Database I'll be using MySQL official image in a docker-compose.yml. Not sure what to do about the Cron or OpenCPU.

There is an official OpenCPU Image on Docker Hub, but I'm not sure how to use it in a composition yet. And I don't know what it is or how to use the API anyways to test it. Heck, at this point I don't even know if I should be using the base image or the rstudio image.

Putting the cron on the same machine as the PHP-Apache violates Docker's philosophy of separation (1 machine for 1 job). Hence not sure what to do... whether to install Supervisor (a hacky way of getting around the issue), or just spool up cron specific machine (probably the correct way to do it).

syntax=docker/dockerfile:1

FROM php:7.4.33-apache

Install System & PHP DependenciesRUN apt-get update RUN apt-get upgrade -yRUN apt-get install -y pandoc libzip-dev libxml2-dev libpng-dev libonig-dev libsodium-dev libcurl4-openssl-dev gitRUN docker-php-ext-install zip xml gd intl mbstring curl pdo pdo_mysql

Install Composer from Official Composer ImageCOPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer

Configure PHPCOPY formr/usr/local/etc/php/php.ini /usr/local/etc/php/php.ini

Install & Configure FormRWORKDIR /var/wwwRUN rm -r htmlRUN git clone https://github.com/rubenarslan/formr.org.git htmlWORKDIR /var/www/htmlRUN git checkout v10.0.5RUN chown -R www-data:www-data /var/www/htmlRUN composer installCOPY formr/var/www/html/config /var/www/html/config

Configure Apache2RUN a2enmod rewrite headersCOPY formr/etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/000-default.confRUN service apache2 restart

— Reply to this email directly, view it on GitHub https://github.com/rubenarslan/formr.org/issues/497#issuecomment-1424663196, or unsubscribe https://github.com/notifications/unsubscribe-auth/AARL5Z4F3YZMLFC6ICL5JODWWU4AHANCNFSM6AAAAAASBCKRIA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

jvanalst commented 1 year ago

@cyriltata Oh interesting. I didn't notice it was an older version (2016). I just assumed since it was the highest version number it was the release. I'll switch to working v0.20.x.

jvanalst commented 1 year ago
# syntax=docker/dockerfile:1

FROM php:8.2.2-apache

# Install System & PHP Dependencies
RUN apt-get update 
RUN apt-get upgrade -y
RUN apt-get install -y pandoc libzip-dev libxml2-dev libpng-dev libonig-dev libsodium-dev libcurl4-openssl-dev git
RUN docker-php-ext-install zip xml gd intl mbstring curl pdo pdo_mysql

# Install Composer from Official Composer Image
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer

# Configure PHP
COPY formr/usr/local/etc/php/php.ini /usr/local/etc/php/php.ini

# Install & Configure Formr
WORKDIR /var/www
RUN rm -r html
RUN git clone https://github.com/rubenarslan/formr.org.git
RUN ln -s /var/www/formr.org/webroot /var/www/html
WORKDIR /var/www/formr.org
RUN git checkout v0.20.5
RUN composer install
COPY formr/var/www/formr.org/config /var/www/formr.org/config
RUN chown -R www-data:www-data /var/www/formr.org

# Configure Apache2
RUN a2enmod rewrite headers
COPY formr/etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/000-default.conf
RUN service apache2 restart
NS21fpsy commented 1 year ago

Does anyone have a YAML for a setup with Docker Compose, where the different components (like formR, database, OpenCPU) work together?

Or does anyone have a Docker image that does not separate the components into different containers, but configures everything together in the same container?

Does anyone have a repository where I can look at such a solution? Thanks and best regards

cyriltata commented 1 year ago

@NS21fpsy you could try our experimental image https://hub.docker.com/r/formr/formr.org that could be deployed with this docker-compose https://github.com/cyriltata/formr.docker (read instructions). It sets up the formr software and mysql in two different containers.

opencpu on the other one could be installed in another machine or they do also have an image https://hub.docker.com/r/opencpu/base, which you need to install your necessary R packages on, including the formr R package.

Let us know if you succeed.