-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathDockerfile
66 lines (50 loc) · 1.85 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
58
59
60
61
62
63
64
65
66
FROM --platform=$BUILDPLATFORM golang:1.24.0@sha256:2b1cbf278ce05a2a310a3d695ebb176420117a8cfcfcc4e5e68a1bef5f6354da 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.3@sha256:a8560b36e8b8210634f77d9f7f9efd7ffa463e380b75e2e74aff4511df3ef88c
ARG VERSION
ARG CREATED
ARG COMMIT
LABEL \
org.opencontainers.image.authors="src-doo" \
org.opencontainers.image.created=$CREATED \
org.opencontainers.image.version=$VERSION \
org.opencontainers.image.revision=$COMMIT \
org.opencontainers.image.url="https://github.com/src-doo/netbox-ssot" \
org.opencontainers.image.documentation="https://github.com/src-doo/netbox-ssot/blob/main/README.md" \
org.opencontainers.image.source="https://github.com/src-doo/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
# Also allow deprecated ssh algorithims for older devices
# See https://github.com/SRC-doo/netbox-ssot/issues/498
RUN mkdir -p /home/netbox/.ssh/ && \
cat <<EOF > /home/netbox/.ssh/config
Host *
HostKeyAlgorithms +ssh-rsa
PubkeyAcceptedKeyTypes +ssh-rsa
EOF
WORKDIR /app
COPY --from=builder --chown=netbox:netbox /app/cmd/netbox-ssot/main ./main
CMD ["./main"]