You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Let's decide on how we treat the source code in a Function repository when using compiled languages!
Unnecessary source code (eg: *.go files) are probably expected to be kept out of the final container by default, without inhibiting the runtime access to other static files:
Let's assume a simple Function which serves static files. The Function answers all HTTP requests by either serving the file requested or a 404. During development and testing, these files are implicitly available, and are source-controlled (they are checked into the repository). Let's also assume they use a custom .toml file for their Function's runtime configuration:
when the function is built and deployed, these files are included in the resultant container, such that from the developer's perspective everything is entirely transparent and they can access their config at ./config.toml and their static files in ./static/{{filename}}.
There are unnecessary files in ./docs which would be included as well, so /docs is added to .funcignore. This prevents them from being built into the container for all builders, or to even be sent to the builder container for containerized builds (Pack and S2I).
However, the source code files (*.go in this example), are included in the resulting container. The source code is necessary in the case of interpreted languages (Python and Node presently), but generally not desireable for compiled languages, where only the resultant binary is expected.
By simply adding *.go as a default entry in .funcignore on project creation (differing for each language of course), this will solve the problem, but only for the Host builder; not for Pack or S2I. This is because the host builder still has all the source code available during the build process by way of using a simple symlink to the source code for compliation. The Pack and S2I builders, however, require all files to be sent to the build container. Evaluation of the .funcignore therefore does not only restrict which files are included in the final container, but also restricts which files are available during compilation.
It seems clear to me that the solution is to separate the two concepts: "files to be kept out of the final container" and "files that need not even be sent to the builder (applicable only for containerized builds)", but I am unsure of the best way to represent these separately. Currently .funcignore is both concepts combined.
Perhaps:
$ cat .funcignore
# Build-stage Ignore
# Files which will not be sent to the builder (if using containerized builds)
# and will also therefore not be in the final container.
# If the Function contains large files, and the Pack or S2I builder is being used, this can
# speed up builds.
[build]
/docs
# Deploy-stage Ignore
# These files will not be deployed as a part of the final container, but will be available
# during compilation.
[deploy]
*.go
The simple solution, of course, is to hard-code into the builders that they never include source-code files in the final container for compiled/transpiled languages. That may be a good first-step, but it's incomplete. For example, another valid use-case is a Function which serves up its own source-code on request.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Let's decide on how we treat the source code in a Function repository when using compiled languages!
Unnecessary source code (eg:
*.go
files) are probably expected to be kept out of the final container by default, without inhibiting the runtime access to other static files:Let's assume a simple Function which serves static files. The Function answers all HTTP requests by either serving the file requested or a 404. During development and testing, these files are implicitly available, and are source-controlled (they are checked into the repository). Let's also assume they use a custom
.toml
file for their Function's runtime configuration:when the function is built and deployed, these files are included in the resultant container, such that from the developer's perspective everything is entirely transparent and they can access their config at
./config.toml
and their static files in./static/{{filename}}
.There are unnecessary files in
./docs
which would be included as well, so/docs
is added to.funcignore
. This prevents them from being built into the container for all builders, or to even be sent to the builder container for containerized builds (Pack and S2I).However, the source code files (
*.go
in this example), are included in the resulting container. The source code is necessary in the case of interpreted languages (Python and Node presently), but generally not desireable for compiled languages, where only the resultant binary is expected.By simply adding
*.go
as a default entry in.funcignore
on project creation (differing for each language of course), this will solve the problem, but only for the Host builder; not for Pack or S2I. This is because the host builder still has all the source code available during the build process by way of using a simple symlink to the source code for compliation. The Pack and S2I builders, however, require all files to be sent to the build container. Evaluation of the.funcignore
therefore does not only restrict which files are included in the final container, but also restricts which files are available during compilation.It seems clear to me that the solution is to separate the two concepts: "files to be kept out of the final container" and "files that need not even be sent to the builder (applicable only for containerized builds)", but I am unsure of the best way to represent these separately. Currently
.funcignore
is both concepts combined.Perhaps:
The simple solution, of course, is to hard-code into the builders that they never include source-code files in the final container for compiled/transpiled languages. That may be a good first-step, but it's incomplete. For example, another valid use-case is a Function which serves up its own source-code on request.
Beta Was this translation helpful? Give feedback.
All reactions