Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions .github/workflows/docker-k8s.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ jobs:
- name: Lint k8s
run: (cd Resources/k8s/kustomize && yamllint .)
- name: Create k8s Kind Cluster
uses: helm/kind-action@v1.13.0
uses: helm/kind-action@v1.14.0
with:
cluster_name: pokeapi
config: Resources/kind/config-ga.yaml
version: v0.31.0
version: v0.32.0
- name: Create deployment configuration
run: |
cp Resources/k8s/kustomize/base/secrets/postgres.env.sample Resources/k8s/kustomize/base/secrets/postgres.env
Expand Down
33 changes: 26 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
veekun_pokedex_repository = ../pokedex
local_config = --settings=config.local
docker_config = --settings=config.docker-compose
gql_compose_config = -f docker-compose.yml -f docker-compose-dev.yml -f Resources/compose/docker-compose-prod-graphql.yml
gql_compose_config_deprecated = -f docker-compose.yml -f docker-compose-dev.yml -f Resources/compose/docker-compose-prod-graphql.yml
gql_compose_config = -f docker-compose.yml -f Resources/compose/docker-compose-prod-graphql.yml

.PHONY: help
.SILENT:
Expand Down Expand Up @@ -78,7 +79,7 @@ docker-stop: # (Docker) Stop containers
docker compose stop

docker-down: # (Docker) Stop and removes containers and networks
docker compose down
docker compose down --remove-orphans -v

docker-test: # (Docker) Run tests
docker compose exec -T app python manage.py test ${local_config}
Expand Down Expand Up @@ -145,7 +146,7 @@ start-graphql-prod:
git pull origin master
git submodule update --init
docker compose -f docker-compose.yml -f Resources/compose/docker-compose-prod-graphql.yml up -d
docker compose stop app
docker compose stop app cache

down-graphql-prod:
docker container rm $(docker container ls -aq) -f
Expand All @@ -154,18 +155,36 @@ down-graphql-prod:
sync; echo 3 > /proc/sys/vm/drop_caches

# Nginx doesn't start if upstream graphql-engine is down
update-graphql-data-prod:
update-graphql-data-prod-old:
docker compose ${gql_compose_config} stop
git pull origin master
git submodule update --remote --merge
docker compose ${gql_compose_config} up --pull always -d app cache db
docker compose ${gql_compose_config_deprecated} up --pull always -d app cache db
sync; echo 3 > /proc/sys/vm/drop_caches
make docker-migrate
make docker-build-db
docker compose ${gql_compose_config} stop app cache
docker compose ${gql_compose_config} up --pull always -d graphql-engine graphiql
docker compose ${gql_compose_config_deprecated} stop app cache
docker compose ${gql_compose_config_deprecated} up --pull always -d graphql-engine graphiql
sleep 120
make hasura-apply
docker compose ${gql_compose_config_deprecated} up --pull always -d web
docker compose exec -T web sh -c 'rm -rf /tmp/cache/*'
docker image prune -af
sync; echo 3 > /proc/sys/vm/drop_caches

update-graphql-data-prod:
git pull origin master
git submodule update --remote --merge
curl -Ss -L -O https://github.com/PokeAPI/pokeapi/releases/download/master-branch/pokeapi.pgdump

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just an idea but would it be possible to stream or pipe the curl directly to pg restore over reading/writing to disk

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course

docker compose ${gql_compose_config} stop web graphql-engine app cache
docker compose ${gql_compose_config} down -v db
docker compose ${gql_compose_config} up --pull always -d db
sleep 10

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of arbitrary sleep wouldn't it be better to check container status

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, but I don't want it to be so complicated.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking something like this

its still a one liner and kind of a simple do while loop, its more reliable too if for any reason it takes up more than the sleep alotted time

@until docker compose ${gql_compose_config} exec -T db pg_isready -U ash -d pokeapi; do sleep 1; done

similarly for the other sleep too

docker compose exec -T db pg_restore -U ash -d pokeapi < pokeapi.pgdump
rm -f pokeapi.pgdump
docker compose ${gql_compose_config} up --pull always -d graphql-engine
sleep 30
make hasura-apply
docker compose ${gql_compose_config} up --pull always -d web
docker compose exec -T web sh -c 'rm -rf /tmp/cache/*'
docker image prune -af
Expand Down
10 changes: 0 additions & 10 deletions Resources/compose/docker-compose-prod-graphql.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
version: '2.4'
services:
cache:
restart: "no"

db:
environment:
POSTGRES_PASSWORD: "${POSTGRES_PASSWORD}"
POSTGRES_USER: "${POSTGRES_USER}"

app:
image: pokeapi/pokeapi:master
env_file: .env
Expand All @@ -19,16 +13,12 @@ services:
condition: service_started
graphql-engine:
condition: service_healthy
logging:
driver: gcplogs

graphql-engine:
cpus: 0.7
memswap_limit: 3g
mem_limit: 700m
environment:
HASURA_GRAPHQL_DATABASE_URL: "postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB:-pokeapi}"
HASURA_GRAPHQL_ADMIN_SECRET: "${HASURA_GRAPHQL_ADMIN_SECRET}"
HASURA_GRAPHQL_SCHEMA_SYNC_POLL_INTERVAL: 0
HASURA_GRAPHQL_EVENTS_HTTP_POOL_SIZE: 10
HASURA_GRAPHQL_ENABLE_CONSOLE: "true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ spec:
done;
containers:
- name: graphql-engine
image: hasura/graphql-engine:v2.48.1
image: hasura/graphql-engine:v2.49.4
ports:
- containerPort: 8080
env:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ spec:
serviceAccountName: ingress-controller
containers:
- name: haproxy-ingress-controller
image: quay.io/jcmoraisjr/haproxy-ingress:v0.14.7
image: quay.io/jcmoraisjr/haproxy-ingress:v0.16.1
resources:
limits:
memory: "256Mi"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ spec:
spec:
initContainers:
- name: postgres-connection-checker
image: postgres:17.2-alpine3.21
image: postgres:18.4-alpine3.24
command: ['sh', '-c']
args:
- until pg_isready -h postgresql -p 5432; do
echo waiting for database;
sleep 2;
done;
- name: data-download
image: alpine:3.21.2
image: alpine:3.24.1
command: ['sh', '-c']
args:
- apk add --update git &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ spec:
spec:
containers:
- name: postgresql
image: postgres:17.2-alpine3.21
image: postgres:18.4-alpine3.24
ports:
- containerPort: 5432
env:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ spec:
spec:
containers:
- name: redis
image: redis:7.4.2-alpine3.21
image: redis:8.6.4-alpine
ports:
- containerPort: 6379
resources: {}
Expand Down
2 changes: 1 addition & 1 deletion Resources/k8s/kustomize/ga/pokeapi-deployment-patch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ spec:
spec:
initContainers:
- name: data-download
image: alpine:3.21.2
image: alpine:3.24.1
command: ['ls']
args: ['/tmp/csv']
containers:
Expand Down
9 changes: 5 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
services:
cache:
image: redis:7.4.2-alpine3.21
image: redis:8.6.4-alpine
volumes:
- redis_data:/data
restart: always

db:
image: postgres:17.2-alpine3.21
image: postgres:18.4-alpine3.24
environment:
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-pokemon}
POSTGRES_USER: ${POSTGRES_USER:-ash}
POSTGRES_DB: ${POSTGRES_DB:-pokeapi}
volumes:
- pg_data:/var/lib/postgresql/data
- pg_data:/var/lib/postgresql/
healthcheck:
test: pg_isready -U $${POSTGRES_USER:-ash} -d $${POSTGRES_DB:-pokeapi}
interval: 10s
Expand Down Expand Up @@ -48,7 +48,8 @@ services:
- ./Resources/nginx/ssl:/ssl:ro
- graphql_cache:/tmp/cache
graphql-engine:
image: hasura/graphql-engine:v2.48.1
image: hasura/graphql-engine:v2.49.4
user: 1001:1001
ports:
- "8080:8080"
depends_on:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ array_relationships:
table:
name: pokemon_v2_abilityname
schema: public
- name: pokemonformconditions
using:
foreign_key_constraint_on:
column: ability_id
table:
name: pokemon_v2_pokemonformcondition
schema: public
- name: pokemonabilities
using:
foreign_key_constraint_on:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ array_relationships:
table:
name: pokemon_v2_move
schema: public
- name: pokemonstatpasts
using:
foreign_key_constraint_on:
column: generation_id
table:
name: pokemon_v2_pokemonstatpast
schema: public
- name: pokemonabilitypasts
using:
foreign_key_constraint_on:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ array_relationships:
table:
name: pokemon_v2_machine
schema: public
- name: pokemonformconditions
using:
foreign_key_constraint_on:
column: item_id
table:
name: pokemon_v2_pokemonformcondition
schema: public
- name: pokemonevolutions
using:
foreign_key_constraint_on:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,21 @@ array_relationships:
table:
name: pokemon_v2_movename
schema: public
- name: pokemonevolutions
- name: pokemonevolutionsByUsedMoveId
using:
foreign_key_constraint_on:
column: used_move_id
table:
name: pokemon_v2_pokemonevolution
schema: public
- name: pokemonformconditions
using:
foreign_key_constraint_on:
column: move_id
table:
name: pokemon_v2_pokemonformcondition
schema: public
- name: pokemonevolutionsByKnownMoveId
using:
foreign_key_constraint_on:
column: known_move_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,27 @@ array_relationships:
table:
name: pokemon_v2_encounter
schema: public
- name: pokemonevolutionsbyevolvedformid
using:
foreign_key_constraint_on:
column: evolved_form_id
table:
name: pokemon_v2_pokemonevolution
schema: public
- name: pokemonevolutions
using:
foreign_key_constraint_on:
column: base_form_id
table:
name: pokemon_v2_pokemonevolution
schema: public
- name: pokemonstatpasts
using:
foreign_key_constraint_on:
column: pokemon_id
table:
name: pokemon_v2_pokemonstatpast
schema: public
- name: pokemonabilities
using:
foreign_key_constraint_on:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ object_relationships:
- name: TypeByPartyTypeId
using:
foreign_key_constraint_on: party_type_id
- name: baseformid
using:
foreign_key_constraint_on: base_form_id
- name: evolutiontrigger
using:
foreign_key_constraint_on: evolution_trigger_id
Expand All @@ -34,18 +37,21 @@ object_relationships:
- name: move
using:
foreign_key_constraint_on: known_move_id
- name: pokemon
using:
foreign_key_constraint_on: evolved_form_id
- name: versiongroup
using:
foreign_key_constraint_on: version_group_id
- name: pokemonspecy
using:
foreign_key_constraint_on: evolved_species_id
- name: type
using:
foreign_key_constraint_on: known_move_type_id
- name: region
using:
foreign_key_constraint_on: region_id
- name: baseformid
- name: type
using:
foreign_key_constraint_on: base_form_id
foreign_key_constraint_on: known_move_type_id
- name: usedmove
using:
foreign_key_constraint_on: used_move_id
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
table:
name: pokemon_v2_pokemonstatpast
schema: public
configuration:
column_config: {}
custom_column_names: {}
custom_name: pokemonstatpast
custom_root_fields: {}
object_relationships:
- name: generation
using:
foreign_key_constraint_on: generation_id
- name: pokemon
using:
foreign_key_constraint_on: pokemon_id
- name: stat
using:
foreign_key_constraint_on: stat_id
select_permissions:
- role: anon
permission:
columns: '*'
filter: {}
limit: 100000
allow_aggregations: true
query_root_fields:
- select
- select_aggregate
subscription_root_fields: []
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ array_relationships:
table:
name: pokemon_v2_pokedex
schema: public
- name: pokemonevolutions
using:
foreign_key_constraint_on:
column: region_id
table:
name: pokemon_v2_pokemonevolution
schema: public
- name: regionnames
using:
foreign_key_constraint_on:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ array_relationships:
table:
name: pokemon_v2_nature
schema: public
- name: pokemonstatpasts
using:
foreign_key_constraint_on:
column: stat_id
table:
name: pokemon_v2_pokemonstatpast
schema: public
- name: pokemonstats
using:
foreign_key_constraint_on:
Expand Down
Loading
Loading