openfaas / python-flask-template

HTTP and Flask-based OpenFaaS templates for Python 3
MIT License
85 stars 86 forks source link

Misconfigured multi-stage step name in all Dockerfiles #63

Closed atlas-wheatear closed 1 year ago

atlas-wheatear commented 1 year ago

My actions before raising this issue

Expected Behaviour

The faas-cli build, having pulled the most recent templates for python3-http as of the last 30 minutes, should continue to build as it did earlier today. (There could be a problem my end, but it's failing on my local M1 Macbook Pro and my GitLab instance.) Functions I haven't modified at all in days are also failing redeployment.

Current Behaviour

It fails, seemingly because it is trying to pull from a remote "builder" image on Docker Hub, as opposed to using the builder "stage" of the multi-stage build. Error below:

#3 [internal] load metadata for docker.io/library/builder:latest
#3 sha256:261eb3ef077559ec61986b2391905264393ea6320a9bca56ed4d427da6e7cb59
#3 ERROR: pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed
------
 > [internal] load metadata for docker.io/library/builder:latest:
------
failed to solve with frontend dockerfile.v0: failed to create LLB definition: pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed

Possible Solution

Explicitly label the previous stage as builder? I'm actually stumped as to why this has broken just now, perhaps due to a breaking of compatibility introduced by using the --platform flag?

https://github.com/openfaas/python-flask-template/blob/79b444bca68df126b7d9e31aca35857dbd4d80f9/template/python3-http/Dockerfile#L2

Steps to Reproduce (for bugs)

  1. using this code https://github.com/emoulsdale/openfaas-test (sorry, it's really bad and unidiomatic)
  2. run faas-cli template store pull python3-http
  3. run faas-cli build
  4. observe this error appear!

Context

My test functions are no longer building with the newest templates at all. Sorry to be a pain :) . I can revert back to the previous version for now though! Will have to check it in to my code manually, and alter the CI scripts.

Your Environment

https://github.com/emoulsdale/openfaas-test

Next steps

You may join Slack for community support.

Just wanted to add that this still only the first problem I've had, so far, after months of trying silly things. I am really enjoying sponsoring this project!

atlas-wheatear commented 1 year ago

I found a previous version of the Dockerfile in the python3-http template, stored (locally, it's gitignored) in one of my function repos.

Using this local previous version, my functions are still building on my local MacBook.

Here is the diff (from previous to current).

1,2c1,2
< FROM ghcr.io/openfaas/of-watchdog:0.9.6 as watchdog
< FROM python:3.7-alpine
---
> FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/of-watchdog:0.9.8 as watchdog
> FROM --platform=${TARGETPLATFORM:-linux/amd64} python:3.7-alpine
22,23c22,23
< COPY index.py           .
< COPY requirements.txt   .
---
> COPY --chown=app:app index.py           .
> COPY --chown=app:app requirements.txt   .
25c25
< RUN pip install -r requirements.txt
---
> RUN pip install --no-cache-dir -r requirements.txt
33,34c33,34
< COPY function/requirements.txt    .
< RUN pip install --user -r requirements.txt
---
> COPY --chown=app:app function/requirements.txt    .
> RUN pip install --no-cache-dir --user -r requirements.txt
36c36
< #install function code
---
> # install function code
38,39c38
< COPY function/   .
< RUN chown -R app:app ../
---
> COPY --chown=app:app function/   .
40a40
> FROM builder as tester
44a45
> FROM builder as final
47c48
< #configure WSGI server and healthcheck
---
> # configure WSGI server and healthcheck
alexellis commented 1 year ago

Sorry for the inconvenience. We are not sure who you are and how you use OpenFaaS as we don't have your company as a sponsor or the ADOPTERS file

We'll look into supporting you here, perhaps consider doing one of the above to reciprocate the goodwill.

Alex

alexellis commented 1 year ago

I can reproduce the problem with:

faas-cli new --lang python3-http testbuild
faas-cli build -f testbuild.yml 

@LucasRoesler I think it may be related to recent changes we've made to the Python template.

I've pushed https://github.com/openfaas/python-flask-template/commit/bf6afb78613a1ff94de0fa5fe5167d644fa45b36 as a fix.

Perhaps we should get the e2e test from the openfaas/templates repo over here and run it as GitHub Action?

https://github.com/openfaas/templates/blob/master/verify.sh https://github.com/openfaas/templates/blob/master/.github/workflows/only-ci.yaml