forked from eclipse-iofog/nats-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.edge
More file actions
55 lines (41 loc) · 1.93 KB
/
Copy pathDockerfile.edge
File metadata and controls
55 lines (41 loc) · 1.93 KB
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
# Build iofog-nats wrapper and install nats-server for arm/v7 and riscv64 edge targets.
# golang:1.26.4-alpine — sha256:3ad57304ad93bbec8548a0437ad9e06a455660655d9af011d58b993f6f615648
FROM --platform=$BUILDPLATFORM golang:1.26.4-alpine@sha256:3ad57304ad93bbec8548a0437ad9e06a455660655d9af011d58b993f6f615648 AS go-builder
ARG TARGETOS
ARG TARGETARCH
ARG TARGETVARIANT
WORKDIR /build
COPY . .
ENV CGO_ENABLED=0
RUN if [ "${TARGETARCH}" = "arm" ] && [ "${TARGETVARIANT}" = "v7" ]; then export GOARM=7; fi && \
GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -trimpath -ldflags="-s -w" -o iofog-nats ./cmd/iofog-nats
RUN if [ "${TARGETARCH}" = "arm" ] && [ "${TARGETVARIANT}" = "v7" ]; then export GOARM=7; fi && \
GOOS=${TARGETOS} GOARCH=${TARGETARCH} go install github.com/nats-io/nats-server/v2@v2.14.3
RUN mkdir -p /out && \
find /go/bin -name "nats-server" -type f -exec cp {} /out/nats-server \;
# alpine:3.22
FROM alpine:3.22@sha256:14358309a308569c32bdc37e2e0e9694be33a9d99e68afb0f5ff33cc1f695dce AS runtime-staging
RUN apk add --no-cache ca-certificates tzdata shadow curl grep && \
adduser -D -u 10000 -h /home/runner runner && \
mkdir -p /home/runner/run /home/runner/data /home/runner/bin /home/runner/nats/jwt && \
chown -R runner:runner /home/runner
COPY --from=go-builder /build/iofog-nats /home/runner/bin/iofog-nats
COPY --from=go-builder /out/nats-server /home/runner/bin/nats-server
COPY LICENSE /licenses/LICENSE
RUN rm -rf /sbin/apk \
/lib/apk \
/etc/apk \
/var/cache/apk
FROM scratch
ARG OCI_SOURCE_REPO
ARG OCI_VERSION
ARG OCI_REVISION
ARG NATS_DISTRIBUTION
LABEL org.opencontainers.image.source="${OCI_SOURCE_REPO}" \
org.opencontainers.image.version="${OCI_VERSION}" \
org.opencontainers.image.revision="${OCI_REVISION}" \
distribution="${NATS_DISTRIBUTION}"
COPY --from=runtime-staging / /
USER 10000
WORKDIR /home/runner
CMD ["/home/runner/bin/iofog-nats"]