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.

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