Skip to content

Commit 1ad1bd7

Browse files
authored
tmpl: fix nil pointer error in Dockerfile.tmpl (#53)
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.
1 parent a4c2b40 commit 1ad1bd7

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

tmpl/Dockerfile.tmpl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,16 @@ RUN --mount=type=cache,target=/nix/store,from=base,source=/nix/store \
2626
# -----------------------------------------------
2727

2828
COPY --link . ./
29+
{{ if .InstallStage }}
2930
RUN --mount=type=cache,target=/nix/store,from=base,source=/nix/store {{.InstallStage.Command}}
31+
{{- end }}
3032

3133
# 3. BUILD STAGE
3234
# Compile the source code into an executable.
3335
# ----------------------------------------------
36+
{{ if .BuildStage }}
3437
RUN --mount=type=cache,target=/nix/store,from=base,source=/nix/store {{.BuildStage.Command}}
38+
{{- end }}
3539

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

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

0 commit comments

Comments
 (0)