feat: init
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
FROM node:slim
|
||||
|
||||
# We don't need the standalone Chromium
|
||||
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
|
||||
|
||||
# Install Google Chrome Stable and fonts
|
||||
# Note: this installs the necessary libs to make the browser work with Puppeteer.
|
||||
RUN apt-get update && apt-get install curl gnupg -y \
|
||||
&& curl --location --silent https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
|
||||
&& sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
|
||||
&& apt-get update \
|
||||
&& apt-get install google-chrome-stable -y --no-install-recommends \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
WORKDIR /app
|
||||
COPY integration-test /app
|
||||
|
||||
RUN npm install
|
||||
|
||||
ENTRYPOINT npm run test:all
|
||||
@@ -0,0 +1,133 @@
|
||||
# MUST BE BUILT FROM .
|
||||
# docker build . -t php7.1-cassandra -f ./Dockerfile
|
||||
FROM php:7.4-fpm
|
||||
|
||||
MAINTAINER Romaric Mourgues <romaric.mourgues@twakeapp.com>
|
||||
|
||||
ARG TIMEZONE
|
||||
ARG APCU_VERSION=5.1.11
|
||||
|
||||
# Set timezone
|
||||
RUN ln -snf /usr/share/zoneinfo/${TIMEZONE} /etc/localtime
|
||||
RUN echo ${TIMEZONE} > /etc/timezone
|
||||
RUN printf '[PHP]\ndate.timezone = "%s"\n', ${TIMEZONE} > /usr/local/etc/php/conf.d/tzone.ini
|
||||
RUN "date"
|
||||
|
||||
RUN apt-get update && apt-get install -y cron
|
||||
|
||||
RUN apt-get update && apt-get install -y \
|
||||
openssl \
|
||||
git \
|
||||
unzip
|
||||
|
||||
RUN apt-get update && apt-get install -y libpng-dev
|
||||
|
||||
#MBSTRING
|
||||
RUN docker-php-ext-install mbstring
|
||||
|
||||
RUN apt-get update && apt-get install -y \
|
||||
libfreetype6-dev \
|
||||
libjpeg62-turbo-dev \
|
||||
libmcrypt-dev \
|
||||
libpng-dev \
|
||||
&& docker-php-ext-install -j$(nproc) iconv mcrypt \
|
||||
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
|
||||
&& docker-php-ext-install -j$(nproc) gd
|
||||
|
||||
#ZIP
|
||||
RUN apt-get update && apt-get install -y zlib1g-dev
|
||||
RUN docker-php-ext-install zip
|
||||
|
||||
#GD images
|
||||
RUN apt-get update && apt-get install -y \
|
||||
libfreetype6-dev \
|
||||
libjpeg62-turbo-dev \
|
||||
libpng-dev \
|
||||
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
|
||||
&& docker-php-ext-install -j$(nproc) gd
|
||||
|
||||
#ZMQ
|
||||
RUN apt-get update && apt-get install -y zlib1g-dev libzmq3-dev wget git \
|
||||
&& pecl install zmq-beta \
|
||||
&& docker-php-ext-install zip \
|
||||
&& docker-php-ext-enable zmq
|
||||
|
||||
#Imagick
|
||||
RUN apt-get update && apt-get install -y ghostscript && apt-get clean
|
||||
RUN apt-get update && apt-get install -y libmagickwand-dev --no-install-recommends && rm -rf /var/lib/apt/lists/*
|
||||
RUN pecl install imagick && docker-php-ext-enable imagick
|
||||
|
||||
#Unoconv
|
||||
RUN apt-get update && apt-get install -y --force-yes unoconv libxml2-dev
|
||||
RUN docker-php-ext-install soap
|
||||
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||
|
||||
# Install Composer
|
||||
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
|
||||
RUN composer --version
|
||||
|
||||
# Type docker-php-ext-install to see available extensions
|
||||
RUN docker-php-ext-install pdo pdo_mysql
|
||||
|
||||
ENV CASSANDRA_PHP_DRIVER_VERSION 1.3.2
|
||||
|
||||
RUN rm /var/lib/apt/lists/* -vrf && \
|
||||
apt-get clean && apt-get update
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install -y git wget libssl-dev zlib1g-dev libicu-dev g++ make cmake libuv-dev libgmp-dev uuid-dev && \
|
||||
apt-get autoclean -y && \
|
||||
apt-get clean -y
|
||||
|
||||
# Install datastax php-driver fox cassandra
|
||||
RUN git clone https://github.com/datastax/php-driver.git /usr/src/datastax-php-driver && \
|
||||
cd /usr/src/datastax-php-driver && \
|
||||
git checkout --detach v${CASSANDRA_PHP_DRIVER_VERSION} && \
|
||||
git submodule update --init && \
|
||||
cd ext && \
|
||||
./install.sh && \
|
||||
echo extension=cassandra.so > /usr/local/etc/php/conf.d/cassandra.ini
|
||||
|
||||
# Install PHP extensions
|
||||
RUN docker-php-ext-install zip mbstring intl opcache bcmath && \
|
||||
echo extension=bcmath.so > /usr/local/etc/php/conf.d/docker-php-ext-bcmath.ini && \
|
||||
apt-get install -y php5-xdebug && \
|
||||
echo zend_extension=xdebug.so > /usr/local/etc/php/conf.d/xdebug.ini && \
|
||||
pecl install apcu-5.1.5 && \
|
||||
echo extension=apcu.so > /usr/local/etc/php/conf.d/apcu.ini && \
|
||||
pecl install uuid && \
|
||||
echo extension=uuid.so > /usr/local/etc/php/conf.d/uuid.ini
|
||||
|
||||
|
||||
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
|
||||
&& php composer-setup.php && php -r "unlink('composer-setup.php');" \
|
||||
&& mv composer.phar /usr/local/bin/composer
|
||||
|
||||
## Cleanup
|
||||
RUN apt-get purge -y \
|
||||
g++ \
|
||||
git \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
#ACPU
|
||||
RUN pecl install apcu-${APCU_VERSION} && docker-php-ext-enable apcu
|
||||
RUN echo "extension=apcu.so" >> /usr/local/etc/php/php.ini
|
||||
RUN echo "apc.enable_cli=1" >> /usr/local/etc/php/php.ini
|
||||
RUN echo "apc.enable=1" >> /usr/local/etc/php/php.ini
|
||||
|
||||
RUN echo 'alias sf="php app/console"' >> ~/.bashrc
|
||||
RUN echo 'alias sf3="php bin/console"' >> ~/.bashrc
|
||||
|
||||
ADD ./uploads.ini /usr/local/etc/php/conf.d/uploads.ini
|
||||
|
||||
ADD ./www.conf /usr/local/etc/php-fpm.d/
|
||||
|
||||
#ENCRYPTION
|
||||
RUN apt-get update && apt-get install -y git
|
||||
RUN git clone https://github.com/jedisct1/libsodium --branch stable
|
||||
RUN cd libsodium && ./configure && make && make check && make install
|
||||
RUN pecl install -f libsodium
|
||||
RUN echo "extension = sodium.so" >> /usr/local/etc/php/php.ini
|
||||
|
||||
#Sockets for amqp
|
||||
RUN docker-php-ext-install sockets
|
||||
@@ -0,0 +1,5 @@
|
||||
file_uploads = On
|
||||
memory_limit = 5G
|
||||
upload_max_filesize = 5G
|
||||
post_max_size = 5G
|
||||
max_execution_time = 600
|
||||
@@ -0,0 +1,20 @@
|
||||
[www]
|
||||
|
||||
user = www-data
|
||||
group = www-data
|
||||
|
||||
listen = /run/php/php7.0-fpm.sock
|
||||
|
||||
listen.owner = www-data
|
||||
listen.group = www-data
|
||||
|
||||
; 30 childen if php is alone on 2cpu + 2go ram: --> 2go ram available - 0.5 (margin) divided by 50mo (average ram by process)
|
||||
pm = ondemand
|
||||
pm.max_children = 50
|
||||
pm.process_idle_timeout = 10s
|
||||
pm.max_requests = 100
|
||||
|
||||
catch_workers_output = yes
|
||||
php_flag[display_errors] = on
|
||||
php_admin_value[error_log] = /var/log/fpm-php.www.log
|
||||
php_admin_flag[log_errors] = on
|
||||
@@ -0,0 +1,52 @@
|
||||
|
||||
FROM debian:11
|
||||
|
||||
RUN apt-get update && apt-get -y install cron
|
||||
|
||||
RUN apt-get update && apt-get install -y \
|
||||
nginx
|
||||
|
||||
RUN apt-get update && apt-get install -y wget
|
||||
|
||||
RUN rm /etc/nginx/sites-enabled/default
|
||||
|
||||
RUN usermod -u 1000 www-data
|
||||
|
||||
RUN apt-get remove certbot
|
||||
RUN apt-get install -y python3 python3-venv libaugeas0
|
||||
RUN python3 -m venv /opt/certbot/
|
||||
RUN /opt/certbot/bin/pip install --upgrade pip
|
||||
RUN /opt/certbot/bin/pip install certbot
|
||||
RUN ln -s /opt/certbot/bin/certbot /usr/bin/certbot
|
||||
|
||||
ADD docker/twake-nginx-php-only/nginx.conf /etc/nginx/nginx.conf
|
||||
|
||||
# Install yarn
|
||||
RUN apt-get update
|
||||
RUN apt-get -y install curl
|
||||
RUN apt-get -y install apt-transport-https ca-certificates apt-utils gnupg
|
||||
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
|
||||
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
|
||||
RUN apt-get update
|
||||
RUN apt-get -y install yarn
|
||||
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash -
|
||||
RUN apt-get install -y nodejs
|
||||
RUN yarn global add webpack
|
||||
RUN yarn global add webpack-cli
|
||||
RUN apt-get update
|
||||
RUN apt-get -y install git
|
||||
|
||||
# Install php
|
||||
|
||||
ADD docker/twake-nginx/site.conf /etc/nginx/sites-available/site.template
|
||||
ADD docker/twake-nginx-php-only/nginx.conf /etc/nginx/nginx.conf
|
||||
RUN apt-get update && apt-get install gettext-base
|
||||
|
||||
RUN echo "upstream php-upstream { server php:9000; }" > /etc/nginx/conf.d/upstream.conf
|
||||
|
||||
COPY docker/twake-nginx-php-only/entrypoint.sh /
|
||||
RUN chmod 0777 /entrypoint.sh
|
||||
ENTRYPOINT /entrypoint.sh
|
||||
|
||||
EXPOSE 80
|
||||
EXPOSE 443
|
||||
@@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
NODE_HOST="${NODE_HOST:-http://node:3000}"
|
||||
PHP_UPSTREAM="${PHP_UPSTREAM:-php:9000}"
|
||||
export NODE_HOST
|
||||
export PHP_UPSTREAM
|
||||
envsubst '$${NODE_HOST}' < /etc/nginx/sites-available/site.template > /etc/nginx/sites-enabled/site
|
||||
echo "upstream php-upstream { server ${PHP_UPSTREAM}; }" > /etc/nginx/conf.d/upstream.conf
|
||||
|
||||
cron -f &
|
||||
nginx -g "daemon off;"
|
||||
@@ -0,0 +1,65 @@
|
||||
user www-data;
|
||||
worker_processes 4;
|
||||
pid /run/nginx.pid;
|
||||
|
||||
events {
|
||||
worker_connections 768;
|
||||
# multi_accept on;
|
||||
}
|
||||
|
||||
http {
|
||||
|
||||
client_max_body_size 200M;
|
||||
|
||||
##
|
||||
# Basic Settings
|
||||
##
|
||||
|
||||
sendfile on;
|
||||
tcp_nopush on;
|
||||
tcp_nodelay on;
|
||||
keepalive_timeout 65;
|
||||
types_hash_max_size 2048;
|
||||
# server_tokens off;
|
||||
|
||||
# server_names_hash_bucket_size 64;
|
||||
# server_name_in_redirect off;
|
||||
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
##
|
||||
# SSL Settings
|
||||
##
|
||||
|
||||
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
|
||||
ssl_prefer_server_ciphers on;
|
||||
|
||||
##
|
||||
# Logging Settings
|
||||
##
|
||||
|
||||
access_log /var/log/nginx/access.log;
|
||||
error_log /var/log/nginx/error.log;
|
||||
|
||||
##
|
||||
# Gzip Settings
|
||||
##
|
||||
|
||||
gzip on;
|
||||
gzip_disable "msie6";
|
||||
|
||||
# gzip_vary on;
|
||||
# gzip_proxied any;
|
||||
# gzip_comp_level 6;
|
||||
# gzip_buffers 16 8k;
|
||||
# gzip_http_version 1.1;
|
||||
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
|
||||
|
||||
##
|
||||
# Virtual Host Configs
|
||||
##
|
||||
|
||||
include /etc/nginx/conf.d/*.conf;
|
||||
include /etc/nginx/sites-enabled/*;
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
server {
|
||||
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
root /twake-core/web;
|
||||
|
||||
add_header Strict-Transport-Security "max-age=31536000";
|
||||
|
||||
location / {
|
||||
return 302 https://web.twake.app/;
|
||||
}
|
||||
|
||||
location ~ ^/(internal|plugins).* {
|
||||
proxy_pass http://node:3000;
|
||||
}
|
||||
|
||||
location ~ ^/(api|administration)/v2/.* {
|
||||
proxy_pass http://node:3000;
|
||||
}
|
||||
|
||||
location ~ ^/socket/.* {
|
||||
proxy_pass http://node:3000;
|
||||
# this magic is needed for WebSocket
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_connect_timeout 7d;
|
||||
proxy_send_timeout 7d;
|
||||
proxy_read_timeout 7d;
|
||||
}
|
||||
|
||||
location ~ ^/(ajax|api|administration|upload|bundle|medias).* {
|
||||
# try to serve file directly, fallback to rewrite
|
||||
try_files $uri @rewriteapp;
|
||||
}
|
||||
|
||||
location @rewriteapp {
|
||||
# rewrite all to app.php
|
||||
rewrite ^(.*)$ /app.php/$1 last;
|
||||
}
|
||||
|
||||
location ~ /.well-known {
|
||||
allow all;
|
||||
}
|
||||
|
||||
location ~ ^/(app|app_dev|config|dev\/.*)\.php(/|$) {
|
||||
fastcgi_pass php-upstream;
|
||||
fastcgi_split_path_info ^(.+\.php)(/.*)$;
|
||||
include fastcgi_params;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
fastcgi_param HTTPS off;
|
||||
fastcgi_buffer_size 128k;
|
||||
fastcgi_buffers 4 256k;
|
||||
fastcgi_busy_buffers_size 256k;
|
||||
}
|
||||
|
||||
location ~ /.well-known {
|
||||
allow all;
|
||||
}
|
||||
|
||||
error_log /var/log/nginx/twakeapp_dev_error.log;
|
||||
access_log /var/log/nginx/twakeapp_dev_access.log;
|
||||
|
||||
}
|
||||
Executable
+31
@@ -0,0 +1,31 @@
|
||||
# First stage: building frontend
|
||||
FROM node:lts AS build
|
||||
|
||||
RUN yarn global add webpack webpack-cli
|
||||
COPY frontend /twake-react/
|
||||
|
||||
WORKDIR /twake-react/
|
||||
|
||||
ENV GENERATE_SOURCEMAP=false
|
||||
RUN cp /twake-react/src/app/environment/environment.ts.dist /twake-react/src/app/environment/environment.ts && \
|
||||
yarn install --network-timeout 1000000000 && \
|
||||
# cat /twake-react/src/app/environment/environment.ts.dist && \
|
||||
# cat /twake-react/src/app/environment/environment.ts && \
|
||||
yarn build && \
|
||||
rm -rf node_modules
|
||||
|
||||
# Second stage: configuring nginx and copying build artifacts
|
||||
FROM nginx:latest
|
||||
COPY docker/twake-nginx/nginx.conf /etc/nginx/nginx.conf
|
||||
COPY docker/twake-nginx/site.conf /etc/nginx/sites-available/site.template
|
||||
COPY docker/twake-nginx/redirect.conf /etc/nginx/sites-available/redirect
|
||||
COPY docker/twake-nginx/entrypoint.sh /
|
||||
COPY docker/twake-nginx/self-signed.sh /usr/local/bin/
|
||||
COPY --from=build /twake-react /twake-react
|
||||
|
||||
RUN chmod +x /entrypoint.sh && rm /etc/nginx/conf.d/default.conf
|
||||
|
||||
ENTRYPOINT ["/entrypoint.sh", "$DEV"]
|
||||
|
||||
EXPOSE 80
|
||||
EXPOSE 443
|
||||
Executable
+48
@@ -0,0 +1,48 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ "$1" = "dev" ]
|
||||
then
|
||||
if test -f "/twake-react/src/app/environment/environment.ts"; then
|
||||
echo "Configuration exists, doing nothing."
|
||||
else
|
||||
cp /twake-react/src/app/environment/environment.ts.dist.dev /twake-react/src/app/environment/environment.ts
|
||||
fi
|
||||
else
|
||||
if test -f "/configuration/environment.ts"; then
|
||||
cp /configuration/environment.ts /twake-react/src/app/environment/environment.ts
|
||||
else
|
||||
cp /twake-react/src/app/environment/environment.ts.dist /twake-react/src/app/environment/environment.ts
|
||||
fi
|
||||
fi
|
||||
|
||||
[[ -d "/etc/nginx/sites-enabled" ]] || mkdir /etc/nginx/sites-enabled
|
||||
|
||||
function _selfsigned() {
|
||||
self-signed.sh
|
||||
export NGINX_LISTEN="443 ssl"
|
||||
ln -sf /etc/nginx/sites-available/redirect /etc/nginx/sites-enabled/
|
||||
}
|
||||
|
||||
case $SSL_CERTS in
|
||||
selfsigned)
|
||||
_selfsigned
|
||||
;;
|
||||
off|no|non|none|false)
|
||||
export NGINX_LISTEN="80"
|
||||
sed -i '/ *ssl_/d' /etc/nginx/sites-available/site.template
|
||||
;;
|
||||
*)
|
||||
echo: "SSL_CERTS var not defined setting selfsigned"
|
||||
export SSL_CERTS=selfsigned
|
||||
_selfsigned
|
||||
;;
|
||||
esac
|
||||
|
||||
NODE_HOST="${NODE_HOST:-http://node:3000}"
|
||||
PHP_UPSTREAM="${PHP_UPSTREAM:-php:9000}"
|
||||
export NODE_HOST
|
||||
export PHP_UPSTREAM
|
||||
envsubst '$${NODE_HOST} $${NGINX_LISTEN}' < /etc/nginx/sites-available/site.template > /etc/nginx/sites-enabled/site
|
||||
echo "upstream php-upstream { server ${PHP_UPSTREAM}; }" > /etc/nginx/conf.d/upstream.conf
|
||||
|
||||
nginx -g "daemon off;"
|
||||
@@ -0,0 +1,65 @@
|
||||
user www-data;
|
||||
worker_processes 4;
|
||||
pid /run/nginx.pid;
|
||||
|
||||
events {
|
||||
worker_connections 768;
|
||||
# multi_accept on;
|
||||
}
|
||||
|
||||
http {
|
||||
|
||||
client_max_body_size 200M;
|
||||
|
||||
##
|
||||
# Basic Settings
|
||||
##
|
||||
|
||||
sendfile on;
|
||||
tcp_nopush on;
|
||||
tcp_nodelay on;
|
||||
keepalive_timeout 65;
|
||||
types_hash_max_size 2048;
|
||||
# server_tokens off;
|
||||
|
||||
# server_names_hash_bucket_size 64;
|
||||
# server_name_in_redirect off;
|
||||
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
##
|
||||
# SSL Settings
|
||||
##
|
||||
|
||||
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
|
||||
ssl_prefer_server_ciphers on;
|
||||
|
||||
##
|
||||
# Logging Settings
|
||||
##
|
||||
|
||||
access_log /var/log/nginx/access.log;
|
||||
error_log /var/log/nginx/error.log;
|
||||
|
||||
##
|
||||
# Gzip Settings
|
||||
##
|
||||
|
||||
gzip on;
|
||||
gzip_disable "msie6";
|
||||
|
||||
# gzip_vary on;
|
||||
# gzip_proxied any;
|
||||
# gzip_comp_level 6;
|
||||
# gzip_buffers 16 8k;
|
||||
# gzip_http_version 1.1;
|
||||
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
|
||||
|
||||
##
|
||||
# Virtual Host Configs
|
||||
##
|
||||
|
||||
include /etc/nginx/conf.d/*.conf;
|
||||
include /etc/nginx/sites-enabled/*;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
location / {
|
||||
return 302 https://$server_name$request_uri;
|
||||
}
|
||||
}
|
||||
Executable
+52
@@ -0,0 +1,52 @@
|
||||
#!/bin/bash
|
||||
# Script to create selfsigned certificates if they don't exist. All certificate
|
||||
# information can be customized using env variables.
|
||||
# Licence: GPL
|
||||
# Note: derivated from https://gitlab.com/live9/docker/containers/openssl/-/blob/master/entrypoint
|
||||
#
|
||||
set -eo pipefail
|
||||
[ "${DEBUG}" = "yes" ] && set -x
|
||||
|
||||
SSL_PATH="/etc/nginx/ssl/"
|
||||
SSL_KEY="${SSL_PATH}/selfsigned.key"
|
||||
SSL_CERT_REQUEST="${SSL_PATH}/selfsigned.csr"
|
||||
SSL_CERTIFICATE="${SSL_PATH}/selfsigned.crt"
|
||||
SSL_DHPARAM_FILE="${SSL_PATH}/dhparam.pem"
|
||||
|
||||
# Certificate creation params
|
||||
SSL_VALID_DAYS="${SSL_VALID_DAYS:-365}"
|
||||
SSL_SUBJ_COUNTRY="${SSL_SUBJ_COUNTRY:-FR}"
|
||||
SSL_SUBJ_STATE="${SSL_SUBJ_STATE:-Hauts-de-France}"
|
||||
SSL_SUBJ_LOCALITY="${SSL_SUBJ_LOCALITY:-Paris}"
|
||||
SSL_SUBJ_ORG="${SSL_SUBJ_ORG:-Linagora}"
|
||||
SSL_SUBJ_ORG_UNIT="${SSL_SUBJ_ORG_UNIT:- Twake}"
|
||||
SSL_SUBJ_CN="${SSL_SUBJ_CN:-localhost}"
|
||||
SSL_SUBJECT="/C=${SSL_SUBJ_COUNTRY}/ST=${SSL_SUBJ_STATE}/L=${SSL_SUBJ_LOCALITY}/O=${SSL_SUBJ_ORG}/OU=${SSL_SUBJ_ORG_UNIT}/CN=${SSL_SUBJ_CN}"
|
||||
SSL_KEY_LENGTH=${SSL_KEY_LENGTH:-2048}
|
||||
|
||||
|
||||
if [ ! -f ${SSL_CERTIFICATE} ]; then
|
||||
echo "Creating certificate sigining request..."
|
||||
mkdir -p ${SSL_PATH}
|
||||
openssl req \
|
||||
-newkey rsa:${SSL_KEY_LENGTH} \
|
||||
-sha256 \
|
||||
-nodes \
|
||||
-keyout ${SSL_KEY} \
|
||||
-out ${SSL_CERT_REQUEST} \
|
||||
-subj "${SSL_SUBJECT}"
|
||||
echo "Creating self-signed certificate..."
|
||||
openssl x509 -req -days ${SSL_VALID_DAYS} \
|
||||
-in ${SSL_CERT_REQUEST} \
|
||||
-signkey ${SSL_KEY} \
|
||||
-out ${SSL_CERTIFICATE}
|
||||
|
||||
echo "Creating dhparam file..."
|
||||
# When SSL_DHPARAM_FILE is present the whole process is done
|
||||
openssl dhparam -out ${SSL_DHPARAM_FILE}.tmp ${SSL_KEY_LENGTH}
|
||||
mv ${SSL_DHPARAM_FILE}.tmp ${SSL_DHPARAM_FILE}
|
||||
|
||||
echo "Done."
|
||||
else
|
||||
echo "Selfsigned certificate already exists, skipping."
|
||||
fi
|
||||
@@ -0,0 +1,111 @@
|
||||
server {
|
||||
listen ${NGINX_LISTEN};
|
||||
ssl_dhparam /etc/nginx/ssl/dhparam.pem;
|
||||
ssl_certificate /etc/nginx/ssl/selfsigned.crt;
|
||||
ssl_certificate_key /etc/nginx/ssl/selfsigned.key;
|
||||
|
||||
server_name localhost;
|
||||
root /twake-core/web;
|
||||
|
||||
add_header Strict-Transport-Security "max-age=31536000";
|
||||
|
||||
location /.well-known {
|
||||
alias /twake-react/build/.well-known/;
|
||||
|
||||
gzip on;
|
||||
gzip_disable "msie6";
|
||||
|
||||
add_header Cache-Control "no-store, public, max-age=0";
|
||||
add_header Cross-Origin-Opener-Policy 'same-origin-allow-popups; report-to="DurableDeepLinkUi"';
|
||||
add_header Cross-Origin-Resource-Policy "same-site";
|
||||
add_header Content-Type "application/json; charset=utf-8";
|
||||
add_header Last-Modified "";
|
||||
add_header Vary "Sec-Fetch-Dest, Sec-Fetch-Mode, Sec-Fetch-Site";
|
||||
add_header X-Content-Type-Options "nosniff";
|
||||
add_header X-Frame-Options "SAMEORIGIN";
|
||||
add_header X-XSS-Protection "0";
|
||||
|
||||
proxy_buffering off;
|
||||
if_modified_since off;
|
||||
expires 0s;
|
||||
allow all;
|
||||
|
||||
try_files $uri /index.html;
|
||||
}
|
||||
|
||||
location / {
|
||||
gzip on;
|
||||
gzip_disable "msie6";
|
||||
|
||||
gzip_comp_level 6;
|
||||
gzip_min_length 1100;
|
||||
gzip_buffers 16 8k;
|
||||
gzip_proxied any;
|
||||
gzip_types
|
||||
text/plain
|
||||
text/css
|
||||
text/js
|
||||
text/xml
|
||||
text/javascript
|
||||
application/javascript
|
||||
application/x-javascript
|
||||
application/json
|
||||
application/xml
|
||||
application/rss+xml
|
||||
image/svg+xml;
|
||||
alias /twake-react/build/;
|
||||
allow all;
|
||||
try_files $uri /index.html;
|
||||
}
|
||||
|
||||
location ~ ^/(internal).* {
|
||||
proxy_set_header X-Forwarded-Host $host;
|
||||
proxy_pass ${NODE_HOST};
|
||||
}
|
||||
|
||||
location ~ ^/(plugins).* {
|
||||
set $target http://plugins_container:8080;
|
||||
proxy_set_header X-Forwarded-Host $host;
|
||||
proxy_pass $target;
|
||||
}
|
||||
|
||||
location ~ ^/(api|administration/v2/).* {
|
||||
proxy_set_header X-Forwarded-Host $host;
|
||||
proxy_pass ${NODE_HOST};
|
||||
}
|
||||
|
||||
location ~ ^/socket/.* {
|
||||
proxy_pass ${NODE_HOST};
|
||||
# this magic is needed for WebSocket
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_connect_timeout 7d;
|
||||
proxy_send_timeout 7d;
|
||||
proxy_read_timeout 7d;
|
||||
}
|
||||
|
||||
location ~ ^/(ajax|api|administration|upload|bundle|medias).* {
|
||||
# try to serve file directly, fallback to rewrite
|
||||
try_files $uri @rewriteapp;
|
||||
}
|
||||
|
||||
location @rewriteapp {
|
||||
# rewrite all to app.php
|
||||
rewrite ^(.*)$ /app.php/$1 last;
|
||||
}
|
||||
|
||||
location ~ ^/(app|app_dev|config|dev\/.*)\.php(/|$) {
|
||||
fastcgi_pass php-upstream;
|
||||
fastcgi_split_path_info ^(.+\.php)(/.*)$;
|
||||
include fastcgi_params;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
fastcgi_param HTTPS off;
|
||||
fastcgi_buffer_size 128k;
|
||||
fastcgi_buffers 4 256k;
|
||||
fastcgi_busy_buffers_size 256k;
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+66
@@ -0,0 +1,66 @@
|
||||
# Common node machine
|
||||
FROM node:lts as node-base
|
||||
|
||||
### Install dependancies
|
||||
RUN apt-get update && \
|
||||
apt-get install -y ghostscript graphicsmagick wget unoconv libxml2-dev ffmpeg python-is-python3 && \
|
||||
# upgrade unoconv
|
||||
wget -N https://raw.githubusercontent.com/dagwieers/unoconv/master/unoconv -O /usr/bin/unoconv && \
|
||||
chmod +x /usr/bin/unoconv
|
||||
#Docker mac issue
|
||||
# RUN apt-get update && apt-get install -y libc6
|
||||
# RUN ln -s /lib/libc.musl-x86_64.so.1 /lib/ld-linux-x86-64.so.2
|
||||
|
||||
|
||||
### Install Twake
|
||||
|
||||
WORKDIR /usr/src/app
|
||||
COPY backend/node/package*.json ./
|
||||
|
||||
# Test Stage
|
||||
FROM node-base as test
|
||||
|
||||
RUN npm install
|
||||
COPY backend/node/ .
|
||||
|
||||
# Add frontend Stage
|
||||
FROM node-base as with-frontend
|
||||
|
||||
COPY backend/node/ .
|
||||
#Install dev dependancies for build
|
||||
RUN NODE_ENV=development npm install && \
|
||||
#Build in production mode
|
||||
export NODE_ENV=production && \
|
||||
npm run build && \
|
||||
rm -rf node_modules && \
|
||||
#Install prod dependancies after build
|
||||
npm install --legacy-peer-deps
|
||||
|
||||
# Add frontend into node
|
||||
COPY frontend/ ../public_build/
|
||||
RUN export NODE_ENV=development && \
|
||||
apt-get install -y build-essential && \
|
||||
cd ../public_build/ && \
|
||||
yarn install --network-timeout 1000000000 && \
|
||||
yarn global add webpack webpack-cli jest && \
|
||||
cp src/app/environment/environment.ts.dist src/app/environment/environment.ts && \
|
||||
export NODE_ENV=production && \
|
||||
yarn build && \
|
||||
rm -R node_modules && \
|
||||
mv build/* ../app/public && \
|
||||
cd .. && rm -R public_build/
|
||||
|
||||
# Development Stage
|
||||
FROM with-frontend as development
|
||||
|
||||
ENV NODE_ENV=development
|
||||
RUN npm install -g pino-pretty && \
|
||||
npm install -g tsc-watch && \
|
||||
yarn install
|
||||
CMD ["npm", "run", "dev:debug"]
|
||||
|
||||
# Production Stage
|
||||
FROM with-frontend as production
|
||||
|
||||
EXPOSE 3000
|
||||
CMD ["npm", "run", "serve"]
|
||||
Executable
+18
@@ -0,0 +1,18 @@
|
||||
FROM twaketech/php7.1-cassandra
|
||||
|
||||
LABEL org.opencontainers.image.authors="Romaric Mourgues <romaric.mourgues@twakeapp.com>,Nguyen Thai <tknguyen@linagora.com>"
|
||||
|
||||
#Crontab
|
||||
ADD docker/twake-php/crontab /etc/cron.d/twake-cron
|
||||
COPY backend/core/ /twake-core/
|
||||
COPY docker/twake-php/entrypoint.sh /
|
||||
|
||||
RUN chmod 0644 /etc/cron.d/twake-cron && \
|
||||
touch /var/log/cron.log && \
|
||||
cd /twake-core/ && php composer.phar install && \
|
||||
chmod +x /entrypoint.sh
|
||||
|
||||
#For exec
|
||||
WORKDIR /twake-core/
|
||||
|
||||
ENTRYPOINT ["/entrypoint.sh", "$DEV"]
|
||||
@@ -0,0 +1,30 @@
|
||||
# /etc/crontab: system-wide crontab
|
||||
# Unlike any other crontab you don't have to run the `crontab'
|
||||
# command to install the new version when you edit this file
|
||||
# and files in /etc/cron.d. These files also have username fields,
|
||||
# that none of the other crontabs do.
|
||||
|
||||
SHELL=/bin/sh
|
||||
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
||||
|
||||
# m h dom mon dow user command
|
||||
* * * * * root cd /twake-core/; php bin/console twake:mails_queue;
|
||||
* * * * * root cd /twake-core/; php bin/console twake:node:push_mobile;
|
||||
* * * * * root cd /twake-core/; php bin/console twake:node:push_channel_activity;
|
||||
|
||||
* * * * * root cd /twake-core/; php bin/console twake:calendar_check;
|
||||
* * * * * root cd /twake-core/; php bin/console twake:tasks_check_reminders;
|
||||
|
||||
* * * * * root cd /twake-core/; php bin/console twake:notifications_mail;
|
||||
|
||||
* * * * * root cd /twake-core/; php bin/console twake:preview_worker;
|
||||
|
||||
* * * * * root cd /twake-core/; php bin/console twake:scheduled_notifications_consume_timetable
|
||||
* * * * * root cd /twake-core/; php bin/console twake:scheduled_notifications_consume_shard
|
||||
|
||||
* * * * * root chmod -R 777 /twake-core/cache;
|
||||
|
||||
32 * * * * root kill -USR2 1;
|
||||
#
|
||||
#
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ -z "$TIMEZONE" ]; then
|
||||
TIMEZONE=Etc/UTC
|
||||
fi
|
||||
|
||||
echo $TIMEZONE > /etc/timezone && \
|
||||
dpkg-reconfigure -f noninteractive tzdata
|
||||
|
||||
sed -i "s|;date.timezone =.*|date.timezone = $TIMEZONE|" /etc/php5/*/php.ini
|
||||
|
||||
if [ -n "$PHP_MEMORY_LIMIT" ]; then
|
||||
sed -i "s/^memory_limit =.*/memory_limit = $PHP_MEMORY_LIMIT/" /etc/php5/*/php.ini
|
||||
fi
|
||||
|
||||
chmod -R 777 /var/www &
|
||||
chmod -R 777 /tmp/
|
||||
rm -R /tmp/*
|
||||
chmod -R 777 /twake-core/ &
|
||||
mkdir /twake-core/cache
|
||||
chmod -R 777 /twake-core/cache &
|
||||
|
||||
if [ "$1" = "dev" ]
|
||||
then
|
||||
if test -f "/twake-core/app/Configuration/Parameters.php"; then
|
||||
echo "Configuration exists, doing nothing."
|
||||
else
|
||||
cp /twake-core/app/Configuration/Parameters.php.dist /twake-core/app/Configuration/Parameters.php
|
||||
fi
|
||||
|
||||
php composer.phar install
|
||||
else
|
||||
if test -f "/configuration/Parameters.php"; then
|
||||
cp /configuration/Parameters.php /twake-core/app/Configuration/Parameters.php
|
||||
else
|
||||
cp /twake-core/app/Configuration/Parameters.php.dist /twake-core/app/Configuration/Parameters.php
|
||||
fi
|
||||
fi
|
||||
|
||||
(php composer.phar dump-autoload --optimize; php composer.phar dump-autoload --classmap-authoritative; php composer.phar dump-autoload --apcu; php bin/console twake:schema:update; php bin/console twake:init; php bin/console twake:init_connector; php bin/console twake:mapping) &
|
||||
|
||||
mkdir /twake-core/cache
|
||||
chmod -R 777 /twake-core/cache &
|
||||
|
||||
echo "" >> /etc/cron.d/twake-cron
|
||||
|
||||
cron -f &
|
||||
docker-php-entrypoint php-fpm
|
||||
@@ -0,0 +1,26 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
|
||||
|
||||
FROM docker:20.10.17-dind-alpine3.16
|
||||
|
||||
|
||||
RUN apk add --update nodejs-current npm bash curl
|
||||
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
COPY plugins/ .
|
||||
|
||||
VOLUME /usr/src/app
|
||||
RUN chmod -R +x scripts
|
||||
RUN mv scripts/* /bin
|
||||
RUN apk update
|
||||
RUN apk add git
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user