Skip to content

Commit

Permalink
chore: enable fetching product updates from Redis
Browse files Browse the repository at this point in the history
  • Loading branch information
raphael0202 committed Dec 12, 2024
1 parent 9e4d326 commit 040e74e
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ COMPOSE_PATH_SEPARATOR=;
# dev is default target
COMPOSE_FILE=docker-compose.yml;docker/dev.yml

# for dev only: connection to local product opener network and for Product Opener redis
# in staging
COMMON_NET_NAME=po_default

SECRET_KEY=key

DEBUG=True
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/container-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ jobs:
echo "CSRF_TRUSTED_ORIGINS=https://prices.openfoodfacts.net" >> $GITHUB_ENV
# Triton server is on the same datacenter as the staging server, so we use the internal IP
echo "TRITON_URI=10.1.0.200:5504" >> $GITHUB_ENV
echo "REDIS_HOST=redis.po_webnet" >> $GITHUB_ENV
echo "REDIS_PORT=6379" >> $GITHUB_ENV
- name: Set various variable for production deployment
if: matrix.env == 'open-prices-org'
run: |
Expand All @@ -49,6 +51,8 @@ jobs:
# Triton server is on Moji datacenter, so we use the stunnel client running
# on the OVH datacenter to access it
echo "TRITON_URI=10.1.0.101:5504" >> $GITHUB_ENV
echo "REDIS_HOST=10.1.0.113" >> $GITHUB_ENV
echo "REDIS_PORT=6379" >> $GITHUB_ENV
- name: Wait for docker image container build workflow
uses: tomchv/[email protected]
id: wait-build
Expand Down Expand Up @@ -115,6 +119,10 @@ jobs:
echo "COMPOSE_PROJECT_NAME=open_prices" >> .env
echo "COMPOSE_PATH_SEPARATOR=;" >> .env
echo "COMPOSE_FILE=docker-compose.yml;docker/prod.yml" >> .env
# This is the network shared with Product Opener.
# In staging, Product Opener is deployed on the same VM.
# In production Product Opener is deployed on a separate server and is not dockerized.
echo "COMMON_NET_NAME=po_webnet" >> .env
# Set docker variables
echo "TAG=sha-${{ github.sha }}" >> .env
echo "RESTART_POLICY=always" >> .env
Expand All @@ -138,6 +146,9 @@ jobs:
echo "GOOGLE_GEMINI_API_KEY=${{ secrets.GOOGLE_GEMINI_API_KEY }}" >> .env
echo "TRITON_URI=${{ env.TRITON_URI }}" >> .env
echo "ENABLE_ML_PREDICTIONS=True" >> .env
echo "REDIS_HOST=${{ env.REDIS_HOST }}" >> .env
echo "REDIS_PORT=${{ env.REDIS_PORT }}" >> .env
echo "ENABLE_REDIS_UPDATES=True" >> .env
- name: Create Docker volumes
uses: appleboy/ssh-action@master
Expand Down
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export USER_UID:=${UID}
export DOCKER_BUILDKIT=1
export COMPOSE_DOCKER_CLI_BUILD=1
DOCKER_COMPOSE=docker compose --env-file=${ENV_FILE}
DOCKER_COMPOSE_TEST=COMPOSE_PROJECT_NAME=open_prices_test docker compose --env-file=${ENV_FILE}
DOCKER_COMPOSE_TEST=COMPOSE_PROJECT_NAME=open_prices_test COMMON_NET_NAME=po_test docker compose --env-file=${ENV_FILE}

# avoid target corresponding to file names, to depends on them
.PHONY: *
Expand Down Expand Up @@ -152,6 +152,12 @@ create_external_volumes:
docker volume create open_prices_images
docker volume create open_prices_data-dump

create_external_networks:
@echo "🥫 Creating external networks if needed … (dev only)"
( docker network create ${COMMON_NET_NAME} || true )
# for tests
( docker network create po_test || true )

cp-static-files:
@echo "🥫 Copying static files from api container to the host …"
docker cp open_prices-api-1:/opt/open-prices/static www/
Expand Down
11 changes: 11 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ x-api-common: &api-common
- REDIS_LATEST_ID_KEY
networks:
- default
- common_net

services:
api:
Expand Down Expand Up @@ -97,3 +98,13 @@ volumes:
name: ${COMPOSE_PROJECT_NAME:-open_prices}_home_cache
static:
name: ${COMPOSE_PROJECT_NAME:-open_prices}_static


networks:
default:
name: ${COMPOSE_PROJECT_NAME:-open_prices}_default

# this is the network shared with product opener, it's only used in staging (and locally)
common_net:
name: ${COMMON_NET_NAME}
external: true
6 changes: 6 additions & 0 deletions docker/prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@ volumes:
data-dump:
external: true
name: ${COMPOSE_PROJECT_NAME:-open_prices}_data-dump


networks:
common_net:
name: ${COMMON_NET_NAME}
external: true

0 comments on commit 040e74e

Please sign in to comment.