prod: new devenv
This commit is contained in:
parent
7c62023e6f
commit
6da1b65915
@ -1,10 +1,10 @@
|
||||
# DB Configuration
|
||||
DB_DRIVER=pdo_mysql
|
||||
DB_HOST=myTube-backend-mysql
|
||||
DB_HOST=mytube-backend-mysql
|
||||
DB_PORT=3306
|
||||
DB_USER=myTube
|
||||
DB_USER=mytube
|
||||
DB_PASSWORD=pass
|
||||
DB_NAME=myTube
|
||||
DB_NAME=mytube
|
||||
DB_NAME_LOG=log
|
||||
|
||||
# MyTube Setup
|
||||
|
||||
@ -1,3 +0,0 @@
|
||||
#!/bin/bash
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
$SCRIPT_DIR/exec build
|
||||
@ -1,3 +0,0 @@
|
||||
#!/bin/bash
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
$SCRIPT_DIR/exec down
|
||||
@ -1,23 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
COMMAND="$@"
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
|
||||
#LOAD ENV VARIABLES FROM .ENV
|
||||
export $(grep -v '^#' "${SCRIPT_DIR}/../../.env" | xargs)
|
||||
|
||||
#MAC
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
docker compose -f "${SCRIPT_DIR}/../../docker/docker-compose-mac.yml" $COMMAND
|
||||
|
||||
#LINUX
|
||||
elif [[ "$OSTYPE" == "linux-gnu" ]]; then
|
||||
docker compose -f "${SCRIPT_DIR}/../../docker/docker-compose.yml" $COMMAND
|
||||
|
||||
else
|
||||
echo "Dieses Skript wird auf deinem Gerät nicht unterstützt"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#UNSET ENV VARIABLES FROM .ENV
|
||||
unset $(grep -v '^#' "${SCRIPT_DIR}/../../.env" | sed -E 's/(.*)=.*/\1/' | xargs)
|
||||
40
bin/script/firstRun
Executable file
40
bin/script/firstRun
Executable file
@ -0,0 +1,40 @@
|
||||
#!/bin/bash
|
||||
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
PROJECT_DIR=$(realpath $SCRIPT_DIR/../../)
|
||||
ENV_DIR=$(realpath $PROJECT_DIR/../../../)
|
||||
|
||||
source $ENV_DIR/bin/messages
|
||||
source $ENV_DIR/bin/drun
|
||||
|
||||
# Create local config files
|
||||
infomsg '[backend] Creating local config...'
|
||||
cp "$PROJECT_DIR"/config/autoload/monolog.local.php.dist "$PROJECT_DIR"/config/autoload/monolog.local.php
|
||||
cp "$PROJECT_DIR"/config/autoload/doctrine.local.php.dist "$PROJECT_DIR"/config/autoload/doctrine.local.php
|
||||
cp "$PROJECT_DIR"/config/autoload/redis.local.php.dist "$PROJECT_DIR"/config/autoload/redis.local.php
|
||||
successmsg '[backend] Local config done'
|
||||
|
||||
# Install packages
|
||||
infomsg '[backend] Composer install...'
|
||||
drun backend composer install -o
|
||||
successmsg '[backend] Composer install done'
|
||||
|
||||
# Dump autoload
|
||||
infomsg "[backend]: Dump autoload"
|
||||
drun backend composer da
|
||||
successmsg "[backend]: Dump autoload done"
|
||||
|
||||
# Migrate Databases
|
||||
infomsg '[backend] Running migrations...'
|
||||
drun backend composer doctrine migrations:migrate --no-interaction
|
||||
drun backend composer doctrine-log migrations:migrate --no-interaction
|
||||
successmsg '[backend] Migrations done'
|
||||
|
||||
# Seed DB
|
||||
infomsg '[backend] Running seeder...'
|
||||
drun backend composer console init:data
|
||||
drun backend composer console rbac:update
|
||||
successmsg '[backend] Seeding done'
|
||||
|
||||
successmsg '[backend] Initialization script done'
|
||||
|
||||
@ -2,31 +2,19 @@
|
||||
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
PROJECT_DIR=$(realpath $SCRIPT_DIR/../../)
|
||||
ENV_DIR=$(realpath $PROJECT_DIR/../../)
|
||||
ENV_DIR=$(realpath $PROJECT_DIR/../../../)
|
||||
source $ENV_DIR/bin/messages
|
||||
|
||||
# Check .env file
|
||||
if [ ! -f "$PROJECT_DIR/.env" ]
|
||||
then
|
||||
echo "Create .env file from example..."
|
||||
if [ ! -f "$PROJECT_DIR/.env" ] ; then
|
||||
infomsg "[backend] Creating .env"
|
||||
cp "$PROJECT_DIR/.env.example" "$PROJECT_DIR/.env"
|
||||
echo ".env file created, please change variables and call me again"
|
||||
exit 1
|
||||
successmsg "[backend] Created .env"
|
||||
fi
|
||||
|
||||
# Build and start docker containers
|
||||
$SCRIPT_DIR/exec build
|
||||
$SCRIPT_DIR/exec up -d
|
||||
|
||||
# Source drun
|
||||
source $ENV_DIR/bin/script/drun
|
||||
|
||||
# Install PHP packages
|
||||
drun myTube-backend composer install
|
||||
|
||||
# Migrate databases to current version
|
||||
drun myTube-backend composer dmm
|
||||
drun myTube-backend composer dmlm
|
||||
|
||||
# Insert setup for project after this line
|
||||
drun myTube-backend composer console rbac:update
|
||||
drun myTube-backend composer console init:data
|
||||
# Check docker-compose.yml file
|
||||
if [ ! -f "$PROJECT_DIR/docker/docker-compose.yml" ] ; then
|
||||
infomsg "[backend] Creating docker-compose.yml"
|
||||
cp "$PROJECT_DIR/docker/docker-compose.yml.dist" "$PROJECT_DIR/docker/docker-compose.yml"
|
||||
successmsg "[backend] Creating docker-compose.yml"
|
||||
fi
|
||||
|
||||
@ -1,3 +0,0 @@
|
||||
#!/bin/bash
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
$SCRIPT_DIR/exec stop
|
||||
@ -1,3 +0,0 @@
|
||||
#!/bin/bash
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
$SCRIPT_DIR/exec up -d
|
||||
39
bin/script/update
Executable file
39
bin/script/update
Executable file
@ -0,0 +1,39 @@
|
||||
#!/bin/bash
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
PROJECT_DIR=$(realpath $SCRIPT_DIR/../../)
|
||||
ENV_DIR=$(realpath $PROJECT_DIR/../../../)
|
||||
SYSTEM_ENV_FILE="$PROJECT_DIR/.env"
|
||||
CWD=$(pwd)
|
||||
|
||||
source $ENV_DIR/bin/messages
|
||||
source $ENV_DIR/bin/drun
|
||||
|
||||
# Pull branch in project directory
|
||||
infomsg "[backend]: Git pull"
|
||||
cd "$PROJECT_DIR"
|
||||
git pull
|
||||
successmsg "[backend]: Git pull done"
|
||||
|
||||
# Install packages
|
||||
infomsg '[backend] Composer install...'
|
||||
drun backend composer install -o
|
||||
successmsg '[backend] Composer install done'
|
||||
|
||||
# Dump autoload
|
||||
infomsg "[backend]: Dump autoload"
|
||||
drun backend composer da
|
||||
successmsg "[backend]: Dump autoload done"
|
||||
|
||||
# Migrate Databases
|
||||
infomsg '[backend] Running migrations...'
|
||||
drun backend composer doctrine migrations:migrate --no-interaction
|
||||
drun backend composer doctrine-log migrations:migrate --no-interaction
|
||||
successmsg '[backend] Migrations done'
|
||||
|
||||
# Update permissions
|
||||
infomsg "[backend]: Update roles and permissions"
|
||||
drun backend composer console rbac:update
|
||||
successmsg "[backend]: Update roles and permissions done"
|
||||
|
||||
# Switch back to current working directory
|
||||
cd "$CWD"
|
||||
@ -81,8 +81,8 @@
|
||||
"scripts": {
|
||||
"dmg": "php bin\/doctrine-migrations.php migrations:generate",
|
||||
"dmm": "php bin\/doctrine-migrations.php migrations:migrate --no-interaction",
|
||||
"dmlg": "php bin\/doctrine-migrations-log.php migrations:generate",
|
||||
"dmlm": "php bin\/doctrine-migrations-log.php migrations:migrate --no-interaction",
|
||||
"doctrine": "php bin\/doctrine-migrations.php",
|
||||
"doctrine-log": "php bin\/doctrine-migrations-log.php",
|
||||
"console": "php bin\/console.php",
|
||||
"createApi": "php bin\/createApi.php",
|
||||
"createPipeline": "php bin\/createPipeline.php",
|
||||
|
||||
@ -52,8 +52,8 @@
|
||||
"scripts": {
|
||||
"dmg": "php bin/doctrine-migrations.php migrations:generate",
|
||||
"dmm": "php bin/doctrine-migrations.php migrations:migrate --no-interaction",
|
||||
"dmlg": "php bin/doctrine-migrations-log.php migrations:generate",
|
||||
"dmlm": "php bin/doctrine-migrations-log.php migrations:migrate --no-interaction",
|
||||
"doctrine": "php bin/doctrine-migrations.php",
|
||||
"doctrine-log": "php bin/doctrine-migrations-log.php",
|
||||
"console": "php bin/console.php",
|
||||
"createApi": "php bin/createApi.php",
|
||||
"createPipeline": "php bin/createPipeline.php",
|
||||
|
||||
@ -3,26 +3,9 @@
|
||||
return [
|
||||
'api' => [
|
||||
'keys' => [
|
||||
'myTube' => $_ENV['HOMEPAGE_API_KEY'],
|
||||
'notification' => $_ENV['NOTIFICATION_API_KEY'],
|
||||
],
|
||||
|
||||
'services' => [
|
||||
'myTube' => [
|
||||
'host' => 'myTube-backend-nginx',
|
||||
'apis' => [
|
||||
|
||||
]
|
||||
],
|
||||
'notification' => [
|
||||
'host' => 'notification-backend-nginx',
|
||||
'apis' => [
|
||||
'send-mail' => [
|
||||
'path' => '/api/mail/send',
|
||||
'method' => 'POST'
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
@ -1,51 +0,0 @@
|
||||
version: '3'
|
||||
networks:
|
||||
myTube:
|
||||
external: true
|
||||
|
||||
services:
|
||||
myTube-backend-mysql:
|
||||
image: myTube-backend-mysql
|
||||
networks:
|
||||
- myTube
|
||||
build:
|
||||
context: ./../
|
||||
dockerfile: ./docker/mysql/dockerfile
|
||||
volumes:
|
||||
- /Users/flo/dev/backend/myTube/var/db:/var/lib/mysql:z
|
||||
environment:
|
||||
MYSQL_USER: ${DB_USER}
|
||||
MYSQL_PASSWORD: ${DB_PASSWORD}
|
||||
ports:
|
||||
- 3306:3306
|
||||
healthcheck:
|
||||
test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"]
|
||||
timeout: 20s
|
||||
retries: 10
|
||||
|
||||
myTube-backend-app:
|
||||
image: myTube-backend-app
|
||||
networks:
|
||||
- myTube
|
||||
build:
|
||||
context: ./../
|
||||
dockerfile: ./docker/php/dockerfile
|
||||
volumes:
|
||||
- /Users/flo/dev/backend/myTube/:/var/www/html:z
|
||||
ports:
|
||||
- 9000:9000
|
||||
depends_on:
|
||||
myTube-backend-mysql:
|
||||
condition: service_healthy
|
||||
|
||||
myTube-backend-nginx:
|
||||
image: myTube-backend-nginx
|
||||
networks:
|
||||
- myTube
|
||||
build:
|
||||
context: ./../
|
||||
dockerfile: ./docker/nginx/dockerfile
|
||||
ports:
|
||||
- 8080:80
|
||||
depends_on:
|
||||
- myTube-backend-app
|
||||
@ -1,4 +1,3 @@
|
||||
version: '3'
|
||||
networks:
|
||||
mytube:
|
||||
external: true
|
||||
@ -45,7 +44,9 @@ services:
|
||||
build:
|
||||
context: ./../
|
||||
dockerfile: ./docker/nginx/dockerfile
|
||||
ports:
|
||||
- 8080:80
|
||||
labels:
|
||||
- "traefik.http.routers.backend.rule=(Host(`mytube.srv`) || Host(`192.168.152.60`)) && PathPrefix(`/api`)"
|
||||
- "traefik.http.routers.backend.entrypoints=websecure"
|
||||
- "traefik.http.routers.backend.tls.certresolver=le"
|
||||
depends_on:
|
||||
- mytube-backend-app
|
||||
@ -1,4 +1,4 @@
|
||||
CREATE DATABASE IF NOT EXISTS `log`;
|
||||
CREATE DATABASE IF NOT EXISTS `myTube`;
|
||||
CREATE DATABASE IF NOT EXISTS `mytube`;
|
||||
|
||||
GRANT ALL PRIVILEGES on *.* to 'myTube'@'%';
|
||||
GRANT ALL PRIVILEGES on *.* to 'mytube'@'%';
|
||||
Loading…
Reference in New Issue
Block a user