關於建置預設建置版本
當您建立或部署函數時,OCI Functions 會使用
func.yaml
檔案中的設定值來建立包含建立 Docker 映像檔之指示的暫時 Dockerfile。建立 Docker 映像檔之後, OCI Functions 會刪除暫時 Dockerfile。
例如,下方顯示一個暫時 Dockerfile。
FROM fnproject/python:3.9-dev as build-stage
WORKDIR /function
ADD requirements.txt /function/
RUN pip3 install --target /python/ --no-cache --no-cache-dir -r requirements.txt &&\
rm -fr ~/.cache/pip /tmp* requirements.txt func.yaml Dockerfile .venv &&\
chmod -R o+r /python
ADD . /function/
RUN rm -fr /function/.pip_cache
FROM fnproject/python:3.9
WORKDIR /function
COPY --from=build-stage /python /python
COPY --from=build-stage /function /function
RUN chmod -R o+r /function
ENV PYTHONPATH=/function:/python
ENTRYPOINT ["/python/bin/fdk", "/function/func.py", "handler"]