updated build files

This commit is contained in:
vabene1111 2021-10-13 11:20:26 +02:00
parent 139afcd333
commit 5858283cdd
6 changed files with 88 additions and 17 deletions

View File

@ -17,6 +17,16 @@ jobs:
uses: actions/setup-python@v1 uses: actions/setup-python@v1
with: with:
python-version: 3.9 python-version: 3.9
# Build Vue frontend
- uses: actions/setup-node@v2
with:
node-version: '14'
- name: Install dependencies
working-directory: ./vue
run: yarn install
- name: Build dependencies
working-directory: ./vue
run: yarn build
- name: Install dependencies - name: Install dependencies
run: | run: |
python -m pip install --upgrade pip python -m pip install --upgrade pip

View File

@ -9,6 +9,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@master - uses: actions/checkout@master
# Update Version number
- name: Update version file - name: Update version file
uses: DamianReeves/write-file-action@v1.0 uses: DamianReeves/write-file-action@v1.0
with: with:
@ -17,12 +18,17 @@ jobs:
VERSION_NUMBER = 'beta' VERSION_NUMBER = 'beta'
BUILD_REF = '${{ github.sha }}' BUILD_REF = '${{ github.sha }}'
write-mode: overwrite write-mode: overwrite
- uses: borales/actions-yarn@v2.3.0 # Build Vue frontend
- uses: actions/setup-node@v2
with: with:
cmd: install node-version: '14'
- uses: borales/actions-yarn@v2.3.0 - name: Install dependencies
with: working-directory: ./vue
cmd: build run: yarn install
- name: Build dependencies
working-directory: ./vue
run: yarn build
# Build container
- name: Build and publish image - name: Build and publish image
uses: ilteoood/docker_buildx@master uses: ilteoood/docker_buildx@master
with: with:
@ -31,9 +37,10 @@ jobs:
tag: beta tag: beta
dockerHubUser: ${{ secrets.DOCKER_USERNAME }} dockerHubUser: ${{ secrets.DOCKER_USERNAME }}
dockerHubPassword: ${{ secrets.DOCKER_PASSWORD }} dockerHubPassword: ${{ secrets.DOCKER_PASSWORD }}
# Send discord notification
- name: Discord notification - name: Discord notification
env: env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_BETA_WEBHOOK }} DISCORD_WEBHOOK: ${{ secrets.DISCORD_BETA_WEBHOOK }}
uses: Ilshidur/action-discord@0.3.2 uses: Ilshidur/action-discord@0.3.2
with: with:
args: 'The BETA Image has been updated!' args: '🚀 The BETA Image has been updated! 🥳'

View File

@ -11,6 +11,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@master - uses: actions/checkout@master
# Update Version number
- name: Update version file - name: Update version file
uses: DamianReeves/write-file-action@v1.0 uses: DamianReeves/write-file-action@v1.0
with: with:
@ -19,6 +20,7 @@ jobs:
VERSION_NUMBER = 'develop' VERSION_NUMBER = 'develop'
BUILD_REF = '${{ github.sha }}' BUILD_REF = '${{ github.sha }}'
write-mode: overwrite write-mode: overwrite
# Build Vue frontend
- uses: actions/setup-node@v2 - uses: actions/setup-node@v2
with: with:
node-version: '14' node-version: '14'
@ -28,6 +30,7 @@ jobs:
- name: Build dependencies - name: Build dependencies
working-directory: ./vue working-directory: ./vue
run: yarn build run: yarn build
# Build container
- name: Publish to Registry - name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@2.13 uses: elgohr/Publish-Docker-Github-Action@2.13
with: with:

View File

@ -13,6 +13,7 @@ jobs:
- name: Get version number - name: Get version number
id: get_version id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
# Update Version number
- name: Update version file - name: Update version file
uses: DamianReeves/write-file-action@v1.0 uses: DamianReeves/write-file-action@v1.0
with: with:
@ -21,12 +22,17 @@ jobs:
VERSION_NUMBER = '${{ steps.get_version.outputs.VERSION }}' VERSION_NUMBER = '${{ steps.get_version.outputs.VERSION }}'
BUILD_REF = '${{ github.sha }}' BUILD_REF = '${{ github.sha }}'
write-mode: overwrite write-mode: overwrite
- uses: borales/actions-yarn@v2.3.0 # Build Vue frontend
- uses: actions/setup-node@v2
with: with:
cmd: install node-version: '14'
- uses: borales/actions-yarn@v2.3.0 - name: Install dependencies
with: working-directory: ./vue
cmd: build run: yarn install
- name: Build dependencies
working-directory: ./vue
run: yarn build
# Build container
- name: Build and publish image - name: Build and publish image
uses: ilteoood/docker_buildx@master uses: ilteoood/docker_buildx@master
with: with:

View File

@ -16,6 +16,7 @@ jobs:
- name: Get version number - name: Get version number
id: get_version id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
# Update Version number
- name: Update version file - name: Update version file
uses: DamianReeves/write-file-action@v1.0 uses: DamianReeves/write-file-action@v1.0
with: with:
@ -24,12 +25,17 @@ jobs:
VERSION_NUMBER = '${{ steps.get_version.outputs.VERSION }}' VERSION_NUMBER = '${{ steps.get_version.outputs.VERSION }}'
BUILD_REF = '${{ github.sha }}' BUILD_REF = '${{ github.sha }}'
write-mode: overwrite write-mode: overwrite
- uses: borales/actions-yarn@v2.3.0 # Build Vue frontend
- uses: actions/setup-node@v2
with: with:
cmd: install node-version: '14'
- uses: borales/actions-yarn@v2.3.0 - name: Install dependencies
with: working-directory: ./vue
cmd: build run: yarn install
- name: Build dependencies
working-directory: ./vue
run: yarn build
# Build container
- name: Build and publish image - name: Build and publish image
uses: ilteoood/docker_buildx@master uses: ilteoood/docker_buildx@master
with: with:
@ -38,6 +44,7 @@ jobs:
tag: ${{ steps.get_version.outputs.VERSION }} tag: ${{ steps.get_version.outputs.VERSION }}
dockerHubUser: ${{ secrets.DOCKER_USERNAME }} dockerHubUser: ${{ secrets.DOCKER_USERNAME }}
dockerHubPassword: ${{ secrets.DOCKER_PASSWORD }} dockerHubPassword: ${{ secrets.DOCKER_PASSWORD }}
# Send discord notification
- name: Discord notification - name: Discord notification
env: env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_RELEASE_WEBHOOK }} DISCORD_WEBHOOK: ${{ secrets.DISCORD_RELEASE_WEBHOOK }}

View File

@ -19,16 +19,32 @@ Give the user permissions: `chown -R recipes:www-data /var/www/recipes`
Create virtual env: `python3.9 -m venv /var/www/recipes` Create virtual env: `python3.9 -m venv /var/www/recipes`
Install Javascript Tools
```shell
apt install nodejs
npm install --global yarn
```
### Install postgresql requirements ### Install postgresql requirements
`sudo apt install libpq-dev postgresql` `sudo apt install libpq-dev postgresql`
###Install project requirements ###Install project requirements
!!! warning "Update"
Dependencies change with most updates so the following steps need to be re-run with every update or else the application might stop working.
See section **Updating** below
Using binaries from the virtual env: Using binaries from the virtual env:
`/var/www/recipes/bin/pip3.9 install -r requirements.txt` `/var/www/recipes/bin/pip3.9 install -r requirements.txt`
You will also need to install front end requirements and build them. For this navigate to the `./vue`folder and run
```shell
yarn install
yarn build
```
## Setup postgresql ## Setup postgresql
@ -70,7 +86,7 @@ Execute `bin/python3.9 manage.py migrate`
and revert superuser from postgres: `sudo -u postgres psql` and `ALTER USER djangouser WITH NOSUPERUSER;` and revert superuser from postgres: `sudo -u postgres psql` and `ALTER USER djangouser WITH NOSUPERUSER;`
Generate static files: `bin/python3.9 manage.py collectstatic` and remember the folder where files have been copied. Generate static files: `bin/python3.9 manage.py collectstatic` and `bin/python3.9 manage.py collectstatic_js_reverse` and remember the folder where files have been copied.
## Setup web services ## Setup web services
@ -137,3 +153,25 @@ server {
*Note*: Enter the correct path in static and proxy_pass lines. *Note*: Enter the correct path in static and proxy_pass lines.
Reload nginx : `sudo systemctl reload nginx` Reload nginx : `sudo systemctl reload nginx`
# Updating
In order to update the application you will need to run the following commands (probably best to put them into a small script).
```shell
# Update source files
git pull
# load envirtonment variables
export $(cat /var/www/recipes/.env |grep "^[^#]" | xargs)
# migrate database
bin/python3.9 manage.py migrate
# collect static files
bin/python3.9 manage.py collectstatic
bin/python3.9 manage.py collectstatic_js_reverse
# change to frontend directory
cd vue
# install and build frontend
yarn install
yarn build
# restart gunicorn service
sudo systemctl restart gunicorn_recipes
```