Merge branch '3-bitrix-volume' into 'master'

Resolve "Вынести ядро битрикс в отдельный volume"

Closes #3

See merge request !1
parents dec8c630 d37bc069
Pipeline #673 failed with stages
in 40 seconds
VIRTUAL_HOST=DEV-%PROJECT_NUM%.zolotoykod.ru VIRTUAL_HOST=staging.1.dev.1119.zolotoykod.ru
HTTP_PORT=8080 BITRIX_PORT=8081
SITE_PORT=8080
{
"extends": "google",
"env": {
"browser": true,
"node": true,
"es6": true
},
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
"globalReturn": true,
"impliedStrict": true,
"experimentalObjectRestSpread": true
}
},
"rules": {
"no-multiple-empty-lines": ["error", {"max": 2}],
"curly": ["error", "multi"],
"quotes": ["error", "single"],
"arrow-parens": ["error", "always"]
}
}
stages:
- startup
- build
- deploy
variables:
BUILD_PATH: "www/dist"
status:
stage: startup
script:
- git status
variables:
GIT_STRATEGY: none
only:
- master
docker:
stage: startup
script:
- /bin/bash start.sh
only:
- master
staging:
stage: build
script:
- docker-compose exec -T bitrix /bin/bash /link_bx.sh /home/bitrix/site
- docker-compose exec -T bitrix /bin/bash /build.sh
cache:
paths:
- www/node_modules/
- www/vendor/
environment:
name: staging
url: http://staging.1.dev.1119.zolotoykod.ru
artifacts:
paths:
- $BUILD_PATH
expire_in: 1 day
only:
- master
production:
stage: deploy
script:
- export
- echo 'Deploy to production soon'
variables:
GIT_STRATEGY: none
environment:
name: production
url: http://production.1.dev.1119.zolotoykod.ru
only:
- tags
#!/bin/bash
export ARTIFACTS_PATH="$HOME/localartifacts/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME/$CI_PIPELINE_ID/"
mkdir -p $ARTIFACTS_PATH
tar -czf bitrix.tar.gz www/bitrix/ www/upload/
mv bitrix.tar.gz $ARTIFACTS_PATH
...@@ -2,23 +2,37 @@ version: '2' ...@@ -2,23 +2,37 @@ version: '2'
services: services:
bitrix: bitrix:
image: zolotoykod/bitrix:latest image: zolotoykod/bitrix:latest
user: bitrix
working_dir: /home/bitrix/www
command: sudo /run.sh
volumes: volumes:
- ./www:/home/bitrix/www:Z - bitrix:/home/bitrix/www/bitrix:Z
- upload:/home/bitrix/www/upload:Z
- data:/var/lib/mysql:Z - data:/var/lib/mysql:Z
- ./docker/zk-entrypoint.sh:/zk-entrypoint.sh:Z
- ./docker/link_bx.sh:/link_bx.sh:Z
- ./docker/build.sh:/build.sh:Z
- ./www:/home/bitrix/site:Z
- ./docker/apache/bitrix.conf:/etc/httpd/bx/conf/default.conf:Z
- ./docker/nginx/bitrix.conf:/etc/nginx/bx/site_avaliable/s1.conf:Z
- ./docker/apache/site.conf:/etc/httpd/bx/conf/site.conf:Z
- ./docker/nginx/site.conf:/etc/nginx/bx/site_enabled/site.conf:Z
ports: ports:
- "${HTTP_PORT}:80" - "${BITRIX_PORT}:8080"
- "${SITE_PORT}:80"
- "22" - "22"
environment: environment:
- HOME=/home/bitrix - HOME=/home/bitrix
- VIRTUAL_HOST - VIRTUAL_HOST
dns: command: /bin/bash /zk-entrypoint.sh
- 8.8.8.8 working_dir: /home/bitrix
- 8.8.4.4
tty: true tty: true
volumes: volumes:
data: data:
driver: local driver: local
bitrix:
driver: local
upload:
driver: local
Listen 127.0.0.1:8888
<VirtualHost 127.0.0.1:8888>
DocumentRoot /home/bitrix/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<DirectoryMatch .*\.svn/.*>
Deny From All
</DirectoryMatch>
<DirectoryMatch .*\.git/.*>
Deny From All
</DirectoryMatch>
<DirectoryMatch .*\.hg/.*>
Deny From All
</DirectoryMatch>
<Directory /home/bitrix/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
DirectoryIndex index.php index.html index.htm
Order allow,deny
allow from all
php_admin_value session.save_path /tmp/php_sessions/www
php_admin_value upload_tmp_dir /tmp/php_upload/www
</Directory>
<Directory /home/bitrix/www/bitrix/cache>
AllowOverride none
Order allow,deny
Deny from all
</Directory>
<Directory /home/bitrix/www/bitrix/managed_cache>
AllowOverride none
Order allow,deny
Deny from all
</Directory>
<Directory /home/bitrix/www/bitrix/local_cache>
AllowOverride none
Order allow,deny
Deny from all
</Directory>
<Directory /home/bitrix/www/bitrix/stack_cache>
AllowOverride none
Order allow,deny
Deny from all
</Directory>
<Directory /home/bitrix/www/upload>
AllowOverride none
AddType text/plain php,php3,php4,php5,php6,phtml,pl,asp,aspx,cgi,dll,exe,ico,shtm,shtml,fcg,fcgi,fpl,asmx,pht
php_value engine off
</Directory>
<Directory /home/bitrix/www/upload/support/not_image>
AllowOverride none
Order allow,deny
Deny from all
</Directory>
<Directory /home/bitrix/www/bitrix/images>
AllowOverride none
AddType text/plain php,php3,php4,php5,php6,phtml,pl,asp,aspx,cgi,dll,exe,ico,shtm,shtml,fcg,fcgi,fpl,asmx,pht
php_value engine off
</Directory>
<Directory /home/bitrix/www/bitrix/tmp>
AllowOverride none
AddType text/plain php,php3,php4,php5,php6,phtml,pl,asp,aspx,cgi,dll,exe,ico,shtm,shtml,fcg,fcgi,fpl,asmx,pht
php_value engine off
</Directory>
ErrorLog logs/error_log
# Possible values include: debug, info, notice, warn, error, crit, alert, emerg.
LogLevel warn
CustomLog logs/access_log combined
<IfModule mod_rewrite.c>
#Nginx should have "proxy_set_header HTTPS YES;" in location
RewriteEngine On
RewriteCond %{HTTP:HTTPS} =YES
RewriteRule .* - [E=HTTPS:on,L]
</IfModule>
</VirtualHost>
Listen 127.0.0.1:8887
<VirtualHost 127.0.0.1:8887>
DocumentRoot /home/bitrix/site
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<DirectoryMatch .*\.svn/.*>
Deny From All
</DirectoryMatch>
<DirectoryMatch .*\.git/.*>
Deny From All
</DirectoryMatch>
<DirectoryMatch .*\.hg/.*>
Deny From All
</DirectoryMatch>
<Directory /home/bitrix/site/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
DirectoryIndex index.php index.html index.htm
Order allow,deny
allow from all
php_admin_value session.save_path /tmp/php_sessions/www
php_admin_value upload_tmp_dir /tmp/php_upload/www
</Directory>
<Directory /home/bitrix/site/bitrix/cache>
AllowOverride none
Order allow,deny
Deny from all
</Directory>
<Directory /home/bitrix/site/bitrix/managed_cache>
AllowOverride none
Order allow,deny
Deny from all
</Directory>
<Directory /home/bitrix/site/bitrix/local_cache>
AllowOverride none
Order allow,deny
Deny from all
</Directory>
<Directory /home/bitrix/site/bitrix/stack_cache>
AllowOverride none
Order allow,deny
Deny from all
</Directory>
<Directory /home/bitrix/site/upload>
AllowOverride none
AddType text/plain php,php3,php4,php5,php6,phtml,pl,asp,aspx,cgi,dll,exe,ico,shtm,shtml,fcg,fcgi,fpl,asmx,pht
php_value engine off
</Directory>
<Directory /home/bitrix/site/upload/support/not_image>
AllowOverride none
Order allow,deny
Deny from all
</Directory>
<Directory /home/bitrix/site/bitrix/images>
AllowOverride none
AddType text/plain php,php3,php4,php5,php6,phtml,pl,asp,aspx,cgi,dll,exe,ico,shtm,shtml,fcg,fcgi,fpl,asmx,pht
php_value engine off
</Directory>
<Directory /home/bitrix/site/bitrix/tmp>
AllowOverride none
AddType text/plain php,php3,php4,php5,php6,phtml,pl,asp,aspx,cgi,dll,exe,ico,shtm,shtml,fcg,fcgi,fpl,asmx,pht
php_value engine off
</Directory>
ErrorLog logs/error_log
# Possible values include: debug, info, notice, warn, error, crit, alert, emerg.
LogLevel warn
CustomLog logs/access_log combined
<IfModule mod_rewrite.c>
#Nginx should have "proxy_set_header HTTPS YES;" in location
RewriteEngine On
RewriteCond %{HTTP:HTTPS} =YES
RewriteRule .* - [E=HTTPS:on,L]
</IfModule>
</VirtualHost>
#!/bin/bash
(
cd /home/bitrix/site \
&& (
# Install dependencies
yarn install --no-progress --no-bin-links \
& composer update --no-progress \
& wait
) && (
# Build and migrations
gulp \
&& php migrator migrate
) && (
# Set permissions
chown -R bitrix.bitrix /home/bitrix/site
)
)
#!/bin/bash
DEST="$1"
DEV="$2"
if [ "$DEV" == "1" ]; then
cp -r /home/bitrix/www/bitrix $DEST
cp -r /home/bitrix/www/upload $DEST
else
ln -s /home/bitrix/www/bitrix $DEST
ln -s /home/bitrix/www/upload $DEST
fi
# Default website
server {
listen 8080;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host:80;
set $proxyserver "http://127.0.0.1:8888";
set $docroot "/home/bitrix/www";
index index.php;
root /home/bitrix/www;
# Redirect to ssl if need
if (-f /home/bitrix/www/.htsecure) { rewrite ^(.*)$ https://$host$1 permanent; }
# Include parameters common to all websites
include bx/conf/bitrix.conf;
# Include server monitoring locations
include bx/server_monitor.conf;
}
# Default website
server {
listen 80;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host:80;
set $proxyserver "http://127.0.0.1:8887";
set $docroot "/home/bitrix/site";
index index.php;
root /home/bitrix/site;
# Redirect to ssl if need
if (-f /home/bitrix/site/.htsecure) { rewrite ^(.*)$ https://$host$1 permanent; }
# Include parameters common to all websites
include bx/conf/bitrix.conf;
# Include server monitoring locations
include bx/server_monitor.conf;
}
#!/bin/bash
# Modify bitrix user id and group id
if [ ! -z "$USER_ID" ]; then
usermod -u $USER_ID bitrix
fi
if [ ! -z "$GROUP_ID" ]; then
groupmod -g $GROUP_ID bitrix
fi
# Create symbolic links to bitrix and uploads
/bin/bash /link_bx.sh /home/bitrix/site
# Set permissions
chown -R bitrix.bitrix /home/bitrix
# Start server
/bin/bash /run.sh
stages:
- startup
- build
- deploy
variables:
BUILD_PATH: "www/dist"
save_user_data:
stage: startup
script:
- bash backup_bitrix.sh
variables:
GIT_STRATEGY: none
startup:
stage: startup
script:
- docker-compose up -d
.build_assets:
stage: build
script:
- docker-compose exec -T bitrix bash -c 'yarn install'
- docker-compose exec -T bitrix bash -c 'gulp'
cache:
paths:
- www/node_modules/
artifacts:
paths:
- $BUILD_PATH
expire_in: 1 day
.migrations:
stage: build
script:
- bash restore_bitrix.sh
- docker-compose exec -T bitrix bash -c 'composer update'
- docker-compose exec -T bitrix bash -c 'php migrator migrate'
cache:
paths:
- www/vendor/
deploy:
stage: deploy
script:
- bash restore_bitrix.sh
- echo 'Get all artifacts from previous stages, so site working properly'
.restore_bitrix:
stage: build
variables:
GIT_STRATEGY: none
script:
- docker-compose exec -T bitrix bash -c 'cp /home/bitrix/backup/bitrix.tar.gz .'
- docker-compose exec -T bitrix bash -c 'tar -xzvf bitrix.tar.gz'
- docker-compose exec -T bitrix bash -c 'rm -f bitrix.tar.gz'
when: manual
.backup_bitrix:
stage: build
variables:
GIT_STRATEGY: none
script:
- tar -czf bitrix.tar.gz bitrix/ upload/
- mv bitrix.tar.gz /tmp/
artifacts:
paths:
- www/bitrix/
- www/upload/
expire_in: 1 day
when: manual
#!/bin/bash
export ARTIFACTS_PATH="$HOME/localartifacts/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME/$CI_PIPELINE_ID/"
cp $ARTIFACTS_PATH/bitrix.tar.gz .
tar -xzf bitrix.tar.gz
rm -f bitrix.tar.gz
#!/bin/bash
export USER_ID="$(id -u `whoami`)"
export GROUP_ID="$(id -g `whoami`)"
docker-compose up -d
This diff is collapsed.
'use strict';
const path = require('path');
const startanull = require('startanull');
// let templatePath = 'local/templates/[template_name]';
let templatePath = '';
let srcDir = path.resolve(__dirname, templatePath, 'src');
let resDir = path.resolve(__dirname, templatePath, 'dist');
let conf = {};
let gulp = conf.gulp = require('gulp');
// BrowserSync
conf.browserSyncOpts = {
proxy: 'dev-1-9927.zk.dev'
};
conf.browserSyncWatch = [
resDir + path.sep + '**',
'!' + srcDir + path.sep + '**'
];
// Styles
conf.stylesSrc = path.resolve(srcDir, 'styles') + path.sep + 'style.less';
conf.stylesDest = path.resolve(resDir, 'css');
conf.stylesWatch = [
path.resolve(srcDir, 'styles') + `${path.sep}**${path.sep}*.less`
];
// Scripts
conf.scriptsSrc = path.resolve(srcDir, 'scripts') + path.sep + 'main.js';
conf.scriptsDest = path.resolve(resDir, 'js');
conf.scriptsWebpack = {};
conf.scriptsWebpack.output = {
filename: '[name].js'
};
conf.scriptsWebpack.devtool = 'eval';
conf.scriptsWebpack.module = {
loaders: [
{
test: /\.jsx?$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel',
query: {
presets: ['es2015']
}
}
]
};
// Templates
conf.templatesSrc = path.resolve(srcDir, 'pug') + path.sep + '*.pug';
conf.templatesDest = resDir;
conf.templatesWatch = '';
conf.templatesPugOpts = {
locals: {},
pretty: true
};
startanull(conf);
<?
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/header.php");
$APPLICATION->SetTitle("Главная");
?>
test
<?
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/footer.php");
?>
#!/usr/bin/env php
<?php
require_once __DIR__ . '/vendor/autoload.php';
use Arrilot\BitrixMigrations\Commands\MakeCommand;
use Arrilot\BitrixMigrations\Commands\InstallCommand;
use Arrilot\BitrixMigrations\Commands\MigrateCommand;
use Arrilot\BitrixMigrations\Commands\RollbackCommand;
use Arrilot\BitrixMigrations\Commands\TemplatesCommand;
use Arrilot\BitrixMigrations\Commands\StatusCommand;
use Arrilot\BitrixMigrations\Migrator;
use Arrilot\BitrixMigrations\Storages\BitrixDatabaseStorage;
use Arrilot\BitrixMigrations\TemplatesCollection;
use Symfony\Component\Console\Application;
define("NOT_CHECK_PERMISSIONS", true);
$_SERVER["DOCUMENT_ROOT"] = __DIR__;
$DOCUMENT_ROOT = $_SERVER["DOCUMENT_ROOT"];
require $_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php";
CModule::IncludeModule("iblock");
$config = [
'table' => 'migrations',
'dir' => './migrations',
];
$database = new BitrixDatabaseStorage($config['table']);
$templates = new TemplatesCollection();
$templates->registerBasicTemplates();
$migrator = new Migrator($config, $templates, $database);
$app = new Application('Migrator');
$app->add(new MakeCommand($migrator));
$app->add(new InstallCommand($config['table'], $database));
$app->add(new MigrateCommand($migrator));
$app->add(new RollbackCommand($migrator));
$app->add(new TemplatesCommand($templates));
$app->add(new StatusCommand($migrator));
$app->run();
{
"author": "Constantine Karnaukhov <genteelknight@gmail.com>",
"devDependencies": {
"gulp": "^3.9.1",
"startanull": "^1.1.1"
},
"dependencies": {
"jquery": "2.2.*",
"uikit": "^2.27.1"
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment