re-organize repo and add dockerfile.

This commit is contained in:
Michael Lehmann
2025-02-18 23:21:57 +01:00
parent 977475806c
commit 4042ea2147
16 changed files with 43 additions and 1 deletions

42
Dockerfile Normal file
View File

@@ -0,0 +1,42 @@
FROM golang:alpine AS builder
WORKDIR /app
COPY /app /app
RUN apk update && apk add --no-cache ca-certificates tzdata && update-ca-certificates
# Create appuser
ENV USER=appuser
ENV UID=10001
# See https://stackoverflow.com/a/55757473/12429735RUN
RUN adduser \
--disabled-password \
--gecos "" \
--home "/nonexistent" \
--shell "/sbin/nologin" \
--no-create-home \
--uid "${UID}" \
"${USER}"
RUN go mod download
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o /app/wiz-controller
# Build Runtime Container.
FROM scratch
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /etc/passwd /etc/passwd
COPY --from=builder /etc/group /etc/group
COPY --from=builder /app/wiz-controller /app/wiz-controller
COPY ./app/templates/* /app/templates/
COPY ./app/images/* /app/images/
COPY ./app/static/* /app/static/
# Use an unprivileged user.
USER appuser:appuser
EXPOSE 8080
WORKDIR /app
CMD ["/app/wiz-controller"]

View File

@@ -22,7 +22,7 @@ func loadConfig(path string) (*Config, error) {
} }
func GetConfig() (*Config, error) { func GetConfig() (*Config, error) {
config, err := loadConfig("misc/sample-config.yml") config, err := loadConfig("/config.yml")
if err != nil { if err != nil {
return nil, fmt.Errorf("unable to read config: %w", err) return nil, fmt.Errorf("unable to read config: %w", err)
} }

View File

View File

View File

Before

Width:  |  Height:  |  Size: 8.2 KiB

After

Width:  |  Height:  |  Size: 8.2 KiB

View File

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

View File

Before

Width:  |  Height:  |  Size: 9.1 KiB

After

Width:  |  Height:  |  Size: 9.1 KiB

View File

Before

Width:  |  Height:  |  Size: 50 KiB

After

Width:  |  Height:  |  Size: 50 KiB