Skip to content

Commit

Permalink
Merge branch 'main' into chore-two-apache
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgarel committed Jan 10, 2025
2 parents a5d3a6a + d996a33 commit 2ee8cf4
Show file tree
Hide file tree
Showing 108 changed files with 2,178 additions and 945 deletions.
14 changes: 13 additions & 1 deletion .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,20 @@ jobs:
# see https://stackoverflow.com/a/60984318/2886726
run: |
git ls-files taxonomies/ | xargs -I{} git log -1 --date=format:%Y%m%d%H%M.%S --format='touch -t %ad "{}"' "{}" | bash
- name: Rebuild taxonomies
- name: Rebuild taxonomies for Open Food Facts (off)
run: make DOCKER_LOCAL_DATA="$(pwd)" build_taxonomies GITHUB_TOKEN="${{ secrets.TAXONOMY_CACHE_GITHUB_TOKEN }}"
- name: Rebuild taxonomies for Open Beauty Facts (obf)
run: |
source env/setenv.sh obf
make DOCKER_LOCAL_DATA="$(pwd)" build_taxonomies GITHUB_TOKEN="${{ secrets.TAXONOMY_CACHE_GITHUB_TOKEN }}"
- name: Rebuild taxonomies for Open Products Facts (opf)
run: |
source env/setenv.sh opf
make DOCKER_LOCAL_DATA="$(pwd)" build_taxonomies GITHUB_TOKEN="${{ secrets.TAXONOMY_CACHE_GITHUB_TOKEN }}"
- name: Rebuild taxonomies for Open Pet Food Facts (opff)
run: |
source env/setenv.sh opff
make DOCKER_LOCAL_DATA="$(pwd)" build_taxonomies GITHUB_TOKEN="${{ secrets.TAXONOMY_CACHE_GITHUB_TOKEN }}"
check_perl:
name: 🐪 Check Perl
Expand Down
2 changes: 1 addition & 1 deletion cgi/display_org_table.pl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
display_error_and_exit($request_ref, $Lang{error_no_permission}{$lc}, 401);
}

if ((not $request_ref->{admin}) or (not $User{pro_moderator})) {
if ((not $request_ref->{admin}) and (not $User{pro_moderator})) {
$log->debug("user does not have permission to view organisation list", {User_id => $User_id}) if $log->is_debug();
display_error_and_exit($request_ref, $Lang{error_no_permission}{$lc}, 403);
}
Expand Down
4 changes: 4 additions & 0 deletions conf/nginx/snippets/off.locations-redirects.include
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ location = /nutriscore-v2 {
return 301 https://$host/new-nutriscore;
}

location ~ ^/(greenscore|ecoscore|eco-score-l-impact-environnemental-des-produits-alimentaires|eco-score-the-environmental-impact-of-food-products)$ {
return 301 https://$host/green-score;
}

# Donations
# 100 % translated: fr, bg, ca, zh, cs, da, nl, de, he, id, it, lt, pl, pt, ro, ru, es, tr, uk, vi
# EN
Expand Down
22 changes: 0 additions & 22 deletions docs/dev/how-to-deploy.md

This file was deleted.

55 changes: 55 additions & 0 deletions docs/dev/how-to-release.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# 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. verify every needed symlink is in place
```bash
sudo -u off scripts/deploy/verify-deployment.sh $SERVICE
```
1. rebuild taxonomies and lang
```bash
sudo -u off bash
cd /srv/$SERVICE
source env/setenv.sh $SERVICE
./scripts/taxonomies/build_tags_taxonomy.pl
./scripts/build_lang.pl
```
1. update the frontend assets you just downloaded
```bash
sudo -u off /srv/$SERVICE/scripts/deploy/install-dist-files.sh $VERSION $SERVICE
```
1. restart services
```bash
sudo systemctl daemon-reload
sudo systemctl restart nginx
sudo systemctl stop apache2 cloud_vision_ocr@$SERVICE.service minion@$SERVICE.service
sudo systemctl start apache2 cloud_vision_ocr@$SERVICE.service minion@$SERVICE.service
```
8 changes: 7 additions & 1 deletion env/setenv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,17 @@ MINION_QUEUE=
# Load environment variables from env file
source env/env.$1

# Set a variable that we use in Makefile to add an extra env file
# Set a variable that we use in Makefile to add an extra env file
# in addition to .env when we run docker compose
EXTRA_ENV_FILE=env/env.$1
LOAD_EXTRA_ENV_FILE=--env-file=env/env.$1

# eventually add lib for prod environment
if [[ -d /srv/$1/lib ]]
then
PERL5LIB=/srv/$1/lib
fi

set +o allexport

# add (env) to the prompt
Expand Down
67 changes: 59 additions & 8 deletions gulpfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { init, write } from "gulp-sourcemaps";

import concat from "gulp-concat";
import gulpSass from "gulp-sass";
import gzip from "gulp-gzip";
import minifyCSS from "gulp-csso";
import sassLib from "sass";
import svgmin from "gulp-svgmin";
Expand All @@ -23,27 +24,41 @@ const sassSrc = "./scss/**/*.scss";

const imagesSrc = ["./node_modules/leaflet/dist/**/*.png"];

// nginx needs both uncompressed and compressed files as we use try_files with gzip_static always & gunzip

export function icons() {
return src("*.svg", { cwd: "./icons" }).
const processed = src("*.svg", { cwd: "./icons" }).
pipe(
svgmin({
// @ts-ignore
configFile: "icons/svgo.config.js",
})
).
pipe(dest("./html/images/icons/dist"));

const compressed = processed.
pipe(gzip()).
pipe(dest("./html/images/icons/dist"));

return processed && compressed;
}

export function attributesIcons() {
return src("*.svg", { cwd: "./html/images/attributes/src" }).
const processed = src("*.svg", { cwd: "./html/images/attributes/src" }).
pipe(svgmin()).
pipe(dest("./html/images/attributes/dist"));

const compressed = processed.
pipe(gzip()).
pipe(dest("./html/images/attributes/dist"));

return processed && compressed;
}

export function css() {
console.log("(re)building css");

return src(sassSrc).
const processed = src(sassSrc).
pipe(init()).
pipe(
sass({
Expand All @@ -55,10 +70,16 @@ export function css() {
pipe(minifyCSS()).
pipe(write(".")).
pipe(dest("./html/css/dist"));

const compressed = processed.
pipe(gzip()).
pipe(dest("./html/css/dist"));

return processed && compressed;
}

export function copyJs() {
return src([
const processed = src([
"./node_modules/@webcomponents/**/webcomponentsjs/**/*.js",
"./node_modules/foundation-sites/js/vendor/*.js",
"./node_modules/foundation-sites/js/foundation.js",
Expand All @@ -84,20 +105,32 @@ export function copyJs() {
pipe(terser()).
pipe(write(".")).
pipe(dest("./html/js/dist"));

const compressed = processed.
pipe(gzip()).
pipe(dest("./html/js/dist"));

return processed && compressed;
}

export function buildJs() {
console.log("(re)building js");

return src(jsSrc).
const processed = src(jsSrc).
pipe(init()).
pipe(terser()).
pipe(write(".")).
pipe(dest("./html/js/dist"));

const compressed = processed.
pipe(gzip()).
pipe(dest("./html/js/dist"));

return processed && compressed;
}

function buildjQueryUi() {
return src([
const processed = src([
"./node_modules/jquery-ui/ui/jquery-patch.js",
"./node_modules/jquery-ui/ui/version.js",
"./node_modules/jquery-ui/ui/widget.js",
Expand All @@ -113,10 +146,16 @@ function buildjQueryUi() {
pipe(concat("jquery-ui.js")).
pipe(write(".")).
pipe(dest("./html/js/dist"));

const compressed = processed.
pipe(gzip()).
pipe(dest("./html/js/dist"));

return processed && compressed;
}

function jQueryUiThemes() {
return src([
const processed = src([
"./node_modules/jquery-ui/themes/base/core.css",
"./node_modules/jquery-ui/themes/base/autocomplete.css",
"./node_modules/jquery-ui/themes/base/menu.css",
Expand All @@ -127,10 +166,16 @@ function jQueryUiThemes() {
pipe(concat("jquery-ui.css")).
pipe(write(".")).
pipe(dest("./html/css/dist/jqueryui/themes/base"));

const compressed = processed.
pipe(gzip()).
pipe(dest("./html/css/dist/jqueryui/themes/base"));

return processed && compressed;
}

function copyCss() {
return src([
const processed = src([
"./node_modules/leaflet/dist/leaflet.css",
"./node_modules/leaflet.markercluster/dist/MarkerCluster.css",
"./node_modules/leaflet.markercluster/dist/MarkerCluster.Default.css",
Expand All @@ -142,6 +187,12 @@ function copyCss() {
pipe(minifyCSS()).
pipe(write(".")).
pipe(dest("./html/css/dist"));

const compressed = processed.
pipe(gzip()).
pipe(dest("./html/css/dist"));

return processed && compressed;
}

function copyImages() {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion html/images/attributes/src/nutriscore-unknown-new-de.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion html/images/attributes/src/nutriscore-unknown-new-en.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion html/images/attributes/src/nutriscore-unknown-new-fr.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion html/images/attributes/src/nutriscore-unknown-new-lb.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion html/images/attributes/src/nutriscore-unknown-new-nl.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 2ee8cf4

Please sign in to comment.