-
Notifications
You must be signed in to change notification settings - Fork 6
/
Dockerfile
57 lines (42 loc) · 1.58 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
FROM --platform=$BUILDPLATFORM golang:1.23.4@sha256:574185e5c6b9d09873f455a7c205ea0514bfd99738c5dc7750196403a44ed4b7 AS builder
ARG TARGETOS
ARG TARGETARCH
ARG VERSION
ARG CREATED
ARG COMMIT
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY ./internal ./internal
COPY ./cmd ./cmd
RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH \
go build -trimpath -ldflags="-s -w \
-X 'main.version=$VERSION' \
-X 'main.commit=$COMMIT' \
-X 'main.date=$CREATED' \
" -o ./cmd/netbox-ssot/main ./cmd/netbox-ssot/main.go
FROM alpine:3.21.0@sha256:21dc6063fd678b478f57c0e13f47560d0ea4eeba26dfc947b2a4f81f686b9f45
ARG VERSION
ARG CREATED
ARG COMMIT
LABEL \
org.opencontainers.image.authors="bl4ko" \
org.opencontainers.image.created=$CREATED \
org.opencontainers.image.version=$VERSION \
org.opencontainers.image.revision=$COMMIT \
org.opencontainers.image.url="https://github.com/bl4ko/netbox-ssot" \
org.opencontainers.image.documentation="https://github.com/bl4ko/netbox-ssot/blob/main/README.md" \
org.opencontainers.image.source="https://github.com/bl4ko/netbox-ssot" \
org.opencontainers.image.title="Netbox-ssot" \
org.opencontainers.image.description="Microservice for syncing Netbox with multiple external sources."
# Install openssh required for netconf
RUN apk add --no-cache openssh
# Create a netbox user and group
RUN addgroup -S -g 10001 netbox && \
adduser -S -u 10001 -G netbox netbox && \
mkdir -p /app && \
chown -R netbox:netbox /app
USER netbox:netbox
WORKDIR /app
COPY --from=builder --chown=netbox:netbox /app/cmd/netbox-ssot/main ./main
CMD ["./main"]