Skip to content

Commit

Permalink
Add db set up to application.
Browse files Browse the repository at this point in the history
  • Loading branch information
DvDty committed Jan 28, 2024
1 parent 381e9a7 commit 8f470c0
Show file tree
Hide file tree
Showing 12 changed files with 143 additions and 7 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,21 @@ Main focus is to provide the development team strong CI:

Example with leaked api key:

![img.png](img.png)
![img.png](readme/img.png)

Notification in slack:

![img_1.png](img_1.png)
![img_1.png](readme/img_1.png)

### Code linter

![img_3.png](img_3.png)
![img_3.png](readme/img_3.png)

![img_2.png](img_2.png)
![img_2.png](readme/img_2.png)

### Code coverage

![img_4.png](img_4.png)
![img_4.png](readme/img_4.png)


## Control plane
Expand Down
42 changes: 42 additions & 0 deletions application/k8s/db-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
apiVersion: v1
kind: Service
metadata:
name: mysql
spec:
ports:
- port: 3306
selector:
app: mysql
clusterIP: None
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: mysql
spec:
selector:
matchLabels:
app: mysql
strategy:
type: Recreate
template:
metadata:
labels:
app: mysql
spec:
containers:
- image: mysql:latest
name: mysql
env:
- name: MYSQL_ROOT_PASSWORD
value: password
ports:
- containerPort: 3306
name: mysql
volumeMounts:
- name: mysql-persistent-storage
mountPath: /var/lib/mysql
volumes:
- name: mysql-persistent-storage
persistentVolumeClaim:
claimName: mysql-pv-claim
26 changes: 26 additions & 0 deletions application/k8s/db-volume.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apiVersion: v1
kind: PersistentVolume
metadata:
name: mysql-pv-volume
labels:
type: local
spec:
storageClassName: manual
capacity:
storage: 1Gi
accessModes:
- ReadWriteOnce
hostPath:
path: "/mnt/data"
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mysql-pv-claim
spec:
storageClassName: manual
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
2 changes: 1 addition & 1 deletion application/k8s/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ spec:
spec:
containers:
- name: branch-deploy-application
image: dvdty/branch-deploy-application:test
image: dvdty/branch-deploy-application:latest
imagePullPolicy: "Always"
ports:
- containerPort: 80
65 changes: 65 additions & 0 deletions master/docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/bin/sh
Red='\033[0;31m' # Red
Green='\033[0;32m' # Green
echo ""
echo "***********************************************************"
echo " Starting LARAVEL PHP-FPM Container "
echo "***********************************************************"

set -e

## Check if the artisan file exists
if [ -f /var/www/html/artisan ]; then
echo "${Green} artisan file found, creating laravel supervisor config..."
##Create Laravel Scheduler process
TASK=/etc/supervisor/conf.d/laravel-worker.conf
touch $TASK
cat > "$TASK" <<EOF
[program:Laravel-scheduler]
process_name=%(program_name)s_%(process_num)02d
command=/bin/sh -c "while [ true ]; do (php /var/www/html/artisan schedule:run --verbose --no-interaction &); sleep 60; done"
autostart=true
autorestart=true
numprocs=1
user=www-data
stdout_logfile=/var/log/laravel_scheduler.out.log
redirect_stderr=true
[program:Laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/html/artisan queue:work --sleep=3 --tries=3
autostart=true
autorestart=true
numprocs=$LARAVEL_PROCS_NUMBER
user=www-data
redirect_stderr=true
stdout_logfile=/var/log/laravel_worker.log
EOF
echo "${Green} Laravel supervisor config created"
else
echo "${Red} artisan file not found"
fi

## Check if the supervisor config file exists
if [ -f /var/www/html/conf/worker/supervisor.conf ]; then
echo "additional supervisor config found"
cp /var/www/html/conf/worker/supervisor.conf /etc/supervisor/conf.d/supervisor.conf
else
echo "${Red} Supervisor.conf not found"
echo "${Green} If you want to add more supervisor configs, create config file in /var/www/html/conf/worker/supervisor.conf"
echo "${Green} Start supervisor with default config..."
fi
## Check if php.ini file exists
if [ -f /var/www/html/conf/php/php.ini ]; then
cp /var/www/html/conf/php/php.ini $PHP_INI_DIR/conf.d/
echo "Custom php.ini file found and copied in $PHP_INI_DIR/conf.d/"
else
echo "Custom php.ini file not found"
echo "If you want to add a custom php.ini file, you add it in /var/www/html/conf/php/php.ini"
fi

echo ""
echo "**********************************"
echo " Starting Supervisord... "
echo "***********************************"
supervisord -c /etc/supervisor/supervisord.conf
3 changes: 2 additions & 1 deletion master/k8s/delete-expired-deployments.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ spec:
containers:
- name: delete-expired-deployments
image: dvdty/branch-deploy-master:latest
command: ["/usr/local/bin/get-deployments-to-delete.sh"]
command: []
# ["/usr/local/bin/get-deployments-to-delete.sh"]
restartPolicy: Never
2 changes: 2 additions & 0 deletions master/routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
*/

Route::get('/', function (Request $request, Kubectl $kubectl, Github $github) {
dd($kubectl->getDeployments());

if ($request->has('branch') && $request->has('time')) {
$kubectl->createInstance($request->input('branch'), (int) $request->input('time'));
}
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes

0 comments on commit 8f470c0

Please sign in to comment.