-
-
Notifications
You must be signed in to change notification settings - Fork 400
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
+ add helper script
- Loading branch information
Showing
2 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` | ||
1. restart services | ||
```bash | ||
sudo systemctl daemon-reload | ||
sudo systemctl restart nginx apache2 | ||
sudo systemctl restart cloud_vision_ocr@$SERVICE.service | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |