Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions build_recipe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,5 +196,7 @@ func TestBuildShipsSiblingPackages(t *testing.T) {
"COPY --chown=appuser code/src code/src",
"COPY --chown=appuser code/adapters code/adapters",
"COPY --chown=appuser code/model_service code/model_service",
// uvicorn's logging configuration and filter, written by the builder (uvicorn_logging.go).
"COPY --chown=appuser code/uvicorn-log-config.json code/codefly_uvicorn_logging.py ./",
}, copies)
}
13 changes: 8 additions & 5 deletions builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,14 @@ func (s *Builder) Build(ctx context.Context, req *builderv0.BuildRequest) (*buil
// A project that is a member of a uv workspace in the service is built from
// that workspace, copied whole (see enclosingUVWorkspace); its path sources
// must then stay inside the service the context carries.
// uvicorn's logging configuration and its filter module, written into the
// project exactly as a native start writes them, before any context is
// assembled from it: the build context is the service directory (or the
// assembled copy of it), and the Dockerfile copies them from code/ beside
// src (uvicorn_logging.go).
if err := writeUvicornLogging(s.SourceLocation); err != nil {
return s.Base.Builder.BuildError(err)
}
membership, err := enclosingUVWorkspace(s.Location, s.SourceLocation)
if err != nil {
return s.Base.Builder.BuildError(err)
Expand Down Expand Up @@ -259,11 +267,6 @@ func (s *Builder) Build(ctx context.Context, req *builderv0.BuildRequest) (*buil
if err := s.Base.Templates(ctx, docker, services.WithBuilder(builderFS).WithDestination("%s", outputDir)); err != nil {
return s.Base.Builder.BuildError(err)
}
// uvicorn's logging configuration and its filter module, which the
// Dockerfile copies beside the code (uvicorn_logging.go).
if err := writeUvicornLogging(outputDir); err != nil {
return s.Base.Builder.BuildError(err)
}
image := s.DockerImage(dockerRequest).FullName()
if assembled == nil {
// Only the Dockerfile and its ignore were written, and the application's
Expand Down
4 changes: 2 additions & 2 deletions templates/builder/Dockerfile.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ WORKDIR /app/code

# uvicorn's logging configuration and the filter it names (uvicorn_logging.go):
# health probes are dropped from the access log, everything else is as uvicorn
# writes it. Both files are rendered into the build context by the builder.
COPY --chown=appuser uvicorn-log-config.json codefly_uvicorn_logging.py ./
# writes it. The builder writes both into the project before the build.
COPY --chown=appuser {{.ServicePrefix}}code/uvicorn-log-config.json {{.ServicePrefix}}code/codefly_uvicorn_logging.py ./

# Default REST port (overridden by codefly at runtime).
CMD ["uvicorn", "src.main:app", "--host", "0.0.0.0", "--port", "8080", "--log-config", "uvicorn-log-config.json"]
Loading