Skip to content

Commit

Permalink
chore: Production test 1
Browse files Browse the repository at this point in the history
chore: Production test 1
  • Loading branch information
DestroyCom committed Sep 2, 2023
2 parents 3bb6cd7 + 900672e commit 4b7151f
Show file tree
Hide file tree
Showing 215 changed files with 26,295 additions and 3,683 deletions.
Binary file added .DS_Store
Binary file not shown.
19 changes: 19 additions & 0 deletions .github/workflows/build_server_image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Build the server image

on: workflow_call

jobs:
build_server:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Kaniko build
uses: aevea/action-kaniko@master
with:
image: destcom/sera-server
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
tag: ${{ github.ref_name }}
tag_with_latest: true
path: ./sera-back/docker/
build_file: ./prod.Dockerfile
19 changes: 19 additions & 0 deletions .github/workflows/build_web_image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Build the webapp image

on: workflow_call

jobs:
build_server:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Kaniko build
uses: aevea/action-kaniko@master
with:
image: destcom/sera-web
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
tag: ${{ github.sha }}
tag_with_latest: true
path: ./sera-front/
build_file: ./prod.Dockerfile
14 changes: 14 additions & 0 deletions .github/workflows/create_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Create a release

on: workflow_call

jobs:
launch_release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Release
uses: softprops/action-gh-release@v1
with:
generate_release_notes: true
104 changes: 45 additions & 59 deletions .github/workflows/deploy_develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,20 @@ on:
push:
branches:
- develop

#- SERA-58
workflow_dispatch:

jobs:
cleaning:
uses: ./.github/workflows/rebuild-containers.yml

deploy:
runs-on: self-hosted
needs: cleaning

steps:
- name: Check if the previous containers exists
run: |
if [ "$(docker ps -a -q --filter "name=sera" | wc -l)" -gt 0 ]
then
echo "Previous containers found, stopping and removing them..."
else
echo "No previous containers found, continuing..."
fi
- name: Stop the previous containers
run: |
if [ "$(docker ps -a -q --filter "name=sera" | wc -l)" -gt 0 ]
then
docker stop $(docker ps -a -q --filter "name=sera")
fi
- name: Remove the previous containers
run: |
if [ "$(docker ps -a -q --filter "name=sera" | wc -l)" -gt 0 ]
then
docker rm $(docker ps -a -q --filter "name=sera")
fi
- name: DEBUG - Display current directory
run: |
pwd
ls -la
- name: Deletes the files inside the current directory
run: |
rm -rf ./*
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0
clean: false
Expand All @@ -53,6 +27,7 @@ jobs:
run: |
echo "${{ secrets.DEVELOP_ROOT_ENV_FILE }}" > .env
echo "${{ secrets.DEVELOP_LARAVEL_ENV_FILE }}" > sera-back/.env
echo "${{ secrets.DEVELOP_FRONT_ENV_FILE }}" > sera-front/.env
- name: Copy .env file if not exists
run: |
Expand All @@ -79,13 +54,14 @@ jobs:
exit 1
fi
- name: DEBUG - Displaying the current directory && path
run: |
pwd
ls -la
find . -name composer.json
ls -la sera-back
ls -la sera-front
#- name: Check if the front does not have lint errors
#run: |
#docker run --rm \
#-u "$(id -u):$(id -g)" \
#-v $(pwd)/sera-front:/opt \
#-w /opt \
#node:lts \
#npm install && npm run lint-autofix

- name: Execute composer install
run: |
Expand All @@ -96,31 +72,41 @@ jobs:
laravelsail/php81-composer \
composer install --ignore-platform-reqs
- name: Check if sail folder exists
run: |
if [ ! -d ./sera-back/vendor/laravel/sail ]
then
echo "sail folder not found, exiting..."
exit ;
fi
- name: Launch the containers
run: |
./sera-back/vendor/laravel/sail/bin/sail -f ./develop.docker-compose.yml up -d --build --force-recreate
docker-compose -f ./develop.docker-compose.yml up -d --build
- name: Wait till all containers has started
run: |
sleep 2m
sleep 30
- name: Migrate the database
- name: Permissions steps
run: |
if [ "${1}" = "reset" ]
then
./sera-back/vendor/laravel/sail/bin/sail artisan migrate:refresh --seed
else
./sera-back/vendor/laravel/sail/bin/sail artisan migrate
fi
sudo chmod -R 777 ./sera-back/storage
sudo chmod -R 777 ./sera-back/artisan
- name: Configure laravel
run: |
docker exec develop-sera-back-laravel-test php artisan cache:clear
docker exec develop-sera-back-laravel-test php artisan config:clear
docker exec develop-sera-back-laravel-test php artisan route:clear
docker exec develop-sera-back-laravel-test php artisan key:generate
docker exec develop-sera-back-laravel-test php artisan config:cache
docker exec develop-sera-back-laravel-test php artisan route:cache
docker exec develop-sera-back-laravel-test php artisan view:cache
docker exec develop-sera-back-laravel-test php artisan optimize
docker exec develop-sera-back-laravel-test php artisan storage:link
docker exec develop-sera-back-laravel-test php artisan l5-swagger:generate
- name: Run migrations$
# get all my env from secrets.DEVELOP_LARAVEL_ENV_FILE

run: |
sleep 10
docker exec develop-sera-back-laravel-test php artisan config:cache
docker exec develop-sera-back-laravel-test php artisan config:clear
docker exec develop-sera-back-laravel-test php artisan migrate:fresh --seed --force
- name: Displaying that it's done
run: |
echo "Done"
echo "Done"
27 changes: 27 additions & 0 deletions .github/workflows/deploy_prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Deploy in production

on:
push:
branches:
- prod
workflow_dispatch:

jobs:
build_server:
uses: ./.github/workflows/build_server_image.yml
build_webapp:
needs: build_server
uses: ./.github/workflows/build_web_image.yml
deploy_release:
needs: build_webapp
uses: ./.github/workflows/create_release.yml
notify:
needs: deploy_release
runs-on: ubuntu-latest
steps:
- name: Notify production build & published
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
uses: Ilshidur/action-discord@master
with:
args: "A new release just been created on SERA, images pushed to dockerhub."
35 changes: 35 additions & 0 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Linting

on:
pull_request:
types: [opened, synchronize, reopened]
#push:
#branches:
#- develop
#workflow_call:

jobs:
lint:
runs-on: lint

steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
clean: false
ref: ${{ github.event.inputs.ref }}

- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: lts/*

- name: Install dependencies
working-directory: ./sera-front
run: npm ci

- name: Verify & autofix linting errors if needed
working-directory: ./sera-front
run: |
npm run lint-autofix
46 changes: 46 additions & 0 deletions .github/workflows/rebuild-containers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Rebuilding containers

on: workflow_call
jobs:
cleaning:
runs-on: self-hosted

steps:
- name: Detect and delete front container
run: |
if [ "$(docker ps -a -q --filter "name=front" | wc -l)" -gt 0 ]
then
echo "Previous containers found, stopping and removing them..."
docker stop $(docker ps -a -q --filter "name=front")
docker rm $(docker ps -a -q --filter "name=front")
else
echo "No previous containers found, continuing..."
fi
- name: Detect and delete back container
run: |
if [ "$(docker ps -a -q --filter "name=back-laravel" | wc -l)" -gt 0 ]
then
echo "Previous containers found, stopping and removing them..."
docker stop $(docker ps -a -q --filter "name=back-laravel")
docker rm $(docker ps -a -q --filter "name=back-laravel")
else
echo "No previous containers found, continuing..."
fi
- name: Detect and delete aditionnal container
run: |
if [ "$(docker ps -a -q --filter "name=back-soketi" | wc -l)" -gt 0 ]
then
echo "Previous containers found, stopping and removing them..."
docker stop $(docker ps -a -q --filter "name=back-soketi")
docker rm $(docker ps -a -q --filter "name=back-soketi")
else
echo "No previous containers found, continuing..."
fi
if [ "$(docker ps -a -q --filter "name=back-redis" | wc -l)" -gt 0 ]
then
echo "Previous containers found, stopping and removing them..."
docker stop $(docker ps -a -q --filter "name=back-redis")
docker rm $(docker ps -a -q --filter "name=back-redis")
else
echo "No previous containers found, continuing..."
fi
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ yarn-error.log
/.fleet
/.idea
/.vscode
old-*
8 changes: 8 additions & 0 deletions .hintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": [
"development"
],
"hints": {
"typescript-config/is-valid": "off"
}
}
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
First installation

```bash
./dev.sh
sh dev.sh
```

Start
Start 😋😛😛

```bash
./sera-back/vendor/bin/sail up -d
```

🕺🕺🕺🕺🕺🕺🕺🕺🕺🕺
29 changes: 21 additions & 8 deletions dev.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ if [ ! -f ./.env ]
then
cp .env.example .env
cp sera-back/.env.example sera-back/.env
chmod 755 sera-back/.env
cp sera-front/.env.example sera-front/.env
chmod 755 ./sera-back/.env
chmod 755 ./sera-front/.env
chmod 755 .env
echo ".env file is not found, copying from .env.example, waiting for 5 seconds..."
sleep 5
Expand All @@ -31,15 +33,26 @@ then
fi

echo "--- launch docker container ---"
./sera-back/vendor/laravel/sail/bin/sail up -d --build --force-recreate
./sera-back/vendor/bin/sail up -d --build --force-recreate

./sera-back/vendor/bin/sail artisan key:generate

# On remove le cache de toutes les configurations, des routes, des api, etc.
./sera-back/vendor/bin/sail artisan config:clear
./sera-back/vendor/bin/sail artisan route:clear

#Storage link
./sera-back/vendor/bin/sail artisan storage:link

#Generate l5-swagger
./sera-back/vendor/bin/sail artisan l5-swagger:generate

echo "--- wait for 10 seconds ---"
sleep 10

echo "--- migrate database ---"
if [ "${1}" = "reset" ]
then
./sera-back/vendor/laravel/sail/bin/sail artisan migrate:refresh --seed
else
./sera-back/vendor/laravel/sail/bin/sail artisan migrate
fi
./sera-back/vendor/bin/sail artisan migrate:fresh --seed


echo "--- done ---"
echo "visit http://localhost"
Loading

0 comments on commit 4b7151f

Please sign in to comment.