2024-02-01 18:26:06 +00:00
|
|
|
name: Build Docker image and create k8s with it
|
2021-05-27 17:25:40 +00:00
|
|
|
|
|
|
|
on:
|
2024-02-01 18:26:06 +00:00
|
|
|
pull_request:
|
2021-05-27 17:25:40 +00:00
|
|
|
|
|
|
|
jobs:
|
2024-02-01 18:26:06 +00:00
|
|
|
docker:
|
2021-05-27 17:25:40 +00:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
2024-02-01 18:26:06 +00:00
|
|
|
uses: actions/checkout@v4
|
2021-05-27 17:25:40 +00:00
|
|
|
with:
|
|
|
|
submodules: recursive
|
2024-02-01 18:26:06 +00:00
|
|
|
- name: Docker meta
|
|
|
|
id: meta
|
|
|
|
uses: docker/metadata-action@v5
|
|
|
|
with:
|
|
|
|
images: pokeapi/pokeapi
|
|
|
|
- name: Set up QEMU
|
|
|
|
uses: docker/setup-qemu-action@v3
|
|
|
|
- name: Set up Docker Buildx
|
|
|
|
id: buildx
|
|
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Build
|
|
|
|
id: docker_build
|
|
|
|
uses: docker/build-push-action@v5
|
|
|
|
with:
|
|
|
|
context: .
|
|
|
|
file: ./Resources/docker/app/Dockerfile
|
|
|
|
push: false
|
2024-06-02 10:02:07 +00:00
|
|
|
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6
|
|
|
|
tags: pokeapi/pokeapi:local
|
|
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
|
|
- name: Image digest
|
|
|
|
run: echo ${{ steps.docker_build.outputs.digest }}
|
|
|
|
k8s:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v4
|
|
|
|
with:
|
|
|
|
submodules: recursive
|
|
|
|
- name: Docker meta
|
|
|
|
id: meta
|
|
|
|
uses: docker/metadata-action@v5
|
|
|
|
with:
|
|
|
|
images: pokeapi/pokeapi
|
|
|
|
- name: Set up QEMU
|
|
|
|
uses: docker/setup-qemu-action@v3
|
|
|
|
- name: Set up Docker Buildx
|
|
|
|
id: buildx
|
|
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Build
|
|
|
|
id: docker_build
|
|
|
|
uses: docker/build-push-action@v5
|
|
|
|
with:
|
|
|
|
context: .
|
|
|
|
file: ./Resources/docker/app/Dockerfile
|
|
|
|
push: false
|
|
|
|
load: true
|
|
|
|
platforms: local
|
2024-02-01 18:26:06 +00:00
|
|
|
tags: pokeapi/pokeapi:local
|
|
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
|
|
- name: Image digest
|
|
|
|
run: echo ${{ steps.docker_build.outputs.digest }}
|
|
|
|
- name: Lint k8s
|
2021-06-01 13:17:54 +00:00
|
|
|
run: (cd Resources/k8s/kustomize && yamllint .)
|
2021-05-27 17:25:40 +00:00
|
|
|
- name: Create k8s Kind Cluster
|
2024-02-01 18:47:04 +00:00
|
|
|
uses: helm/kind-action@v1.1.0
|
2021-05-28 09:53:23 +00:00
|
|
|
with:
|
2024-02-01 18:47:04 +00:00
|
|
|
version: v0.11.1
|
2021-06-05 20:58:10 +00:00
|
|
|
- name: Create deployment configuration
|
|
|
|
run: |
|
|
|
|
cp Resources/k8s/kustomize/base/secrets/postgres.env.sample Resources/k8s/kustomize/base/secrets/postgres.env
|
|
|
|
cp Resources/k8s/kustomize/base/secrets/graphql.env.sample Resources/k8s/kustomize/base/secrets/graphql.env
|
|
|
|
cp Resources/k8s/kustomize/base/config/pokeapi.env.sample Resources/k8s/kustomize/base/config/pokeapi.env
|
2024-06-02 11:10:18 +00:00
|
|
|
- name: Load local image to Kind
|
|
|
|
run: kind load docker-image pokeapi/pokeapi:local
|
2021-05-28 15:06:06 +00:00
|
|
|
- name: K8s Apply
|
2021-05-27 17:25:40 +00:00
|
|
|
run: |
|
2024-02-01 18:26:06 +00:00
|
|
|
make kustomize-local-apply
|
2021-05-28 15:06:06 +00:00
|
|
|
kubectl proxy &
|
2024-06-02 10:35:18 +00:00
|
|
|
sleep 1
|
2021-05-28 15:06:06 +00:00
|
|
|
bash Resources/scripts/wait.sh http://localhost:8001/api/v1/namespaces/pokeapi/services/pokeapi/proxy/api/v2/
|
2024-02-01 18:26:06 +00:00
|
|
|
- name: Set default namespace and print info
|
2021-05-28 15:11:59 +00:00
|
|
|
run: |
|
|
|
|
kubectl config set-context --current --namespace pokeapi
|
2024-02-01 18:26:06 +00:00
|
|
|
kubectl describe deployment
|
2021-05-28 15:06:06 +00:00
|
|
|
- name: Migrate and build data
|
|
|
|
run: |
|
2021-05-27 18:38:25 +00:00
|
|
|
make k8s-migrate
|
|
|
|
make k8s-build-db
|
2021-05-28 15:06:06 +00:00
|
|
|
bash Resources/scripts/wait.sh http://localhost:8001/api/v1/namespaces/pokeapi/services/pokeapi/proxy/api/v2/pal-park-area/5/
|
2024-02-01 18:26:06 +00:00
|
|
|
- name: K8s wait for job
|
2021-05-28 15:06:06 +00:00
|
|
|
run: |
|
|
|
|
kubectl wait --timeout=120s --for=condition=complete job/load-graphql
|
|
|
|
last_command=$(kubectl get job -o jsonpath='{.status.succeeded}' load-graphql)
|
2021-06-01 12:37:49 +00:00
|
|
|
test "$last_command" -eq 1
|