Compare commits
21 Commits
9ffde6bccb
...
c9c854ed41
Author | SHA1 | Date | |
---|---|---|---|
c9c854ed41 | |||
0d57268700 | |||
f6fc1021d5 | |||
1ff04d3e1e | |||
fdd1fa50ff | |||
5f381ecd63 | |||
6d912268db | |||
4ab0cd7be2 | |||
6440dea859 | |||
35f7972cd4 | |||
7e12d32f9e | |||
984ae4dc27 | |||
33deefdd9e | |||
5eebaf8ec4 | |||
9d459e0ab7 | |||
47aaf3f3d6 | |||
17633c4005 | |||
1c4c9420f8 | |||
41ba159bb1 | |||
644706616a | |||
c7ab923563 |
50
Jenkinsfile
vendored
50
Jenkinsfile
vendored
@ -13,8 +13,9 @@ pipeline {
|
||||
}
|
||||
agent {
|
||||
dockerfile {
|
||||
filename 'docker/Dockerfile-test'
|
||||
filename 'docker/Dockerfile'
|
||||
dir '.'
|
||||
additionalBuildArgs '--target rvr_base'
|
||||
reuseNode true
|
||||
}
|
||||
}
|
||||
@ -26,8 +27,9 @@ pipeline {
|
||||
stage('Unit Testing') {
|
||||
agent {
|
||||
dockerfile {
|
||||
filename 'docker/Dockerfile-test'
|
||||
filename 'docker/Dockerfile'
|
||||
dir '.'
|
||||
additionalBuildArgs '--target rvr_base'
|
||||
reuseNode true
|
||||
}
|
||||
}
|
||||
@ -44,8 +46,9 @@ pipeline {
|
||||
stage('Static Code Analysis') {
|
||||
agent {
|
||||
dockerfile {
|
||||
filename 'docker/Dockerfile-test'
|
||||
filename 'docker/Dockerfile'
|
||||
dir '.'
|
||||
additionalBuildArgs '--target rvr_base'
|
||||
reuseNode true
|
||||
}
|
||||
}
|
||||
@ -58,5 +61,46 @@ pipeline {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Prepare Docker release') {
|
||||
environment {
|
||||
COMPOSER_HOME="${WORKSPACE}/.composer"
|
||||
npm_config_cache="${WORKSPACE}/.npm"
|
||||
}
|
||||
agent {
|
||||
dockerfile {
|
||||
filename 'docker/Dockerfile'
|
||||
dir '.'
|
||||
additionalBuildArgs '--target rvr_base'
|
||||
reuseNode true
|
||||
}
|
||||
}
|
||||
steps {
|
||||
script {
|
||||
sh script: 'git clean -ffdx', label: 'Clean repository'
|
||||
env.VERSION = sh(script: 'git describe --tags --always --match "Release_*" HEAD', returnStdout: true).trim()
|
||||
sh script: 'docker/scripts/release.sh', label: 'Release script'
|
||||
sh script: "rm -rf ${env.COMPOSER_HOME} ${env.npm_config_cache}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Release Docker image') {
|
||||
steps {
|
||||
script {
|
||||
withDockerRegistry([credentialsId: 'gitea-system-user', url: 'https://git.esoko.eu/']) {
|
||||
sh script: 'docker buildx create --use --bootstrap --platform=linux/arm64,linux/amd64 --name multi-platform-builder'
|
||||
sh script: """docker buildx build \
|
||||
--platform linux/amd64,linux/arm64 \
|
||||
-f docker/Dockerfile \
|
||||
--target rvr_release \
|
||||
-t git.esoko.eu/esoko/rvr:${env.VERSION} \
|
||||
--push \
|
||||
.""",
|
||||
label: 'Build Docker image'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"esoko/soko-web": "0.13.1",
|
||||
"esoko/soko-web": "0.14.1",
|
||||
"firebase/php-jwt": "^6.4"
|
||||
},
|
||||
"require-dev": {
|
||||
|
10
composer.lock
generated
10
composer.lock
generated
@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "59130fbd82b1c81275666b16adb0c1a1",
|
||||
"content-hash": "2fdc479615518ac79d67b0a3f72ea2cb",
|
||||
"packages": [
|
||||
{
|
||||
"name": "cocur/slugify",
|
||||
@ -82,11 +82,11 @@
|
||||
},
|
||||
{
|
||||
"name": "esoko/soko-web",
|
||||
"version": "v0.13.1",
|
||||
"version": "v0.14.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://git.esoko.eu/esoko/soko-web.git",
|
||||
"reference": "8bf495c89b4ce1456da1133adc285003e544dd48"
|
||||
"reference": "7210b24aa31f47a55125a7c1f74267313f372559"
|
||||
},
|
||||
"require": {
|
||||
"cocur/slugify": "^4.3",
|
||||
@ -108,7 +108,7 @@
|
||||
"GNU GPL 3.0"
|
||||
],
|
||||
"description": "Lightweight web framework",
|
||||
"time": "2023-07-08T12:38:40+00:00"
|
||||
"time": "2023-09-26T22:26:55+00:00"
|
||||
},
|
||||
{
|
||||
"name": "firebase/php-jwt",
|
||||
@ -3152,5 +3152,5 @@
|
||||
"prefer-lowest": false,
|
||||
"platform": [],
|
||||
"platform-dev": [],
|
||||
"plugin-api-version": "2.3.0"
|
||||
"plugin-api-version": "2.6.0"
|
||||
}
|
||||
|
@ -2,12 +2,17 @@ version: '3'
|
||||
services:
|
||||
app:
|
||||
build:
|
||||
context: ./docker
|
||||
dockerfile: Dockerfile-app
|
||||
context: .
|
||||
dockerfile: docker/Dockerfile
|
||||
target: rvr_dev
|
||||
depends_on:
|
||||
mariadb:
|
||||
condition: service_healthy
|
||||
ports:
|
||||
- 80:80
|
||||
volumes:
|
||||
- .:/var/www/rvr
|
||||
working_dir: /var/www/rvr
|
||||
mariadb:
|
||||
image: mariadb:10.3
|
||||
ports:
|
||||
@ -19,6 +24,13 @@ services:
|
||||
MYSQL_DATABASE: 'rvr'
|
||||
MYSQL_USER: 'rvr'
|
||||
MYSQL_PASSWORD: 'rvr'
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "mysqladmin -u $$MYSQL_USER -p$$MYSQL_PASSWORD ping -h localhost || exit 1"]
|
||||
start_period: 5s
|
||||
start_interval: 1s
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
adminer:
|
||||
image: adminer:4.8.1-standalone
|
||||
ports:
|
||||
|
44
docker/Dockerfile
Normal file
44
docker/Dockerfile
Normal file
@ -0,0 +1,44 @@
|
||||
FROM ubuntu:focal AS rvr_base
|
||||
|
||||
ENV DEBIAN_FRONTEND noninteractive
|
||||
|
||||
RUN apt update --fix-missing && apt install -y sudo curl git unzip mariadb-client nginx \
|
||||
php-apcu php7.4-cli php7.4-curl php7.4-fpm php7.4-mbstring php7.4-mysql php7.4-zip php7.4-xml
|
||||
|
||||
RUN mkdir -p /run/php
|
||||
COPY docker/configs/nginx.conf /etc/nginx/sites-available/default
|
||||
|
||||
COPY docker/scripts/install-composer.sh install-composer.sh
|
||||
RUN ./install-composer.sh
|
||||
|
||||
COPY docker/scripts/install-nodejs.sh install-nodejs.sh
|
||||
RUN ./install-nodejs.sh
|
||||
RUN npm install -g uglify-js clean-css-cli svgo yarn
|
||||
|
||||
|
||||
FROM rvr_base AS rvr_dev
|
||||
|
||||
RUN apt update --fix-missing && apt install -y php-xdebug
|
||||
|
||||
RUN echo "xdebug.remote_enable = 1" >> /etc/php/7.4/mods-available/xdebug.ini &&\
|
||||
echo "xdebug.remote_autostart = 1" >> /etc/php/7.4/mods-available/xdebug.ini &&\
|
||||
echo "xdebug.remote_connect_back = 1" >> /etc/php/7.4/mods-available/xdebug.ini
|
||||
|
||||
EXPOSE 80
|
||||
EXPOSE 5000
|
||||
EXPOSE 8090
|
||||
EXPOSE 9229
|
||||
ENTRYPOINT docker/scripts/entry-point-dev.sh
|
||||
|
||||
|
||||
FROM rvr_base AS rvr_release
|
||||
|
||||
RUN apt update --fix-missing && apt install -y cron
|
||||
|
||||
WORKDIR /var/www/rvr
|
||||
COPY ./ /var/www/rvr
|
||||
RUN rm -rf /var/www/rvr/.git
|
||||
|
||||
EXPOSE 80
|
||||
EXPOSE 8090
|
||||
ENTRYPOINT docker/scripts/entry-point.sh
|
@ -1,30 +0,0 @@
|
||||
FROM ubuntu:focal
|
||||
|
||||
ENV DEBIAN_FRONTEND noninteractive
|
||||
|
||||
# Install Nginx, PHP and further necessary packages
|
||||
RUN apt update --fix-missing
|
||||
RUN apt install -y curl git unzip mariadb-client nginx \
|
||||
php-apcu php-xdebug php7.4-cli php7.4-curl php7.4-fpm php7.4-mbstring php7.4-mysql php7.4-zip php7.4-xml
|
||||
|
||||
# Configure Nginx with PHP
|
||||
RUN mkdir -p /run/php
|
||||
COPY configs/nginx.conf /etc/nginx/sites-available/default
|
||||
RUN echo "xdebug.remote_enable = 1" >> /etc/php/7.4/mods-available/xdebug.ini
|
||||
RUN echo "xdebug.remote_autostart = 1" >> /etc/php/7.4/mods-available/xdebug.ini
|
||||
RUN echo "xdebug.remote_connect_back = 1" >> /etc/php/7.4/mods-available/xdebug.ini
|
||||
|
||||
# Install Composer
|
||||
COPY scripts/install-composer.sh install-composer.sh
|
||||
RUN ./install-composer.sh
|
||||
|
||||
# Install Node.js and required packages
|
||||
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash -
|
||||
RUN apt install -y nodejs
|
||||
RUN npm install -g uglify-js clean-css-cli svgo yarn
|
||||
|
||||
EXPOSE 80
|
||||
VOLUME /var/www/rvr
|
||||
WORKDIR /var/www/rvr
|
||||
|
||||
ENTRYPOINT /usr/sbin/php-fpm7.4 -F & /usr/sbin/nginx -g 'daemon off;'
|
@ -1,6 +0,0 @@
|
||||
FROM ubuntu:focal
|
||||
|
||||
ENV DEBIAN_FRONTEND noninteractive
|
||||
|
||||
RUN apt update && apt install -y curl git unzip php7.4-cli php7.4-mbstring php7.4-xml
|
||||
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
|
1
docker/scripts/cron
Normal file
1
docker/scripts/cron
Normal file
@ -0,0 +1 @@
|
||||
0 * * * * /var/www/rvr/rvr db:maintain
|
32
docker/scripts/entry-point-dev.sh
Executable file
32
docker/scripts/entry-point-dev.sh
Executable file
@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
echo "Installing Composer packages..."
|
||||
if [ -f .env ]; then
|
||||
composer install
|
||||
else
|
||||
composer create-project
|
||||
fi
|
||||
|
||||
echo "Installing Yarn packages..."
|
||||
(cd public/static && yarn install)
|
||||
|
||||
echo "Migrating DB..."
|
||||
./rvr db:migrate
|
||||
|
||||
echo "Set runner user based on owner of .env..."
|
||||
USER_UID=$(stat -c "%u" .env)
|
||||
USER_GID=$(stat -c "%g" .env)
|
||||
groupadd --gid $USER_GID rvr
|
||||
useradd --uid $USER_UID --gid $USER_GID rvr
|
||||
sed -i -e "s/^user = .*$/user = rvr/g" -e "s/^group = .*$/group = rvr/g" /etc/php/7.4/fpm/pool.d/www.conf
|
||||
|
||||
set +e
|
||||
|
||||
/usr/sbin/php-fpm7.4 -F &
|
||||
/usr/sbin/nginx -g 'daemon off;' &
|
||||
|
||||
wait -n
|
||||
|
||||
exit $?
|
27
docker/scripts/entry-point.sh
Executable file
27
docker/scripts/entry-point.sh
Executable file
@ -0,0 +1,27 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
echo "Migrating DB..."
|
||||
./rvr db:migrate
|
||||
|
||||
echo "Installing crontab..."
|
||||
/usr/bin/crontab docker/scripts/cron
|
||||
|
||||
echo "Set runner user based on owner of .env..."
|
||||
USER_UID=$(stat -c "%u" .env)
|
||||
USER_GID=$(stat -c "%g" .env)
|
||||
groupadd --gid $USER_GID rvr
|
||||
useradd --uid $USER_UID --gid $USER_GID rvr
|
||||
chown rvr:rvr cache
|
||||
sed -i -e "s/^user = .*$/user = rvr/g" -e "s/^group = .*$/group = rvr/g" /etc/php/7.4/fpm/pool.d/www.conf
|
||||
|
||||
set +e
|
||||
|
||||
/usr/sbin/cron -f &
|
||||
/usr/sbin/php-fpm7.4 -F &
|
||||
/usr/sbin/nginx -g 'daemon off;' &
|
||||
|
||||
wait -n
|
||||
|
||||
exit $?
|
14
docker/scripts/install-nodejs.sh
Executable file
14
docker/scripts/install-nodejs.sh
Executable file
@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
apt update
|
||||
apt install -y ca-certificates curl gnupg
|
||||
mkdir -p /etc/apt/keyrings
|
||||
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
|
||||
|
||||
NODE_MAJOR=18
|
||||
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list
|
||||
|
||||
apt update
|
||||
apt install -y nodejs
|
27
docker/scripts/release.sh
Executable file
27
docker/scripts/release.sh
Executable file
@ -0,0 +1,27 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
echo "Installing Composer packages..."
|
||||
composer create-project --no-dev
|
||||
|
||||
echo "Installing Yarn packages..."
|
||||
(cd public/static && yarn install)
|
||||
|
||||
echo "Updating version info..."
|
||||
VERSION=$(git describe --tags --always --match "Release_*" HEAD)
|
||||
REVISION=$(git rev-parse --short HEAD)
|
||||
REVISION_DATE=$(git show -s --format=%aI HEAD)
|
||||
sed -i -E "s/const VERSION = '(.*)';/const VERSION = '${VERSION}';/" app.php
|
||||
sed -i -E "s/const REVISION = '(.*)';/const REVISION = '${REVISION}';/" app.php
|
||||
sed -i -E "s/const REVISION_DATE = '(.*)';/const REVISION_DATE = '${REVISION_DATE}';/" app.php
|
||||
|
||||
echo "Minifying JS, CSS and SVG files..."
|
||||
find public/static/js -type f -iname '*.js' -exec uglifyjs {} -c -m -o {} \;
|
||||
find public/static/css -type f -iname '*.css' -exec cleancss {} -o {} \;
|
||||
find public/static/img -type f -iname '*.svg' -exec svgo {} -o {} \;
|
||||
|
||||
echo "Linking view files..."
|
||||
./rvr view:link
|
||||
|
||||
rm .env
|
@ -1,162 +0,0 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
# Usage: ./deploy-to-multiple-worktrees.py REPO_PATH WORKTREE_DEVELOPMENT_PATH WORKTREE_PRODUCTION_PATH
|
||||
|
||||
import sys
|
||||
import os
|
||||
import subprocess
|
||||
import re
|
||||
|
||||
WORKTREE_REGEX = r"^worktree (.*)\nHEAD ([a-f0-9]*)\n(?:branch refs\/heads\/(.*)|detached)$"
|
||||
|
||||
if len(sys.argv) < 4:
|
||||
print("Usage: ./deploy-to-multiple-worktrees.py REPO_PATH WORKTREE_DEVELOPMENT_PATH WORKTREE_PRODUCTION_PATH")
|
||||
exit(1)
|
||||
|
||||
REPO = os.path.abspath(sys.argv[1])
|
||||
WORKTREE_DEVELOPMENT = os.path.abspath(sys.argv[2])
|
||||
WORKTREE_PRODUCTION = os.path.abspath(sys.argv[3])
|
||||
|
||||
class Worktree:
|
||||
def __init__(self, path, branch, revision, version):
|
||||
self.path = path
|
||||
self.branch = branch
|
||||
self.revision = revision
|
||||
self.version = version
|
||||
self.newRevision = None
|
||||
self.newVersion = None
|
||||
|
||||
def getDataForWorktrees():
|
||||
ret = subprocess.check_output(["git", "worktree", "list", "--porcelain"], cwd=REPO).decode().strip()
|
||||
blocks = ret.split("\n\n")
|
||||
|
||||
worktrees = []
|
||||
|
||||
for block in blocks:
|
||||
matches = re.search(WORKTREE_REGEX, block)
|
||||
|
||||
if matches:
|
||||
path = matches.group(1)
|
||||
revision = matches.group(2)
|
||||
branch = matches.group(3)
|
||||
version = getVersion(revision)
|
||||
|
||||
worktrees.append(Worktree(path, branch, revision, version))
|
||||
|
||||
return worktrees
|
||||
|
||||
def findWorktree(path):
|
||||
for worktree in worktrees:
|
||||
if worktree.path == path:
|
||||
return worktree
|
||||
|
||||
return None
|
||||
|
||||
def getVersion(branch):
|
||||
return subprocess.check_output(["git", "describe", "--tags", "--always", "--match", "Release_*", branch], cwd=REPO).decode().strip()
|
||||
|
||||
def getRevisionForRef(ref):
|
||||
return subprocess.check_output(["git", "rev-list", "-1", ref], cwd=REPO).decode().strip()
|
||||
|
||||
def getLatestReleaseTag():
|
||||
process = subprocess.Popen(["git", "for-each-ref", "refs/tags/Release*", "--sort=-creatordate", "--format=%(refname:short)"], stdout=subprocess.PIPE, cwd=REPO)
|
||||
|
||||
for line in process.stdout:
|
||||
tag = line.decode().rstrip()
|
||||
|
||||
if isTagVerified(tag):
|
||||
return tag
|
||||
|
||||
print(f"[WARNING] Tag '{tag}' is not verified, skipping.")
|
||||
|
||||
raise Exception("No verified 'Release*' tag found!")
|
||||
|
||||
def isTagVerified(tag):
|
||||
process = subprocess.run(["git", "tag", "--verify", tag], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, cwd=REPO)
|
||||
|
||||
return process.returncode == 0
|
||||
|
||||
def updateRepoFromRemote():
|
||||
subprocess.call(["git", "fetch", "origin", "--prune", "--prune-tags"], cwd=REPO)
|
||||
|
||||
def checkoutWorktree(worktreePath, ref):
|
||||
subprocess.call(["git", "checkout", "-f", ref], cwd=worktreePath)
|
||||
|
||||
def cleanWorktree(worktreePath):
|
||||
subprocess.call(["git", "clean", "-f", "-d"], cwd=worktreePath)
|
||||
|
||||
def updateAppInWorktree(worktreePath):
|
||||
subprocess.call([worktreePath + "/scripts/update.sh"], cwd=worktreePath)
|
||||
|
||||
def updateAppVersionInWorktree(worktreePath):
|
||||
subprocess.call([worktreePath + "/scripts/update-version.sh"], cwd=worktreePath)
|
||||
|
||||
worktrees = getDataForWorktrees()
|
||||
|
||||
updateRepoFromRemote()
|
||||
|
||||
print("Repo is updated from origin")
|
||||
|
||||
print("----------------------------------------------")
|
||||
print("----------------------------------------------")
|
||||
|
||||
developmentWorktree = findWorktree(WORKTREE_DEVELOPMENT)
|
||||
|
||||
developmentWorktree.newRevision = getRevisionForRef(developmentWorktree.branch)
|
||||
developmentWorktree.newVersion = getVersion(developmentWorktree.revision)
|
||||
|
||||
print("DEVELOPMENT (" + developmentWorktree.path + ") is on branch " + developmentWorktree.branch)
|
||||
print(developmentWorktree.revision + " = " + developmentWorktree.branch + " (" + developmentWorktree.version + ")")
|
||||
print(developmentWorktree.newRevision + " = origin/" + developmentWorktree.branch + " (" + developmentWorktree.newVersion + ")")
|
||||
|
||||
if developmentWorktree.revision != developmentWorktree.newRevision:
|
||||
print("-> DEVELOPMENT (" + developmentWorktree.path + ") will be UPDATED")
|
||||
print("----------------------------------------------")
|
||||
|
||||
checkoutWorktree(developmentWorktree.path, developmentWorktree.branch)
|
||||
cleanWorktree(developmentWorktree.path)
|
||||
|
||||
print(developmentWorktree.path + " is checked out to " + developmentWorktree.branch + " and cleaned")
|
||||
|
||||
updateAppInWorktree(developmentWorktree.path)
|
||||
updateAppVersionInWorktree(developmentWorktree.path)
|
||||
|
||||
print("RVR is updated in " + developmentWorktree.path)
|
||||
elif developmentWorktree.version != developmentWorktree.newVersion:
|
||||
print("-> DEVELOPMENT " + developmentWorktree.path + "'s version info will be UPDATED")
|
||||
|
||||
updateAppVersionInWorktree(developmentWorktree.path)
|
||||
|
||||
print("RVR version is updated in " + developmentWorktree.path)
|
||||
else:
|
||||
print("-> DEVELOPMENT (" + developmentWorktree.path + ") WON'T be updated")
|
||||
|
||||
print("----------------------------------------------")
|
||||
print("----------------------------------------------")
|
||||
|
||||
productionWorktree = findWorktree(WORKTREE_PRODUCTION)
|
||||
|
||||
productionWorktree.newVersion = getLatestReleaseTag()
|
||||
productionWorktree.newRevision = getRevisionForRef(productionWorktree.newVersion)
|
||||
|
||||
print("PRODUCTION (" + productionWorktree.path + ")")
|
||||
print(productionWorktree.revision + " = " + productionWorktree.version)
|
||||
print(productionWorktree.newRevision + " = " + productionWorktree.newVersion)
|
||||
|
||||
if productionWorktree.revision != productionWorktree.newRevision:
|
||||
print("-> PRODUCTION (" + productionWorktree.path + ") will be UPDATED")
|
||||
|
||||
checkoutWorktree(productionWorktree.path, productionWorktree.newRevision)
|
||||
cleanWorktree(productionWorktree.path)
|
||||
|
||||
print(productionWorktree.path + " is checked out to " + productionWorktree.newRevision + " and cleaned")
|
||||
|
||||
updateAppInWorktree(productionWorktree.path)
|
||||
updateAppVersionInWorktree(productionWorktree.path)
|
||||
|
||||
print("RVR is updated in " + productionWorktree.path)
|
||||
else:
|
||||
print("-> PRODUCTION (" + productionWorktree.path + ") WON'T be updated")
|
||||
|
||||
print("----------------------------------------------")
|
||||
print("----------------------------------------------")
|
@ -1,32 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
ROOT_DIR=$(dirname $(readlink -f "$0"))/..
|
||||
|
||||
. ${ROOT_DIR}/.env
|
||||
|
||||
if [ -f ${ROOT_DIR}/installed ]; then
|
||||
echo "RVR is already installed! To force reinstall, delete file 'installed' from the root directory!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Installing Yarn packages..."
|
||||
(cd ${ROOT_DIR}/public/static && yarn install)
|
||||
|
||||
echo "Installing RVR DB..."
|
||||
mysql --host=${DB_HOST} --user=${DB_USER} --password=${DB_PASSWORD} ${DB_NAME} < ${ROOT_DIR}/database/rvr.sql
|
||||
|
||||
echo "Migrating DB..."
|
||||
(cd ${ROOT_DIR} && ./rvr db:migrate)
|
||||
|
||||
if [ -z "${DEV}" ] || [ "${DEV}" -eq "0" ]; then
|
||||
echo "Minifying JS, CSS and SVG files..."
|
||||
${ROOT_DIR}/scripts/minify.sh
|
||||
|
||||
echo "Linking view files..."
|
||||
(cd ${ROOT_DIR} && ./rvr view:link)
|
||||
else
|
||||
echo "Creating the first user..."
|
||||
(cd ${ROOT_DIR} && ./rvr user:add rvr@rvr.dev 123456 admin)
|
||||
fi
|
||||
|
||||
touch ${ROOT_DIR}/installed
|
@ -1,11 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
ROOT_DIR=$(dirname $(readlink -f "$0"))/..
|
||||
|
||||
. ${ROOT_DIR}/.env
|
||||
|
||||
find ${ROOT_DIR}/public/static/js -type f -iname '*.js' -exec uglifyjs {} -c -m -o {} \;
|
||||
|
||||
find ${ROOT_DIR}/public/static/css -type f -iname '*.css' -exec cleancss {} -o {} \;
|
||||
|
||||
find ${ROOT_DIR}/public/static/img -type f -iname '*.svg' -exec svgo {} -o {} \;
|
@ -1,17 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
ROOT_DIR=$(dirname $(readlink -f "$0"))/..
|
||||
|
||||
. ${ROOT_DIR}/.env
|
||||
|
||||
cd ${ROOT_DIR}
|
||||
|
||||
echo "Updating version info..."
|
||||
|
||||
VERSION=$(git describe --tags --always --match "Release_*" HEAD)
|
||||
REVISION=$(git rev-parse --short HEAD)
|
||||
REVISION_DATE=$(git show -s --format=%aI HEAD)
|
||||
|
||||
sed -i -E "s/const VERSION = '(.*)';/const VERSION = '${VERSION}';/" app.php
|
||||
sed -i -E "s/const REVISION = '(.*)';/const REVISION = '${REVISION}';/" app.php
|
||||
sed -i -E "s/const REVISION_DATE = '(.*)';/const REVISION_DATE = '${REVISION_DATE}';/" app.php
|
@ -1,26 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
ROOT_DIR=$(dirname $(readlink -f "$0"))/..
|
||||
|
||||
. ${ROOT_DIR}/.env
|
||||
|
||||
echo "Installing Composer packages..."
|
||||
if [ -z "${DEV}" ] || [ "${DEV}" -eq "0" ]; then
|
||||
(cd ${ROOT_DIR} && composer install --no-dev)
|
||||
else
|
||||
(cd ${ROOT_DIR} && composer install --dev)
|
||||
fi
|
||||
|
||||
echo "Installing Yarn packages..."
|
||||
(cd ${ROOT_DIR}/public/static && yarn install)
|
||||
|
||||
echo "Migrating DB..."
|
||||
(cd ${ROOT_DIR} && ./rvr db:migrate)
|
||||
|
||||
if [ -z "${DEV}" ] || [ "${DEV}" -eq "0" ]; then
|
||||
echo "Minifying JS, CSS and SVG files..."
|
||||
${ROOT_DIR}/scripts/minify.sh
|
||||
|
||||
echo "Linking view files..."
|
||||
(cd ${ROOT_DIR} && ./rvr view:link)
|
||||
fi
|
@ -19,6 +19,8 @@ class MigrateDatabaseCommand extends Command
|
||||
{
|
||||
$db = \Container::$dbConnection;
|
||||
|
||||
$this->createBaseDb();
|
||||
|
||||
$db->startTransaction();
|
||||
|
||||
$success = [];
|
||||
@ -62,10 +64,8 @@ class MigrateDatabaseCommand extends Command
|
||||
return 0;
|
||||
}
|
||||
|
||||
private function readDir(string $type): array
|
||||
private function createBaseDb()
|
||||
{
|
||||
$done = [];
|
||||
|
||||
$migrationTableExists = \Container::$dbConnection->query('SELECT count(*)
|
||||
FROM information_schema.tables
|
||||
WHERE table_schema = \'' . $_ENV['DB_NAME'] . '\'
|
||||
@ -73,16 +73,25 @@ class MigrateDatabaseCommand extends Command
|
||||
->fetch(IResultSet::FETCH_NUM)[0];
|
||||
|
||||
if ($migrationTableExists != 0) {
|
||||
$select = new Select(\Container::$dbConnection, 'migrations');
|
||||
$select->columns(['migration']);
|
||||
$select->where('type', '=', $type);
|
||||
$select->orderBy('migration');
|
||||
return;
|
||||
}
|
||||
|
||||
$result = $select->execute();
|
||||
\Container::$dbConnection->multiQuery(file_get_contents(ROOT . '/database/rvr.sql'));
|
||||
}
|
||||
|
||||
while ($migration = $result->fetch(IResultSet::FETCH_ASSOC)) {
|
||||
$done[] = $migration['migration'];
|
||||
}
|
||||
private function readDir(string $type): array
|
||||
{
|
||||
$done = [];
|
||||
|
||||
$select = new Select(\Container::$dbConnection, 'migrations');
|
||||
$select->columns(['migration']);
|
||||
$select->where('type', '=', $type);
|
||||
$select->orderBy('migration');
|
||||
|
||||
$result = $select->execute();
|
||||
|
||||
while ($migration = $result->fetch(IResultSet::FETCH_ASSOC)) {
|
||||
$done[] = $migration['migration'];
|
||||
}
|
||||
|
||||
$path = ROOT . '/database/migrations/' . $type;
|
||||
|
Loading…
Reference in New Issue
Block a user