diff --git a/Dockerfile b/Dockerfile index 173a19a..d9b7a39 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ # syntax=docker/dockerfile:1 -FROM --platform=${BUILDPLATFORM} golang:1.19-alpine3.15 AS builder +FROM --platform=${BUILDPLATFORM} golang:1.23-alpine3.20 AS builder RUN apk add git @@ -9,8 +9,11 @@ COPY . . ARG TARGETOS TARGETARCH TARGETVARIANT +# Initialize go module if it doesn't exist +RUN go mod init rtsp-to-web || true + ENV CGO_ENABLED=0 -RUN go get \ +RUN go mod tidy \ && go mod download \ && GOOS=${TARGETOS} GOARCH=${TARGETARCH} GOARM=${TARGETVARIANT#"v"} go build -a -o rtsp-to-web @@ -18,13 +21,17 @@ FROM alpine:3.21 WORKDIR /app +RUN apk add --no-cache bash + COPY --from=builder /go/src/app/rtsp-to-web /app/ COPY --from=builder /go/src/app/web /app/web +COPY docker-entrypoint.sh /app/ -RUN mkdir -p /config -COPY --from=builder /go/src/app/config.json /config +RUN mkdir -p /config && \ + chmod +x /app/docker-entrypoint.sh ENV GO111MODULE="on" ENV GIN_MODE="release" -CMD ["./rtsp-to-web", "--config=/config/config.json"] +ENTRYPOINT ["/app/docker-entrypoint.sh"] +CMD ["./rtsp-to-web", "--config=/config/config.json"] \ No newline at end of file diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100644 index 0000000..798cd68 --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +# Write the config string to the config file if CONFIG_STRING is provided +if [ ! -z "$CONFIG_STRING" ]; then + echo "$CONFIG_STRING" > /config/config.json + echo "Config written to /config/config.json" +fi + +# Execute the main command +exec "$@" \ No newline at end of file