Skip to content

Commit

Permalink
chore: fix deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
raphael0202 committed Nov 16, 2023
1 parent 7c5e460 commit 0722ee3
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ POSTGRES_PASSWORD=postgres
# Host is postgres, as we're using docker and the service name is "postgres"
POSTGRES_HOST=postgres
POSTGRES_PORT=5432

POSTGRES_EXPOSE=127.0.0.1:5433
9 changes: 7 additions & 2 deletions .github/workflows/container-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ jobs:
- name: Set common variables
run: |
# We use the prod oauth server for all environments
echo "OAUTH2_SERVER_URL=https://world.openfoodfacts.org/cgi/auth.pl" >> $GITHUB_ENV
echo "SSH_PROXY_HOST=ovh1.openfoodfacts.org" >> $GITHUB_ENV
echo "SSH_USERNAME=off" >> $GITHUB_ENV
- name: Set various variable for staging (net) deployment
Expand Down Expand Up @@ -108,15 +107,21 @@ jobs:
# Set Docker Compose variables
echo "DOCKER_CLIENT_TIMEOUT=180" >> .env
echo "COMPOSE_HTTP_TIMEOUT=180" >> .env
echo "COMPOSE_PROJECT_NAME=open-prices" >> .env
echo "COMPOSE_PROJECT_NAME=open_prices" >> .env
echo "COMPOSE_PATH_SEPARATOR=;" >> .env
echo "COMPOSE_FILE=docker-compose.yml;docker/prod.yml" >> .env
# Set docker variables
echo "TAG=sha-${{ github.sha }}" >> .env
echo "RESTART_POLICY=always" >> .env
# Set App variables
echo "API_PORT=8190" >> .env
echo "OAUTH2_SERVER_URL=https://world.openfoodfacts.org/cgi/auth.pl" >> .env
echo "SENTRY_DNS=${{ secrets.SENTRY_DSN }}" >> .env
echo "POSTGRES_EXPOSE=127.0.0.1:5433" >> .env
echo "POSTGRES_HOST=postgres.open_prices_default" >> .env
echo "POSTGRES_DB=postgres" >> .env
echo "POSTGRES_USER=postgres" >> .env
echo "POSTGRES_PASSWORD=${{ secrets.POSTGRES_PASSWORD }}" >> .env
- name: Create Docker volumes
uses: appleboy/ssh-action@master
Expand Down
24 changes: 23 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,36 @@ down:
${DOCKER_COMPOSE} down


hdown:
@echo "🥫 Bringing down containers and associated volumes …"
${DOCKER_COMPOSE} down -v


# pull images from image repository
pull:
${DOCKER_COMPOSE} pull

restart:
@echo "🥫 Restarting containers …"
${DOCKER_COMPOSE} restart

status:
@echo "🥫 Getting container status …"
${DOCKER_COMPOSE} ps

log:
@echo "🥫 Reading logs (docker-compose) …"
${DOCKER_COMPOSE} logs -f api


#------------#
# Production #
#------------#

# Create all external volumes needed for production. Using external volumes is useful to prevent data loss (as they are not deleted when performing docker down -v)
create_external_volumes:
@echo "🥫 Creating external volumes (production only) …"
docker volume create postgres-data
docker volume create open_prices_postgres-data

#---------#
# Cleanup #
Expand Down

0 comments on commit 0722ee3

Please sign in to comment.