Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
A
aphp1_classwork80
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Egor Kremnev
aphp1_classwork80
Commits
fdb59959
Commit
fdb59959
authored
Aug 15, 2023
by
Egor Kremnev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add scripts
parent
c61e88ee
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
4440 additions
and
11466 deletions
+4440
-11466
composer.lock
composer.lock
+1417
-1541
package-lock.json
package-lock.json
+2789
-9925
apply-update.sh
scripts/apply-update.sh
+92
-0
build.sh
scripts/build.sh
+49
-0
create-deployment-package.sh
scripts/create-deployment-package.sh
+47
-0
deploy-update-package.sh
scripts/deploy-update-package.sh
+46
-0
No files found.
composer.lock
View file @
fdb59959
This diff is collapsed.
Click to expand it.
package-lock.json
View file @
fdb59959
This diff is collapsed.
Click to expand it.
scripts/apply-update.sh
View file @
fdb59959
#!/usr/bin/env bash
# shellcheck disable=SC2086
set
-e
INSTANCE_NAME
=
${
1
}
LATEST_ARTIFACT_NAME
=
${
2
}
APPLICATION_ROOT_PATH
=
${
3
}
VERSION
=
$(
cat
${
APPLICATION_ROOT_PATH
}
/VERSION
)
PROJECT_ROOT
=
${
APPLICATION_ROOT_PATH
}
/application
BACKUP_DIR
=
/application_backups
# Create backup directory if not exist
mkdir
-p
${
BACKUP_DIR
}
BACKUP_DATE
=
$(
date
+
"%Y_%m_%d__%H_%M"
)
BACKUP_DIR_PATH
=
${
BACKUP_DIR
}
/
${
PROJECT_ROOT
}
_backup_
${
BACKUP_DATE
}
_v
${
VERSION
}
DB_PATH
=
${
PROJECT_ROOT
}
/database/database.
${
INSTANCE_NAME
}
.sqlite
STASH_DB_DIR
=
/tmp/db/
STASH_DB_PATH
=
${
STASH_DB_DIR
}
database.
${
INSTANCE_NAME
}
.sqlite
info
()
{
echo
-e
"
\e
[33m[Info]
\e
[33m
$1
\e
[39m
$(for
i
in
{
12..21
}
;
do
echo
-en
"
\e
[33;1;
${
i
}
m.
\e
[0m"
;
done
;
echo
)
"
}
success
()
{
echo
-e
"
\e
[32m[Success]
\e
[32m
$1
\e
[39m
$(for
i
in
{
12..21
}
;
do
echo
-en
"
\e
[32;1;
${
i
}
m.
\e
[0m"
;
done
;
echo
)
"
}
if
[[
"
$(
id
-u
)
"
!=
"0"
]]
;
then
echo
"This script must be run as root"
1>&2
exit
1
fi
cd
${
APPLICATION_ROOT_PATH
}
mkdir
-p
${
STASH_DB_DIR
}
info
"# Creating backup"
if
[[
-f
${
DB_PATH
}
]]
;
then
info
"# Put db to temporary stash"
cp
${
DB_PATH
}
${
STASH_DB_PATH
}
fi
mkdir
-p
${
BACKUP_DIR_PATH
}
mv
${
PROJECT_ROOT
}
${
BACKUP_DIR_PATH
}
info
"# Extracting app package"
mkdir
-p
${
PROJECT_ROOT
}
tar
-xzf
${
LATEST_ARTIFACT_NAME
}
-C
${
PROJECT_ROOT
}
if
[[
-f
${
STASH_DB_PATH
}
]]
;
then
info
"# Restore DB from stash"
mv
${
STASH_DB_PATH
}
${
DB_PATH
}
fi
info
"# Setup permission for cache dir and storage"
chmod
-R
777
${
PROJECT_ROOT
}
/storage/
chmod
-R
777
${
PROJECT_ROOT
}
/bootstrap/cache
info
"# Set user to .env file"
chown
root:
${
PROJECT_ROOT
}
/.env
info
"# Set application key"
cd
${
PROJECT_ROOT
}
php artisan key:generate
info
"# Optimizing Configuration Loading..."
php artisan config:cache
info
"# Optimizing Route Loading"
php artisan route:cache
info
"# Optimizing View Loading"
php artisan view:cache
info
"# Database folder permission"
chmod
-R
775 database
chown
-R
$(
whoami
)
database
info
"# Restart nginx server"
service nginx restart
cd
${
APPLICATION_ROOT_PATH
}
info
"# Destroy archive
${
LATEST_ARTIFACT_NAME
}
"
rm
${
LATEST_ARTIFACT_NAME
}
info
"# Destroy VERSION file"
rm
VERSION
info
"# Destroy script"
rm
apply-update.sh
success
"Update successfully!"
scripts/build.sh
View file @
fdb59959
#!/usr/bin/env bash
set
-e
info
()
{
echo
-e
"
\e
[33m [Info]
\e
[33m
$1
\e
[39m"
}
success
()
{
echo
-e
"
\e
[32m [Success]
\e
[32m
$1
\e
[39m"
}
info
"build started under user
$(
whoami
)
"
info
"Install environment for unit tests"
cp
.env.unit .env
info
"Install requirements >>>>> "
composer
install
--no-interaction
--prefer-dist
info
"Generate application key >>>>>> "
php artisan key:generate
info
"Start unit test >>>>> "
php artisan
test
info
"Setup environment for dusk test"
cp
.env.dusk .env
info
"Make database for testing"
touch
database/database.unit.sqlite
touch
database/database.dusk.sqlite
php artisan key:generate
php artisan dusk:chrome-driver
nohup
bash
-c
"php artisan serve --env=dusk --port=4343 2>&1 &"
&&
sleep
5
php artisan dusk
success
"Completed testing!"
scripts/create-deployment-package.sh
View file @
fdb59959
#!/usr/bin/env bash
set
-e
BRANCH
=
${
1
}
VERSION
=
${
2
}
ENV_NAME
=
.env.
${
BRANCH
}
info
()
{
echo
-e
"
\e
[33m[Info]
\e
[33m
$1
\e
[39m"
}
success
()
{
echo
-e
"
\e
[32m[Success]
\e
[32m
$1
\e
[39m"
}
info
"./build.sh starts here..."
info
"build started under user
$(
whoami
)
"
info
"Clear all cache"
php artisan cache:clear
php artisan view:clear
php artisan config:clear
info
"Install environment for server
${
BRANCH
}
"
cp
${
ENV_NAME
}
.env
info
"Install requirements"
composer
install
--no-interaction
--prefer-dist
info
"Generate application key"
php artisan key:generate
info
"Create directory 'artifacts' if not exists"
mkdir
-p
${
HOME
}
/artifacts
info
"Create application artifact for version:
${
VERSION
}
"
tar
-czf
${
HOME
}
/artifacts/application-
${
VERSION
}
.tar.gz
\
--exclude
=
README.md
\
--exclude
=
tests
\
.
ls
${
HOME
}
/artifacts/
success
"Create package completed!"
scripts/deploy-update-package.sh
View file @
fdb59959
#!/usr/bin/env bash
# shellcheck disable=SC2086
set
-e
# IP or hostname, example: root@82.196.9.144 or root@example.com
HOST
=
${
1
}
# production, demo or staging etc...
INSTANCE_NAME
=
${
2
}
# Stable version
VERSION
=
${
3
}
PATH_TO_SCRIPTS_DIR
=
${
4
}
/scripts
PATH_TO_NGINX_CONFIG_FILE
=
${
PATH_TO_SCRIPTS_DIR
}
/nginx/default.conf
APPLICATION_ROOT_PATH
=
/home/deploy
# Archive name
LATEST_ARTIFACT_NAME
=
application-
${
VERSION
}
.tar.gz
# Path to archive
LATEST_ARTIFACT_PATH
=
${
HOME
}
/artifacts/
${
LATEST_ARTIFACT_NAME
}
info
()
{
echo
-e
"
\e
[33m[Info]
\e
[33m
$1
\e
[39m
$(for
i
in
{
12..21
}
;
do
echo
-en
"
\e
[33;1;
${
i
}
m>
\e
[0m"
;
done
;
echo
)
"
}
success
()
{
echo
-e
"
\e
[32m[Success]
\e
[32m
$1
\e
[39m
$(for
i
in
{
12..21
}
;
do
echo
-en
"
\e
[32;1;
${
i
}
m>
\e
[0m"
;
done
;
echo
)
"
}
script_execution_dir
=
$(
pwd
)
info
"Scripts run under
${
script_execution_dir
}
directory"
scp
${
PATH_TO_SCRIPTS_DIR
}
/apply-update.sh
${
HOST
}
:
${
APPLICATION_ROOT_PATH
}
scp
${
PATH_TO_NGINX_CONFIG_FILE
}
${
HOST
}
:/etc/nginx/sites-available/default
scp
${
LATEST_ARTIFACT_PATH
}
${
HOST
}
:
${
APPLICATION_ROOT_PATH
}
echo
${
VERSION
}
>
VERSION
scp VERSION
${
HOST
}
:
${
APPLICATION_ROOT_PATH
}
# shellcheck disable=SC2087
ssh
${
HOST
}
<<
EOL
chmod +x apply-update.sh
${
APPLICATION_ROOT_PATH
}
/apply-update.sh
${
INSTANCE_NAME
}
${
LATEST_ARTIFACT_NAME
}
${
APPLICATION_ROOT_PATH
}
EOL
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment