diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 54d5221e..8d5c7840 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,6 +17,16 @@ jobs: uses: actions/setup-python@v1 with: 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 run: | python -m pip install --upgrade pip diff --git a/.github/workflows/docker-publish-beta.yml b/.github/workflows/docker-publish-beta.yml index 015c0790..426531dd 100644 --- a/.github/workflows/docker-publish-beta.yml +++ b/.github/workflows/docker-publish-beta.yml @@ -9,6 +9,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@master + # Update Version number - name: Update version file uses: DamianReeves/write-file-action@v1.0 with: @@ -17,12 +18,17 @@ jobs: VERSION_NUMBER = 'beta' BUILD_REF = '${{ github.sha }}' write-mode: overwrite - - uses: borales/actions-yarn@v2.3.0 + # Build Vue frontend + - uses: actions/setup-node@v2 with: - cmd: install - - uses: borales/actions-yarn@v2.3.0 - with: - cmd: build + node-version: '14' + - name: Install dependencies + working-directory: ./vue + run: yarn install + - name: Build dependencies + working-directory: ./vue + run: yarn build + # Build container - name: Build and publish image uses: ilteoood/docker_buildx@master with: @@ -31,9 +37,10 @@ jobs: tag: beta dockerHubUser: ${{ secrets.DOCKER_USERNAME }} dockerHubPassword: ${{ secrets.DOCKER_PASSWORD }} + # Send discord notification - name: Discord notification env: DISCORD_WEBHOOK: ${{ secrets.DISCORD_BETA_WEBHOOK }} uses: Ilshidur/action-discord@0.3.2 with: - args: 'The BETA Image has been updated!' \ No newline at end of file + args: '🚀 The BETA Image has been updated! 🥳' \ No newline at end of file diff --git a/.github/workflows/docker-publish-dev.yml b/.github/workflows/docker-publish-dev.yml index 77bd23d6..4598b035 100644 --- a/.github/workflows/docker-publish-dev.yml +++ b/.github/workflows/docker-publish-dev.yml @@ -11,6 +11,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@master + # Update Version number - name: Update version file uses: DamianReeves/write-file-action@v1.0 with: @@ -19,6 +20,7 @@ jobs: VERSION_NUMBER = 'develop' BUILD_REF = '${{ github.sha }}' write-mode: overwrite + # Build Vue frontend - uses: actions/setup-node@v2 with: node-version: '14' @@ -28,6 +30,7 @@ jobs: - name: Build dependencies working-directory: ./vue run: yarn build + # Build container - name: Publish to Registry uses: elgohr/Publish-Docker-Github-Action@2.13 with: diff --git a/.github/workflows/docker-publish-latest.yml b/.github/workflows/docker-publish-latest.yml index 09ba9dd0..13b5c18a 100644 --- a/.github/workflows/docker-publish-latest.yml +++ b/.github/workflows/docker-publish-latest.yml @@ -13,6 +13,7 @@ jobs: - name: Get version number id: get_version run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} + # Update Version number - name: Update version file uses: DamianReeves/write-file-action@v1.0 with: @@ -21,12 +22,17 @@ jobs: VERSION_NUMBER = '${{ steps.get_version.outputs.VERSION }}' BUILD_REF = '${{ github.sha }}' write-mode: overwrite - - uses: borales/actions-yarn@v2.3.0 + # Build Vue frontend + - uses: actions/setup-node@v2 with: - cmd: install - - uses: borales/actions-yarn@v2.3.0 - with: - cmd: build + node-version: '14' + - name: Install dependencies + working-directory: ./vue + run: yarn install + - name: Build dependencies + working-directory: ./vue + run: yarn build + # Build container - name: Build and publish image uses: ilteoood/docker_buildx@master with: diff --git a/.github/workflows/docker-publish-release.yml b/.github/workflows/docker-publish-release.yml index c4145a9c..0d0b60b1 100644 --- a/.github/workflows/docker-publish-release.yml +++ b/.github/workflows/docker-publish-release.yml @@ -16,6 +16,7 @@ jobs: - name: Get version number id: get_version run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} + # Update Version number - name: Update version file uses: DamianReeves/write-file-action@v1.0 with: @@ -24,12 +25,17 @@ jobs: VERSION_NUMBER = '${{ steps.get_version.outputs.VERSION }}' BUILD_REF = '${{ github.sha }}' write-mode: overwrite - - uses: borales/actions-yarn@v2.3.0 + # Build Vue frontend + - uses: actions/setup-node@v2 with: - cmd: install - - uses: borales/actions-yarn@v2.3.0 - with: - cmd: build + node-version: '14' + - name: Install dependencies + working-directory: ./vue + run: yarn install + - name: Build dependencies + working-directory: ./vue + run: yarn build + # Build container - name: Build and publish image uses: ilteoood/docker_buildx@master with: @@ -38,6 +44,7 @@ jobs: tag: ${{ steps.get_version.outputs.VERSION }} dockerHubUser: ${{ secrets.DOCKER_USERNAME }} dockerHubPassword: ${{ secrets.DOCKER_PASSWORD }} + # Send discord notification - name: Discord notification env: DISCORD_WEBHOOK: ${{ secrets.DISCORD_RELEASE_WEBHOOK }} diff --git a/docs/install/manual.md b/docs/install/manual.md index 5355f72b..3cbecf82 100644 --- a/docs/install/manual.md +++ b/docs/install/manual.md @@ -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` +Install Javascript Tools +```shell +apt install nodejs +npm install --global yarn +``` + ### Install postgresql requirements `sudo apt install libpq-dev postgresql` ###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: `/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 @@ -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;` -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 @@ -137,3 +153,25 @@ server { *Note*: Enter the correct path in static and proxy_pass lines. 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 +```