2023-12-27 18:25:55 +01:00
|
|
|
# SPDX-FileCopyrightText: 2023 Winni Neessen <wn@neessen.dev>
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
|
|
|
|
## Build first
|
2024-05-16 10:36:37 +02:00
|
|
|
FROM golang:alpine@sha256:f1fe698725f6ed14eb944dc587591f134632ed47fc0732ec27c7642adbe90618 AS builder
|
2024-02-08 14:32:29 +01:00
|
|
|
RUN mkdir /builddithur
|
2023-12-27 18:25:55 +01:00
|
|
|
ADD cmd/ /builddir/cmd/
|
|
|
|
ADD template/ /builddir/template
|
|
|
|
ADD *.go /builddir/
|
|
|
|
ADD plugins/ /builddir/plugins
|
|
|
|
ADD go.mod /builddir/
|
|
|
|
ADD go.sum /builddir/
|
|
|
|
WORKDIR /builddir
|
|
|
|
RUN go mod tidy
|
|
|
|
RUN go mod download
|
|
|
|
RUN go mod verify
|
|
|
|
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -ldflags \
|
|
|
|
'-w -s -extldflags "-static"' \
|
2024-03-21 15:39:31 +01:00
|
|
|
-o /builddir/logranger github.com/wneessen/logranger/cmd/server
|
2023-12-27 18:25:55 +01:00
|
|
|
|
|
|
|
## Create scratch image
|
|
|
|
FROM scratch
|
|
|
|
LABEL maintainer="wn@neessen.dev"
|
|
|
|
COPY ["support-files/passwd", "/etc/passwd"]
|
|
|
|
COPY ["support-files/group", "/etc/group"]
|
|
|
|
COPY --chown=logranger ["README.md", "/logranger/README.md"]
|
|
|
|
COPY --chown=logranger ["etc/logranger.toml", "/etc/logranger/"]
|
|
|
|
COPY --from=builder ["/builddir/logranger", "/logranger/logranger"]
|
|
|
|
WORKDIR /logranger
|
|
|
|
USER logranger
|
|
|
|
VOLUME ["/etc/logranger"]
|
|
|
|
EXPOSE 9099
|
|
|
|
ENTRYPOINT ["/logranger/logranger"]
|