diff --git a/Makefile b/Makefile index 9041b3e7d..4de964c30 100644 --- a/Makefile +++ b/Makefile @@ -67,10 +67,16 @@ bin/kind: test/k8s/Dockerfile test/k8s/_out/img: test/k8s/Dockerfile Cargo.toml Cargo.lock $(shell find . -type f -name '*.rs') mkdir -p $(@D) && $(DOCKER_BUILD) -f test/k8s/Dockerfile --iidfile=$(@) --load . +.PHONY: test/py-flask +test/py-flask: + docker build -t py-flask-app:latest -f $@/Dockerfile $@ + mkdir -p $@/out && docker save -o $@/out/img.tar py-flask-app:latest + .PHONY: test/k8s/cluster -test/k8s/cluster: target/wasm32-wasi/$(TARGET)/img.tar bin/kind test/k8s/_out/img bin/kind +test/k8s/cluster: target/wasm32-wasi/$(TARGET)/img.tar bin/kind test/k8s/_out/img bin/kind test/py-flask bin/kind create cluster --name $(KIND_CLUSTER_NAME) --image="$(shell cat test/k8s/_out/img)" && \ bin/kind load image-archive --name $(KIND_CLUSTER_NAME) $(<) + bin/kind load image-archive --name $(KIND_CLUSTER_NAME) test/py-flask/out/img.tar .PHONY: test/k8s test/k8s: test/k8s/cluster diff --git a/test/k8s/deploy.yaml b/test/k8s/deploy.yaml index 91f59edbf..2f6bb9bc0 100644 --- a/test/k8s/deploy.yaml +++ b/test/k8s/deploy.yaml @@ -24,4 +24,7 @@ spec: containers: - name: demo image: ghcr.io/containerd/runwasi/wasi-demo-app:latest + imagePullPolicy: Never + - name: py-demo + image: py-cmd-app:v1 imagePullPolicy: Never \ No newline at end of file diff --git a/test/py-flask/Dockerfile b/test/py-flask/Dockerfile new file mode 100644 index 000000000..8a29cd268 --- /dev/null +++ b/test/py-flask/Dockerfile @@ -0,0 +1,20 @@ +# syntax=docker/dockerfile:1.4 +FROM --platform=$BUILDPLATFORM python:3.10-alpine AS builder + +WORKDIR /app + +COPY requirements.txt /app +RUN --mount=type=cache,target=/root/.cache/pip \ + pip3 install -r requirements.txt + +COPY . /app + +ENTRYPOINT ["python3"] +CMD ["app.py"] + +FROM builder as dev-envs + +RUN <