-
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.3@sha256:73f06be4578c9987ce560087e2e2ea6485fb605e3910542cadd8fa09fc5f3e31 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.20.3@sha256:1e42bbe2508154c9126d48c2b8a75420c3544343bf86fd041fb7527e017a4b4a
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"]