Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -9,22 +9,29 @@ 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

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"]
10 changes: 10 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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 "$@"