Skip to content

Commit cc439d9

Browse files
authored
Merge branch 'master' into veekun-scripts
2 parents e8bf90d + 41c4856 commit cc439d9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+15530
-9777
lines changed

.circleci/config.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ version: 2.1
33
jobs:
44
test:
55
docker:
6-
- image: cimg/python:3.10.9
6+
- image: cimg/python:3.12.8
77
steps:
88
- checkout
99
- run:
@@ -25,7 +25,7 @@ jobs:
2525
command: make openapi-generate
2626
build:
2727
docker:
28-
- image: cimg/python:3.10.9
28+
- image: cimg/python:3.12.8
2929
steps:
3030
- checkout
3131
- run:
@@ -44,7 +44,7 @@ jobs:
4444
command: make build-db
4545
deploy:
4646
machine:
47-
image: ubuntu-2204:2023.10.1
47+
image: ubuntu-2204:2024.11.1
4848
resource_class: large
4949
steps:
5050
- checkout

.dockerignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,7 @@ docker-compose*
2424
/*.js
2525
.env
2626
*pycache*
27-
target
27+
target
28+
data/v2/cries
29+
data/v2/csv
30+
data/v2/sprites

.github/workflows/docker-build-and-push.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build and Push Docker image
1+
name: Push Docker image
22

33
on:
44
push:
@@ -20,17 +20,15 @@ jobs:
2020
id: meta
2121
uses: docker/metadata-action@v5
2222
with:
23-
# list of Docker images to use as base name for tags
24-
images: |
25-
pokeapi/pokeapi
23+
images: pokeapi/pokeapi
2624
- name: Set up QEMU
2725
uses: docker/setup-qemu-action@v3
2826
- name: Set up Docker Buildx
2927
id: buildx
3028
uses: docker/setup-buildx-action@v3
3129
- name: Login to DockerHub
3230
if: github.event_name != 'pull_request'
33-
uses: docker/login-action@v1
31+
uses: docker/login-action@v3
3432
with:
3533
username: ${{ secrets.DOCKERHUB_USERNAME_NARAMSIM }}
3634
password: ${{ secrets.DOCKERHUB_TOKEN_NARAMSIM }}
@@ -43,12 +41,12 @@ jobs:
4341
echo "Platforms: ${{ steps.buildx.outputs.platforms }}"
4442
- name: Build and push
4543
id: docker_build
46-
uses: docker/build-push-action@v5
44+
uses: docker/build-push-action@v6
4745
with:
4846
context: .
4947
file: ./Resources/docker/app/Dockerfile
5048
push: true
51-
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6
49+
platforms: linux/amd64,linux/arm64 #,linux/arm/v7,linux/arm/v6
5250
tags: ${{ steps.meta.outputs.tags }}
5351
labels: ${{ steps.meta.outputs.labels }}
5452
- name: Image digest

.github/workflows/docker-k8s.yml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build Docker image and create k8s with it
1+
name: Test Docker, Compose and k8s
22

33
on:
44
pull_request:
@@ -23,12 +23,12 @@ jobs:
2323
uses: docker/setup-buildx-action@v3
2424
- name: Build
2525
id: docker_build
26-
uses: docker/build-push-action@v5
26+
uses: docker/build-push-action@v6
2727
with:
2828
context: .
2929
file: ./Resources/docker/app/Dockerfile
3030
push: false
31-
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6
31+
platforms: linux/amd64,linux/arm64 #,linux/arm/v7,linux/arm/v6
3232
tags: pokeapi/pokeapi:local
3333
labels: ${{ steps.meta.outputs.labels }}
3434
- name: Image digest
@@ -66,7 +66,7 @@ jobs:
6666
- name: Lint k8s
6767
run: (cd Resources/k8s/kustomize && yamllint .)
6868
- name: Create k8s Kind Cluster
69-
uses: helm/kind-action@v1.10.0
69+
uses: helm/kind-action@v1.12.0
7070
with:
7171
cluster_name: pokeapi
7272
version: v0.21.0
@@ -99,3 +99,16 @@ jobs:
9999
test "$last_command" -eq 1
100100
- name: Get GQL output
101101
run: kubectl logs jobs/load-graphql
102+
compose:
103+
runs-on: ubuntu-latest
104+
steps:
105+
- name: Checkout
106+
uses: actions/checkout@v4
107+
- name: Build dev environment
108+
run: |
109+
docker compose -f docker-compose.yml -f docker-compose-dev.yml up -d
110+
sleep 30
111+
- name: Assert containers running
112+
run: |
113+
last_command=$(docker ps | grep 'pokeapi-' | wc -l)
114+
test "$last_command" -eq 5

.github/workflows/release.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- '*.*.*'
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v4
14+
with:
15+
submodules: recursive
16+
- name: Build
17+
run: |
18+
docker compose -f docker-compose.yml -f docker-compose-dev.yml up -d
19+
make docker-migrate
20+
make docker-build-db
21+
- name: Dump DB
22+
run: docker compose exec -T -u postgres db sh -c "cd /tmp && pg_dump -h localhost -Fc -U ash pokeapi | gzip > pokeapi.dump.zip"
23+
- name: Copy dump
24+
run: |
25+
docker compose cp db:/tmp/pokeapi.dump.zip ./
26+
ls -larth
27+
- name: Release
28+
uses: softprops/action-gh-release@c95fe1489396fe8a9eb87c0abf8aa5b2ef267fda
29+
if: startsWith(github.ref, 'refs/tags/')
30+
with:
31+
draft: true
32+
fail_on_unmatched_files: true
33+
files: pokeapi.dump.zip
34+
generate_release_notes: true

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,14 @@ start-graphql-prod:
140140
down-graphql-prod:
141141
docker container rm $(docker container ls -aq) -f
142142
docker system prune --all --volumes --force
143+
docker volume prune --all --force
143144
sync; echo 3 > /proc/sys/vm/drop_caches
144145

145146
# Nginx doesn't start if upstream graphql-engine is down
146147
update-graphql-data-prod:
147148
docker compose ${gql_compose_config} stop
148149
git pull origin master
149-
git submodule update --init
150+
git submodule update --remote --merge
150151
docker compose ${gql_compose_config} up --pull always -d app cache db
151152
sync; echo 3 > /proc/sys/vm/drop_caches
152153
make docker-migrate

README.md

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,20 @@ A RESTful API for Pokémon - [pokeapi.co](https://pokeapi.co)
2020

2121
> Beta GraphQL support is rolling out! Check out the [GraphQL paragraph](#graphql--) for more info.
2222
23-
## Setup   [![pyVersion310](https://img.shields.io/badge/python-3.10-blue.svg)](https://www.python.org/download/releases/3.10/)
23+
24+
## Table of Contents
25+
26+
- [Setup](#setup)
27+
- [Database setup](#database-setup)
28+
- [Docker and Compose](#docker-and-compose)
29+
- [GraphQL](#graphql)
30+
- [Kubernetes](#kubernetes)
31+
- [Wrappers](#wrappers)
32+
- [Donations](#donations)
33+
- [Join Us On Slack!](#join-us-on-slack)
34+
- [Contributing](#contributing)
35+
36+
## Setup <a id="setup"></a> &nbsp; [![pyVersion310](https://img.shields.io/badge/python-3.12-blue.svg)](https://www.python.org/download/releases/3.10/)
2437

2538
- Download this source code into a working directory, be sure to use the flag `--recurse-submodules` to clone also our submodules.
2639

@@ -43,7 +56,7 @@ A RESTful API for Pokémon - [pokeapi.co](https://pokeapi.co)
4356
make serve
4457
```
4558

46-
### Database setup
59+
## Database setup
4760

4861
To build or rebuild the database by applying any CSV file update, run
4962

@@ -70,7 +83,7 @@ make migrate
7083

7184
Run `make help` to see all tasks.
7285

73-
## Docker and Compose &nbsp; [![docker hub](https://img.shields.io/docker/v/pokeapi/pokeapi?label=tag&sort=semver)](https://hub.docker.com/r/pokeapi/pokeapi)
86+
## Docker and Compose <a id="docker-and-compose"></a> &nbsp; [![docker hub](https://img.shields.io/docker/v/pokeapi/pokeapi?label=tag&sort=semver)](https://hub.docker.com/r/pokeapi/pokeapi)
7487

7588
There is also a multi-container setup, managed by [Docker Compose V2](https://docs.docker.com/compose/). This setup allows you to deploy a production-like environment, with separate containers for each service, and is recommended if you need to simply spin up PokéAPI.
7689

@@ -103,7 +116,7 @@ make docker-make-migrations
103116
make docker-migrate
104117
```
105118
106-
## GraphQL &nbsp; <a href="ttps://github.com/hasura/graphql-engine"><img height="29px" src="https://graphql-engine-cdn.hasura.io/img/powered_by_hasura_blue.svg"/></a>
119+
## GraphQL <a id="graphql"></a> &nbsp; <a href="ttps://github.com/hasura/graphql-engine"><img height="29px" src="https://graphql-engine-cdn.hasura.io/img/powered_by_hasura_blue.svg"/></a>
107120
108121
When you start PokéAPI with the above Docker Compose setup, an [Hasura Engine](https://github.com/hasura/graphql-engine) server is started as well. It's possible to track all the PokeAPI tables and foreign keys by simply
109122

@@ -119,7 +132,7 @@ A free public GraphiQL console is browsable at the address https://beta.pokeapi.
119132

120133
A set of examples is provided in the directory [/graphql/examples](./graphql/examples) of this repository.
121134

122-
## Kubernetes &nbsp; [![Build Docker image and create k8s with it](https://github.com/PokeAPI/pokeapi/actions/workflows/docker-k8s.yml/badge.svg)](https://github.com/PokeAPI/pokeapi/actions/workflows/docker-k8s.yml)
135+
## Kubernetes <a id="kubernetes"></a> &nbsp; [![Build Docker image and create k8s with it](https://github.com/PokeAPI/pokeapi/actions/workflows/docker-k8s.yml/badge.svg)](https://github.com/PokeAPI/pokeapi/actions/workflows/docker-k8s.yml)
123136

124137
[Kustomize](https://kubernetes.io/docs/tasks/manage-kubernetes-objects/kustomization/) files are provided in the folder https://github.com/PokeAPI/pokeapi/tree/master/Resources/k8s/kustomize/base/. Create and change your secrets:
125138

@@ -223,7 +236,3 @@ To contribute to this repository:
223236
- We'll accept your changes after review.
224237
225238
Simple!
226-
227-
## Deprecation
228-
229-
As of October 2018, the v1 API has been removed from PokéAPI. For more information, see [pokeapi.co/docs/v1.html](https://pokeapi.co/docs/v1.html).

Resources/compose/docker-compose-prod-graphql.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@ services:
1414
restart: "no"
1515

1616
web:
17-
volumes:
18-
- graphiql:/public-console:ro
17+
depends_on:
18+
graphiql:
19+
condition: service_started
20+
graphql-engine:
21+
condition: service_healthy
1922
logging:
2023
driver: gcplogs
2124

@@ -30,10 +33,9 @@ services:
3033
HASURA_GRAPHQL_EVENTS_HTTP_POOL_SIZE: 10
3134

3235
graphiql:
33-
image: pokeapi/graphiql:1.0.1
34-
command: sh -c 'cp -a /app/static/. /transfer/ && tail -f /etc/passwd'
35-
volumes:
36-
- graphiql:/transfer
36+
image: pokeapi/graphiql:2.0.0
37+
expose:
38+
- 80
3739
depends_on:
3840
- graphql-engine
3941
restart: always

Resources/docker/app/Dockerfile

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,33 @@
1-
FROM python:3.10-alpine
1+
FROM python:3.12.8-alpine3.21 AS builder
22

3-
ENV PYTHONUNBUFFERED 1
4-
ENV DJANGO_SETTINGS_MODULE 'config.docker-compose'
3+
ENV PYTHONUNBUFFERED=1
54

65
RUN mkdir /code
76
WORKDIR /code
87

98
ADD requirements.txt /code/
109
RUN apk add --no-cache postgresql-libs libstdc++
1110
RUN apk add --no-cache --virtual .build-deps gcc g++ musl-dev \
12-
postgresql-dev rust cargo && \
13-
python3 -m pip install -r requirements.txt --no-cache-dir && \
14-
apk --purge del .build-deps
11+
postgresql-dev binutils rust cargo && \
12+
python3 -m pip install -r requirements.txt --no-cache-dir
13+
14+
FROM python:3.12.8-alpine3.21
15+
16+
ENV PYTHONUNBUFFERED=1
17+
ENV DJANGO_SETTINGS_MODULE='config.docker-compose'
18+
19+
RUN mkdir /code
20+
WORKDIR /code
21+
22+
COPY --from=builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
23+
COPY --from=builder /usr/local/bin /usr/local/bin
24+
1525
ADD . /code/
1626

1727
RUN addgroup -g 1000 -S pokeapi && \
1828
adduser -u 1000 -S pokeapi -G pokeapi
19-
2029
USER pokeapi
21-
CMD gunicorn config.wsgi:application -c gunicorn.conf.py
30+
31+
CMD ["gunicorn", "config.wsgi:application", "-c", "gunicorn.conf.py"]
32+
2233
EXPOSE 80

Resources/docker/app/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
- [`master`](https://github.com/PokeAPI/pokeapi/blob/master/Resources/docker/app/Dockerfile)
1818
- [`staging`](https://github.com/PokeAPI/pokeapi/blob/staging/Resources/docker/app/Dockerfile)
1919

20-
> `pokeapi` uses `python:3.10-alpine` as base image.
20+
> `pokeapi` uses `python:3.12.8-alpine3.21` as base image.
2121
2222
## What is PokeAPI?
2323

0 commit comments

Comments
 (0)