Installation for S&D
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

144 lines
3.7 KiB

  1. # From here we will move the composer binary
  2. FROM composer:1.10 AS composer
  3. # Download base image ubuntu 20.04
  4. FROM ubuntu:20.04
  5. # Changing sh shell to bash
  6. SHELL ["/bin/bash", "-c", "-o", "pipefail"]
  7. # Change working directory
  8. WORKDIR /var/www/html
  9. # Disable Prompt During Packages Installation
  10. ARG DEBIAN_FRONTEND=noninteractive
  11. # Prepare NodeJS
  12. RUN apt-get update -y && \
  13. apt-get install -y --no-install-recommends \
  14. ca-certificates \
  15. curl && \
  16. curl -sL https://deb.nodesource.com/setup_16.x | bash -
  17. # Prepare Yarn
  18. RUN apt-get update -y && \
  19. apt-get install -y --no-install-recommends \
  20. ca-certificates \
  21. curl && \
  22. curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
  23. echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
  24. # Install Apache, NodeJS, PHP7.4-FPM, Supervisor
  25. RUN apt-get update -y && \
  26. apt-get install -y --no-install-recommends \
  27. apache2 \
  28. apache2-doc \
  29. apache2-utils \
  30. git \
  31. libapache2-mod-fcgid \
  32. nodejs \
  33. php7.4 \
  34. php7.4-calendar \
  35. php7.4-common \
  36. php7.4-fileinfo \
  37. php7.4-ftp \
  38. php7.4-fpm \
  39. php7.4-gettext \
  40. php7.4-iconv \
  41. php7.4-json \
  42. php7.4-mbstring \
  43. php7.4-opcache \
  44. php7.4-pdo \
  45. php7.4-phar \
  46. php7.4-posix \
  47. php7.4-readline \
  48. php7.4-sockets \
  49. php7.4-sqlite3 \
  50. php7.4-tokenizer \
  51. php7.4-xml \
  52. php7.4-zip \
  53. software-properties-common \
  54. supervisor \
  55. yarn
  56. # Configure packages
  57. RUN a2enmod rewrite actions fcgid alias proxy_fcgi setenvif remoteip && \
  58. a2enconf php7.4-fpm && \
  59. bash -c 'echo "RemoteIPHeader X-Forwarded-For" >> /etc/apache2/apache2.conf' && \
  60. sed -i "s/LogFormat \"%v:%p %h/LogFormat \"%v:%p %a/g" /etc/apache2/apache2.conf && \
  61. sed -i "s/LogFormat \"%h/LogFormat \"%a/g" /etc/apache2/apache2.conf && \
  62. sed -i "s/AllowOverride None/AllowOverride All/g" /etc/apache2/apache2.conf && \
  63. mkdir -p /run/php && \
  64. mkdir -p /var/run/apache2 && \
  65. mkdir -p /var/lock/apache2 && \
  66. mkdir -p /var/log/supervisor && \
  67. chown -R www-data:www-data /var/www/html && \
  68. chown -R www-data:www-data /run/php && \
  69. rm /var/www/html/index.html
  70. # Update NPM to last version
  71. RUN npm i -g npm
  72. # Install Duckling
  73. RUN apt-get update -y && \
  74. apt-get -y install --no-install-recommends \
  75. libpcre3 \
  76. libpcre3-dev \
  77. pkg-config && \
  78. git clone https://github.com/facebook/duckling.git fb-duckling && \
  79. curl -sSL https://get.haskellstack.org/ | sh && \
  80. cd fb-duckling && \
  81. stack build
  82. # This is a laravel application, change DocRoot
  83. RUN sed -i 's/\/var\/www\/html/&\/public/g' /etc/apache2/sites-available/000-default.conf
  84. # Expose environment variables
  85. RUN sed -i 's/;clear_env = .*/clear_env = no/g' /etc/php/*/fpm/pool.d/www.conf
  86. # Install LibreOffice
  87. RUN apt-get update -y && \
  88. apt-add-repository -y ppa:libreoffice/ppa && \
  89. apt-get update -y && \
  90. apt-get install -y libreoffice
  91. # Cleanup apt cache
  92. RUN rm -rf /var/lib/apt/lists/*
  93. # Prepare Supervisor
  94. RUN mkdir /var/log/queue
  95. # Move configuraton files
  96. COPY conf/supervisord_core.conf /etc/supervisor/conf.d/supervisord.conf
  97. # Move repository
  98. COPY --chown=www-data:www-data searchanddisplace-core/ .
  99. # Here we do the magic!
  100. COPY --from=composer /usr/bin/composer /usr/local/bin/composer
  101. # Install PHP Dependencies
  102. RUN composer install --no-progress
  103. # Generate key
  104. RUN php artisan key:generate
  105. # Install JS Dependencies
  106. RUN rm -rf node_modules && \
  107. npm install && \
  108. npm run production
  109. # Migrate Database
  110. RUN touch ./database/database.sqlite && \
  111. chown www-data:www-data ./database/database.sqlite && \
  112. php artisan migrate
  113. # Expose Port for the Application
  114. EXPOSE 80 443
  115. # Copy start.sh script and define default command for the container
  116. CMD ["/usr/bin/supervisord"]