-
Notifications
You must be signed in to change notification settings - Fork 20
/
local.Dockerfile
61 lines (50 loc) · 1.54 KB
/
local.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
# See rocksdb/README.md for instructions to update rocksdb version
FROM ghcr.io/strangelove-ventures/rocksdb:v7.10.2 AS rocksdb
FROM golang:1.23-alpine AS builder
RUN apk add --update --no-cache\
gcc\
libc-dev\
git\
make\
bash\
g++\
linux-headers\
perl\
snappy-dev\
zlib-dev\
bzip2-dev\
lz4-dev\
zstd-dev\
snappy-static\
zlib-static\
bzip2-static\
lz4-static\
zstd-static
# Install RocksDB headers and static library
COPY --from=rocksdb /rocksdb /rocksdb
WORKDIR /workspace
# Copy the Go Modules manifests
COPY go.mod go.mod
COPY go.sum go.sum
# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
RUN go mod download
# Copy the go source
COPY *.go .
COPY api/ api/
COPY cmd/ cmd/
COPY controllers/ controllers/
COPY internal/ internal/
ARG VERSION
RUN export CGO_ENABLED=1 \
LDFLAGS='-linkmode external -extldflags "-static"' \
CGO_CFLAGS="-I/rocksdb/include" \
CGO_LDFLAGS="-L/rocksdb -L/usr/lib -L/lib -lrocksdb -lstdc++ -lm -lz -lbz2 -lsnappy -llz4 -lzstd";\
go build -tags 'rocksdb pebbledb' -ldflags "-X github.com/strangelove-ventures/cosmos-operator/internal/version.version=$VERSION $LDFLAGS" -a -o manager .
# Build final image from scratch
FROM scratch
LABEL org.opencontainers.image.source=https://github.com/strangelove-ventures/cosmos-operator
WORKDIR /
COPY --from=builder /workspace/manager .
USER 65532:65532
ENTRYPOINT ["/manager"]