perf: dockerfiles (#14793)

This commit is contained in:
Robert Zaremba
2023-01-26 21:21:54 +01:00
committed by GitHub
parent 938143f038
commit be9bd7a8c1
9 changed files with 82 additions and 77 deletions
+15 -13
View File
@@ -10,15 +10,20 @@
# > docker run -it -p 26657:26657 -p 26656:26656 -v ~/.simappcli:/root/.simapp simapp simd keys add foo
# > docker run -it -p 26657:26657 -p 26656:26656 -v ~/.simappcli:/root/.simapp simapp simd keys list
# TODO: demo connecting rest-server (or is this in server now?)
FROM --platform=$BUILDPLATFORM golang:1.19-alpine AS build-env
# Install minimum necessary dependencies
ENV PACKAGES curl make git libc-dev bash gcc linux-headers eudev-dev python3
RUN apk add --no-cache $PACKAGES
# bullseye already comes with build dependencies, so we don't need anything extra to install
FROM --platform=$BUILDPLATFORM golang:1.19-bullseye AS build-env
# Set working directory for the build
WORKDIR /go/src/github.com/cosmos/cosmos-sdk
# optimization: if go.sum didn't change, docker will use cached image
COPY go.mod go.sum ./
COPY collections/go.mod collections/go.sum ./collections/
COPY store/go.mod store/go.sum ./store/
RUN go mod download
# Add source files
COPY . .
@@ -30,17 +35,14 @@ ARG TARGETOS TARGETARCH
RUN GOOS=$TARGETOS GOARCH=$TARGETARCH make build
# Final image
FROM alpine:edge
# Final image, without build artifacts. `/base` already contains openssl, glibc and all required libs to start an app
FROM gcr.io/distroless/base
# Install ca-certificates
RUN apk add --update ca-certificates
EXPOSE 26656 26657 1317 9090
# Run simd by default, omit entrypoint to ease using container with simcli
CMD ["simd"]
STOPSIGNAL SIGTERM
WORKDIR /root
# Copy over binaries from the build-env
COPY --from=build-env /go/src/github.com/cosmos/cosmos-sdk/build/simd /usr/bin/simd
EXPOSE 26656 26657 1317 9090
# Run simd by default, omit entrypoint to ease using container with simcli
CMD ["simd"]