From 57adc919484e46c66e35bf9dd75810b9e0f4701b Mon Sep 17 00:00:00 2001 From: G Balraj Date: Wed, 20 Mar 2019 18:47:01 +0530 Subject: [PATCH] Fixes #2503: Intergration of restyaboard installation using Plateform.sh is added. --- .platform.app.yaml | 101 ++++++++++++++++++++++++++++ .platform/routes.yaml | 11 +++ .platform/services.yaml | 8 +++ client/img/default-admin-user.png | Bin 0 -> 4750 bytes server/php/config.inc.php | 26 +++++-- server/php/image.php | 9 ++- server/php/platformsh_install.php | 23 +++++++ sql/restyaboard_with_empty_data.sql | 2 +- 8 files changed, 171 insertions(+), 9 deletions(-) create mode 100644 .platform.app.yaml create mode 100644 .platform/routes.yaml create mode 100644 .platform/services.yaml create mode 100755 client/img/default-admin-user.png create mode 100644 server/php/platformsh_install.php diff --git a/.platform.app.yaml b/.platform.app.yaml new file mode 100644 index 000000000..ef147c1c2 --- /dev/null +++ b/.platform.app.yaml @@ -0,0 +1,101 @@ +# This file describes an application. You can have multiple applications +# in the same project. + +# The name of this app. Must be unique within a project. +name: restyaboard + +# The runtime the application uses. +type: 'php:7.2' + +# The relationships of the application with services or other applications. +# The left-hand side is the name of the relationship as it will be exposed +# to the application in the PLATFORM_RELATIONSHIPS variable. The right-hand +# side is in the form `:`. +relationships: + database: 'pgsql96:postgresql' + # platform sql -p 52l75zyfpy2t6 --relationship database < sql/restyaboard_with_empty_data.sql + +variables: + php: + # Turn display errors off when you're ready to launch. + display_errors: On + upload_max_filesize: 50M + post_max_size: 50M + max_execution_time: 200 + max_input_time: 200 + memory_limit: 256M + +# The configuration of app when it is exposed to the web. +web: + locations: + '/': + # The public directory of the app, relative to its root. + root: '' + # The front-controller script to send non-static requests to. + passthru: '/client/index.html' + allow: true + rules: + ^/client/img/([a-zA-Z_]*)/([a-zA-Z_]*)/([a-zA-Z0-9_\.]*)$: + passthru: '/server/php/image.php?size=$1&model=$2&filename=$3' + ^/ical/([0-9]*)/([0-9]*)/([a-zA-Z0-9]*).ics$: + passthru: '/server/php/ical.php?id=$1&user_id=$2&hash=$2' + ^/download/([0-9]*)/([a-zA-Z0-9_\.]*)$: + passthru: '/server/php/download.php?id=$1&hash=$2' + ^/oauth_callback/([a-zA-Z0-9_\.]*)/([a-zA-Z0-9_\.]*)$: + passthru: '/server/php/oauth_callback.php?plugin=$1&code=$2' + ^/oauth/authorize$: + passthru: '/server/php/authorize.php' + ^/api/(.*)$: + passthru: '/server/php/R/r.php?_url=$1' + ^/(css|js|img|font|apps|locales)/(.*)$: + passthru: '/client/$1/$2' + ^/favicon.ico$: + passthru: '/client/favicon.ico' + ^/manifest.json$: + passthru: '/client/manifest.json' + ^/apple-touch-icon(.*)$: + passthru: '/client/apple-touch-icon$1' + +runtime: + extensions: + - pgsql + - pdo_pgsql + - curl + - gd + - imap + - json + - ldap + - mbstring + +# The size of the persistent disk of the application (in MB). +disk: 2048 + + +# The mounts that will be performed when the package is deployed. +mounts: + '/client/img/micro_thumb': 'shared:files/client/img/micro_thumb' + '/client/img/small_thumb': 'shared:files/client/img/small_thumb' + '/client/img/normal_thumb': 'shared:files/client/img/normal_thumb' + '/client/img/medium_thumb': 'shared:files/client/img/medium_thumb' + '/client/img/large_thumb': 'shared:files/client/img/large_thumb' + '/client/img/extra_large_thumb': 'shared:files/client/img/extra_large_thumb' + '/client/img/original': 'shared:files/client/img/original' + '/tmp': 'shared:files/tmp' + '/tmp/cache': 'shared:files/tmp/cache' + '/media': 'shared:files/media' + +# Restyaboard crons +crons: + main: + spec: '*/5 * * * *' + cmd: 'cd server/php/shell; ./main.sh' + +# Deploy hook, access to services & done once (per cluster, not per node), only mounts are writable at this point +# Note: Http traffic is paused while this is running, so for prod code this should finish as fast as possible, < 30s +hooks: + deploy: | + set -e + # Mainly relevant for eZ Platform demo usage, for own setup adapt this or remove and rely on migrations. + if [ ! -f /tmp/.sql.installed ]; then + php server/php/platformsh_install.php + fi \ No newline at end of file diff --git a/.platform/routes.yaml b/.platform/routes.yaml new file mode 100644 index 000000000..3011a1e59 --- /dev/null +++ b/.platform/routes.yaml @@ -0,0 +1,11 @@ +# The routes of the project. +# +# Each route describes how an incoming URL is going +# to be processed by Platform.sh. + +"http://{default}/": + type: upstream + upstream: "restyaboard:http" +"http://www.{default}/": + type: redirect + to: "https://{default}/" \ No newline at end of file diff --git a/.platform/services.yaml b/.platform/services.yaml new file mode 100644 index 000000000..ec865aee6 --- /dev/null +++ b/.platform/services.yaml @@ -0,0 +1,8 @@ +# The services of the project. +# +# Each service listed will be deployed +# to power your Platform.sh project. + +pgsql96: + type: postgresql:9.6 + disk: 2048 diff --git a/client/img/default-admin-user.png b/client/img/default-admin-user.png new file mode 100755 index 0000000000000000000000000000000000000000..e3a72b00e21de26eee3531bfce9a0335ab2702e7 GIT binary patch literal 4750 zcmaJ_c{r5q+a6>oYhseZ7>w+OF`5ZuXKYh;qA)XdW{iokC0k0#n#jJDvW3c0q9~^9 z*@uaw z)884tA2vn+fT0zE3ZV~9k@alJ76eyvpfd>%(83X1@F290vm4$V?~DubqvF*704A`9 zr7hXk)C7qo_{cl|#>i8Ah;%jppoXFlov~hcGROt*=HaUjUU}IB26^Dr!8R(Uil#&z zyt{{CFbQuFY-WiK_QE1?V3Y<(je?{L_~6OTAc~K-uRoHa4*p9QNwnZ(sD0I@p~|CL$FS0s{l(1C`|oBsT>p0)hCgp`;{7N67gH`I4O}a=!jz ze-w1_{#cR+k?cY61^rfZb|G9PtApv0{$~k3#D8Rc{r^rAJz)wIXQBdBUh(&m{s2u) z|9_~D&p&8?vN`_0@&2E}{+2;Ryn;F2pKz6gr5Das?6)f-Qip_hCKE`O1cLXUEM9OY zkO}_o1R_Ys0uDNBSCGr=mi)|8R8)*sDHxU-BO=?!R34zjA-Kf)A1ISr_{m)`9p zdRtG5+Vlee+>B^lElbL%%RY^UVyeG>D}u3^G5>X1aZ*wIOD|wCTzN|Ao`4oaElyyE zSs+Gtb;0e;jKt`TtrFK`Dzu4O&ij2$s`4j#_PyFz93F&sWSR_*G@Gn#cX8s9!n<>w zIuX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)9#Wg~?8 zcMclq2P;k{jx7$AA#32 z{B{q3V^i3!w^45#C6F$s@-kNYvs{+LaI@94vB-j9pA2vNuLZuR^G=9dXI<@QUqbY##8?Cr#r)Is$iBiFQVPho_~TQ|6GU$MJ9602k! zY|5CD<(aA%$zQdUM#kAyk5zNrbEsalbFYrhPBt5NI-54zX9$s!$P!toafl_!>d5Fk z4wMSoksekUs!#bXew7c^C%kjfOgqw&*WQ5ay;g2?)zxT>bd(LoVKopjvpH>|D_;5Fc?DdvS_VXlAW0()Cj?MF2uVmx7O0P0XhrF%Bv{TcbZqk}v>@{06)?Qx3M_1ud&#th`Uh`jfYLZb_`JFO%dY7In!1~`r)ir*~ zHnrGsHJJ)!vbk*ZGb_!2{YKBLUmr*mp4#%W!_Q1S=cHraPQ@SZ&X5+811U#e6NlwS zwe|1sRlLmDQ-x+);4lw~Z~R}zJY-p&MokZV49>c!9Ie4z5xDv@{dfcJd-=KZ{PlO@ z;zSFvhL?_bC>?iY*XpfaW(KUi@lTG8^#^+3*fzF}R1Gu<+ya7{*s4g;3rVm5i!)xl zM`w '202x151' ) ); -$aspect['CardAttachment']['large_thumb'] = 1; +$aspect['CardAttachment']['large_thumb'] = 1; \ No newline at end of file diff --git a/server/php/image.php b/server/php/image.php index a27a206c0..ee6456b2e 100644 --- a/server/php/image.php +++ b/server/php/image.php @@ -66,7 +66,12 @@ function preserveImageTransparency($fileExt, $sourceImg, &$targetImg) $row = pg_fetch_assoc($s_result); $fullPath = $row['path']; } - $fullPath = MEDIA_PATH . DS . $fullPath; + //Todo default image + if(explode('/',$fullPath)[0] == 'client' && explode('/',$fullPath)[1] == 'img'){ + $fullPath = APP_PATH. DS .$fullPath; + }else{ + $fullPath = MEDIA_PATH . DS . $fullPath; + } $is_aspect = false; if (!empty($aspect[$model][$size])) { $is_aspect = true; @@ -185,4 +190,4 @@ function preserveImageTransparency($fileExt, $sourceImg, &$targetImg) header('Location:' . $_SERVER['REQUEST_URI'] . '?chrome-3xx-fix'); } else { header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found', true, 404); -} +} \ No newline at end of file diff --git a/server/php/platformsh_install.php b/server/php/platformsh_install.php new file mode 100644 index 000000000..b42494bc9 --- /dev/null +++ b/server/php/platformsh_install.php @@ -0,0 +1,23 @@ + /tmp/.sql.installed'); +exec('mkdir -p /tmp/pgpass'); +exec('chmod -R go-rwx /tmp/pgpass'); +$relationships = json_decode(base64_decode(getenv('PLATFORM_RELATIONSHIPS')), true); +if (!empty($relationships['database'])) { + foreach ($relationships['database'] as $endpoint) { + define('R_DB_HOST', $endpoint['host']); + define('R_DB_USER', $endpoint['username']); + define('R_DB_PASSWORD', $endpoint['password']); + define('R_DB_NAME', $endpoint['path']); + define('R_DB_PORT', $endpoint['port']); + break; + } + } + +exec('echo "'.R_DB_HOST.':'.R_DB_PORT.':'.R_DB_NAME.':'.R_DB_USER.':'.R_DB_PASSWORD.'" > /tmp/pgpass/.pgpass'); +exec('chmod 0600 /tmp/pgpass/.pgpass'); +putenv('PGPASSFILE=/tmp/pgpass/.pgpass'); +exec('psql --host='.R_DB_HOST. ' --port='.R_DB_PORT.' --dbname='.R_DB_NAME.' --username='.R_DB_USER.' --no-password --file=' . $current_dir . '/../../sql/restyaboard_with_empty_data.sql'); +exec('rm -rf /tmp/pgpass'); \ No newline at end of file diff --git a/sql/restyaboard_with_empty_data.sql b/sql/restyaboard_with_empty_data.sql index 1732000f4..8bb27f7a6 100644 --- a/sql/restyaboard_with_empty_data.sql +++ b/sql/restyaboard_with_empty_data.sql @@ -5472,7 +5472,7 @@ COPY public.user_logins (id, created, modified, user_id, ip_id, user_agent, is_l -- COPY public.users (id, created, modified, role_id, username, email, password, full_name, initials, about_me, profile_picture_path, notification_frequency, is_allow_desktop_notification, is_active, is_email_confirmed, created_organization_count, created_board_count, joined_organization_count, list_count, joined_card_count, created_card_count, joined_board_count, checklist_count, checklist_item_completed_count, checklist_item_count, activity_count, card_voter_count, last_activity_id, last_login_date, last_login_ip_id, ip_id, login_type_id, is_productivity_beats, user_login_count, is_ldap, is_send_newsletter, last_email_notified_activity_id, owner_board_count, member_board_count, owner_organization_count, member_organization_count, language, timezone, default_desktop_notification, is_list_notifications_enabled, is_card_notifications_enabled, is_card_members_notifications_enabled, is_card_labels_notifications_enabled, is_card_checklists_notifications_enabled, is_card_attachments_notifications_enabled, is_intro_video_skipped, is_invite_from_board, is_two_factor_authentication_enabled, two_factor_authentication_hash) FROM stdin; -1 2014-06-03 12:40:41.189 2015-04-02 16:26:03.939 1 admin board@restya.com $2y$12$QiJW6TjPKzDZPAuoWEex9OjPHQF33YzfkdC09FhasgPO.MjZ5btKe New Admin PA Added About Me media/User/1/default-admin-user.png \N f t t 0 0 0 0 0 0 0 0 0 0 0 0 2 2015-06-06 10:53:34.46 1 \N 2 t 2 f 2 0 0 0 0 0 \N Europe/Andorra t t t t t t t f f f \N +1 2014-06-03 12:40:41.189 2015-04-02 16:26:03.939 1 admin board@restya.com $2y$12$QiJW6TjPKzDZPAuoWEex9OjPHQF33YzfkdC09FhasgPO.MjZ5btKe New Admin PA Added About Me client/img/default-admin-user.png \N f t t 0 0 0 0 0 0 0 0 0 0 0 0 2 2015-06-06 10:53:34.46 1 \N 2 t 2 f 2 0 0 0 0 0 \N Europe/Andorra t t t t t t t f f f \N 2 2014-07-05 11:46:40.804 2014-07-05 11:46:40.804 2 user board+user@restya.com $2y$12$QiJW6TjPKzDZPAuoWEex9OjPHQF33YzfkdC09FhasgPO.MjZ5btKe User U \N \N \N f t t 0 0 0 0 0 0 0 0 0 0 0 0 0 2018-10-29 18:23:04.746305 2 \N 2 f 1 f 0 0 0 0 0 0 \N Asia/Calcutta f f f f f f f f f f \N \.