I was looking at this answer https://stackoverflow.com/a/37904830/169252 to try to solve my problem.
However, it doesn't seem to work for my case
ENV API="list,create,delete"
ENV ID="1-1"
ENV VERBO=5
ENTRYPOINT /myapp --id=$ID --api=$API --origin="*" --trace --metrics --verbosity=$VERBO --allow-insecure
However, I always get invalid value "" for flag -verbosity:
if not provided by the docker run
command, i.e.
docker run -p 80:8080 $DOCKER_IMAGE
.
However, if I run it as
docker run -p 80:8080 -e VERBO=4 $DOCKER_IMAGE
, it seems to work (have another issue right now after this so can't post actual result).
Am I using this correctly? The idea is that VERBO
is an optional argument and doesn't need to be set by docker run
-only if so desired.
This is the complete Dockerfile:
FROM golang:1.19-alpine as builder
RUN apk add --no-cache make gcc musl-dev linux-headers git
WORKDIR /go/myapp
COPY . .
ARG GOPROXY
RUN go mod download
RUN make myapp
ENV API="list,create,delete"
ENV ID="1-1"
ENV VERBO=5
FROM alpine:latest
RUN apk add --no-cache ca-certificates
COPY --from=builder /go/myapp/build/myapp /
ENTRYPOINT /myapp --id=$ID --api=$API --origin="*" --trace --metrics --verbosity=$VERBO --allow-insecure