Skip to content

Commit

Permalink
tmpl: fix nil pointer error in Dockerfile.tmpl (#53)
Browse files Browse the repository at this point in the history
Check that each stage is set in the plan before attempting to use its
command. This fixes a nil pointer error that occurs when using an empty
devbox.json in an unsupported language.
  • Loading branch information
gcurtis committed Sep 1, 2022
1 parent a4c2b40 commit 1ad1bd7
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tmpl/Dockerfile.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,16 @@ RUN --mount=type=cache,target=/nix/store,from=base,source=/nix/store \
# -----------------------------------------------

COPY --link . ./
{{ if .InstallStage }}
RUN --mount=type=cache,target=/nix/store,from=base,source=/nix/store {{.InstallStage.Command}}
{{- end }}

# 3. BUILD STAGE
# Compile the source code into an executable.
# ----------------------------------------------
{{ if .BuildStage }}
RUN --mount=type=cache,target=/nix/store,from=base,source=/nix/store {{.BuildStage.Command}}
{{- end }}

# 4. PACKAGING STAGE
# Create a minimal image that contains the executable.
Expand All @@ -52,4 +56,6 @@ WORKDIR /app

# We default to ENTRYPOINT instead of CMD as we consider it best practice
# when the container is wrapping an application or service.
{{ if .StartStage }}
ENTRYPOINT {{.StartStage.Command}}
{{- end }}

0 comments on commit 1ad1bd7

Please sign in to comment.