-
-
Notifications
You must be signed in to change notification settings - Fork 116
Open
Description
Is your feature request related to a problem?
This relates to #176
Following the documentation leads to replacing all arg entries with the given key, even those using the default value.
Using the example from the documentation
input
### File: Dockerfile.webapp
ARG GO_VERSION=1.15.8
FROM golang:"${GO_VERSION}-alpine" AS build
# Retrieve source code
WORKDIR /app
COPY . /app
# Build application
RUN go build -X "GoVersion=${GO_VERSION}" -o ./webapp
FROM ubuntu AS test
ARG GO_VERSION
ENV GO_VERSION=${GO_VERSION}
RUN ./run_tests.sh
FROM ubuntu:18.04 AS run
COPY --from=builder /app/webapp /usr/local/bin/webapp
becomes
### File: Dockerfile.webapp
ARG GO_VERSION=1.15.11 (1)
FROM golang:"${GO_VERSION}-alpine" AS build
# Retrieve source code
WORKDIR /app
COPY . /app
# Build application
RUN go build -X "GoVersion=${GO_VERSION}" -o ./webapp
FROM ubuntu:20.04 AS test (2)
ARG GO_VERSION=1.15.11 (1)
ENV GO_VERSION=${GO_VERSION}
RUN ./run_tests.sh
FROM ubuntu:20.04 AS run (2)
COPY --from=builder /app/webapp /usr/local/bin/webapp
Even if functionally it works, this creates unnecessary duplication in the Dockerfile.
Solution you'd like
There should be a way to avoid setting values to arg lines using the default.
Preferred output would be
### File: Dockerfile.webapp
ARG GO_VERSION=1.15.11 (1)
FROM golang:"${GO_VERSION}-alpine" AS build
# Retrieve source code
WORKDIR /app
COPY . /app
# Build application
RUN go build -X "GoVersion=${GO_VERSION}" -o ./webapp
FROM ubuntu:20.04 AS test (2)
ARG GO_VERSION
ENV GO_VERSION=${GO_VERSION}
RUN ./run_tests.sh
FROM ubuntu:20.04 AS run (2)
COPY --from=builder /app/webapp /usr/local/bin/webapp
Alternatives you've considered
For example, the given input
spec:
file: Dockerfile.webapp
instruction:
keyword: "ARG"
matcher: "GO_VERSION"
ignoreDefaultValue: true
would change the matching logic to
# Matches
ARG GO_VERSION=0.1.0
arg GO_VERSION=0.1.0
## Does NOT matches
ARG GO_VERSION
ARG GO_VERSION=
ARG GOLANG_VERSION
ARG RUST_VERSION=GO_VERSION
ARG go_version
Anything else?
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
Todo