diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..2dbecbe0 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,10 @@ +.idea +.vscode +node_modules +release +.DS_Store +/scripts/ +test/.env +chain + +build diff --git a/.github/README.md b/.github/README.md index bd63dfcf..ec21cb2b 100644 --- a/.github/README.md +++ b/.github/README.md @@ -38,3 +38,19 @@ You can verify the build information using the following command: ```shell kyved info ``` + +### Building docker image + +#### Root +To create a regular `kyve-network/kyve:${VERSION}` docker image with `kyved` binary only execute: +```bash +make docker-image +``` +To create the corresponding debug image containing a `sh` shell execute `make docker-image-debug`. + +#### Nonroot +To create a nonroot docker image `kyve-network/kyve:${VERSION}-nonroot` running with user `nonroot:65532`: +```bash +make docker-image-nonroot +``` +To create the corresponding debug image `kyve-network/kyve:${VERSION}-debug-nonroot` execute `make docker-image-debug-nonroot`. \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..de9c3199 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +ARG IMG_TAG=latest + +# Compile the kyved binary +FROM golang:1.20-alpine AS kyved-builder + +# Install make +RUN apk add --no-cache make + +WORKDIR /go/src + +# Install dependencies +COPY go.mod go.sum* ./ +RUN --mount=type=cache,target=/root/.cache/go-build \ + --mount=type=cache,target=/root/go/pkg/mod \ + go mod download +COPY . . + +ENV ENV=mainnet +RUN make install + +# Copy binary to a distroless container +FROM gcr.io/distroless/static-debian11:$IMG_TAG + +COPY --from=kyved-builder "/go/bin/kyved" /usr/local/bin/ +EXPOSE 26656 26657 1317 9090 + +ENTRYPOINT ["kyved"] \ No newline at end of file diff --git a/Makefile b/Makefile index 84623b11..50784932 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,8 @@ COMMIT := $(shell git log -1 --format='%H') GO_VERSION := $(shell go version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f1,2) -VERSION := v1.4.0 # $(shell echo $(shell git describe --tags) | sed 's/^v//') + +# VERSION := $(shell echo $(shell git describe --tags) | sed 's/^v//') +VERSION := v1.4.0 TEAM_ALLOCATION := 165000000000000 ifeq ($(ENV),kaon) @@ -73,6 +75,36 @@ release: ensure_environment ensure_version @rm kyved @echo "✅ Completed release creation!" +############################################################################### +### Docker Build ### +############################################################################### + +# Build a release image +docker-image: + @DOCKER_BUILDKIT=1 docker build -t kyve-network/kyve:${VERSION} . + @echo "✅ Completed docker image build!" + +# Build a release nonroot image +docker-image-nonroot: + @DOCKER_BUILDKIT=1 docker build \ + --build-arg IMG_TAG="nonroot" \ + -t kyve-network/kyve:${VERSION}-nonroot . + @echo "✅ Completed docker image build! (nonroot)" + +# Build a release debug image +docker-image-debug: + @DOCKER_BUILDKIT=1 docker build \ + --build-arg IMG_TAG="debug" \ + -t kyve-network/kyve:${VERSION}-debug . + @echo "✅ Completed docker image build! (debug)" + +# Build a release debug-nonroot image +docker-image-debug-nonroot: + @DOCKER_BUILDKIT=1 docker build \ + --build-arg IMG_TAG="debug-nonroot" \ + -t kyve-network/kyve:${VERSION}-debug-nonroot . + @echo "✅ Completed docker image build! (debug-nonroot)" + ############################################################################### ### Checks ### ###############################################################################