Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: document release process #11210

Merged
merged 5 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions docs/dev/how-to-release.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# How to release

## Staging environment

This is automatically done by the CI of github,
see `.github/workflows/container-build.yml`.

The deployment uses docker compose with specific environments variables
and the `docker/prod.yml` overlay.

As soon as you merge a pull request in the `main` branch,
the action is triggered. You can see it at
https://github.com/openfoodfacts/openfoodfacts-server/actions/workflows/container-build.yml

## Production environment

Product Opener is deployed on a container in Proxmox.
The container is a debian server, it must follow the `backend` container version.

In the command lines, I use $SERVICE and $VERSION variables,
corresponding to the service short name (off, opf, etc.) and the version tag.

To deploy you need to execute the following steps:
1. merge the Release Please pull request.
This will create a new release / version tag on github
1. update the code:
```bash
sudo -u off bash
cd /srv/$SERVICE
git fetch
git checkout $VERSION
```
1. update the frontend assets you just downloaded
```bash
sudo -u off /srv/$SERVICE/scripts/deploy/install-dist-files.sh
```
alexgarel marked this conversation as resolved.
Show resolved Hide resolved
1. restart services
```bash
sudo systemctl daemon-reload
sudo systemctl restart nginx apache2
alexgarel marked this conversation as resolved.
Show resolved Hide resolved
sudo systemctl restart cloud_vision_ocr@$SERVICE.service
```
47 changes: 47 additions & 0 deletions scripts/deploy/install-dist-files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env bash

# this script is a helper for deployment
# it downloads the assets for a version and extracts them
# It must be followed by install-dist-files.sh which will install files


# fail on error
set -e

if [[ -z "$1" ]]
then
echo "Usage: $0 <version> [<instance short name>]"
echo "ex: $0 v2.53.0 off"
echo "If <instance short name> is not provided, it will be the server name"
exit 2
fi

VERSION=$1

if [[ -n $2 ]]
then
SERVICE=$2
else
SERVICE=$(hostname)
fi

if [[ $(whoami) != off ]]
then
echo "This script must be run as the off user"
exit 3
fi

echo "Downloading dist files $VERSION for $SERVICE"
# get archive and untar
curl --fail --location https://github.com/openfoodfacts/openfoodfacts-server/releases/download/$VERSION/frontend-dist.tgz -o /tmp/frontend-dist.tgz
rm -rf /srv/$SERVICE-dist/tmp/$VERSION || true
mkdir -p /srv/$SERVICE-dist/tmp/$VERSION
tar --directory=/srv/$SERVICE-dist/tmp/$VERSION -xzf /tmp/frontend-dist.tgz
# remove old files
rm -rf /srv/$SERVICE-dist/tmp/old || true
mkdir /srv/$SERVICE-dist/tmp/old
# swap current version and old version
shopt -s extglob # extended globbing
mv /srv/$SERVICE-dist/!(tmp) /srv/$SERVICE-dist/tmp/old
mv /srv/$SERVICE-dist/tmp/$VERSION/* /srv/$SERVICE-dist/
rmdir /srv/$SERVICE-dist/tmp/$VERSION
Loading