Runtime version problems when building fnproject functions? Just roll your own images then. July 24, 2020November 12, 2023 What you should know: I am currently working for Orbit Cloud Solutions as Cloud Advisor, but any posts on this blog reflect my own views and opinions only. When playing around with Oracle Functions and fnproject i pretty soon encountered some build problems for my function written in Go. It simply didn’t play well with some newer Go modules i was using. To understand what was happening here, you need to understand how serverless functions in fnproject are built and deployed. Basically you get docker images used for the build step and for the deployment. So you might have a larger docker image containing all your build tools and a smaller docker image that is actually run on the serverless runtime. Out of the box fnproject uses its own images published on dockerhub. Depending on the language runtime, the environment may be more or less up to date. In the case of Go, at the time i had my issues, the latest update was don a year before – so not the most current Go version you get here. Due to the open source nature of fnproject, this is a thing that easily can be solved: When doing a standard build with fn build or fn deploy the tooling will create a temporary Dockerfile, use the images described in it to build the code and create a docker image for deployment to the docker registry used by the serverless runtime. Now if the fn cli finds a Dockerfile in the source directory, it will not generate that temporary Dockerfile but use that one it found instead. This now leaves it up to you which docker images to use for building and running your code. In my case, all i needed was a current version of Go inside the image. After putting this Dockerfile in my source directory, everything was running smoothly again. FROM maxjahn/fn-go:dev as build-stage WORKDIR /function WORKDIR /go/src/func/ ENV GO111MODULE=on COPY . . RUN cd /go/src/func/ && go build -o func FROM maxjahn/fn-go WORKDIR /function COPY --from=build-stage /go/src/func/func /function/ ENTRYPOINT ["./func"] As you can see, i am now using 2 images that are published on my dockerhub account. But you probably want to modify and build your own images. Again, this is dead simple as everything that you need is published on github for you to modify. Just clone the repo https://github.com/fnproject/dockers and look for the images you want to custom build and publish to your docker registry of choice. In my case this of course were the Go images. Simply update the target to reflect your docker registry and run the build script. If you want to add some packages, drivers or tools to your images, the Dockerfiles you find here are the right spot to do so. One thing i needed to do, was to remove the installation of bzr in the dev Dockerfile. Maybe that will be resolved at the time you are trying to build your images. Now you should have your own custom images with more current versions ready for your serverless function development and deployment. Just think of using a custom Dockerfile in your function source directory as described above. Share this:TwitterLinkedInRedditPocketMastodonPrintEmailLike this:Like Loading... Cloud Guides & Tutorials