mirror of
https://github.com/wneessen/logranger.git
synced 2024-11-22 12:50:50 +01:00
Add Dockerfile for project build
Introduced Dockerfile to manage the build process for the project, including its dependencies. This development will standardize the environment, thus making it easier for others to build and run the app. Also added necessary 'passwd' and 'group' files in 'support-files' directory for managing user details in Docker.
This commit is contained in:
parent
44473579de
commit
a5c8e5962b
3 changed files with 36 additions and 0 deletions
34
Dockerfile
Normal file
34
Dockerfile
Normal file
|
@ -0,0 +1,34 @@
|
|||
# SPDX-FileCopyrightText: 2023 Winni Neessen <wn@neessen.dev>
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
## Build first
|
||||
FROM golang:alpine AS builder
|
||||
RUN mkdir /builddir
|
||||
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"' \
|
||||
-o /builddir/logranger github.com/wneessen/logranger/cmd/server
|
||||
|
||||
## 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"]
|
1
support-files/group
Normal file
1
support-files/group
Normal file
|
@ -0,0 +1 @@
|
|||
logranger:x:1000:logranger
|
1
support-files/passwd
Normal file
1
support-files/passwd
Normal file
|
@ -0,0 +1 @@
|
|||
logranger:x:1000:1000:Logranger user:/logranger:/bin/false
|
Loading…
Reference in a new issue