Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Dockerfile #18

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
ARG IMG_TAG=latest

# Compile the kyved binary
FROM golang:1.19-alpine AS kyved-builder

WORKDIR /go/src
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 PACKAGES make
RUN apk add --no-cache $PACKAGES
RUN CGO_ENABLED=0 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"]
33 changes: 32 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
COMMIT := $(shell git log -1 --format='%H')
VERSION := v1.0.0 # $(shell echo $(shell git describe --tags) | sed 's/^v//')
VERSION := v1.0.0
# $(shell echo $(shell git describe --tags) | sed 's/^v//')

DENOM ?= ukyve
TEAM_TGE ?= 2023-03-14T14:03:14
Expand Down Expand Up @@ -70,6 +71,36 @@ release:
@rm kyved
@echo "✅ Completed release creation!"

###############################################################################
### Docker Build ###
###############################################################################

# Build a release image
.PHONY: docker-image
docker-image:
@DOCKER_BUILDKIT=1 docker build -t kyve-network/kyve:${VERSION} .

# Build a release nonroot image
.PHONY: docker-image-nonroot
docker-image-nonroot:
@DOCKER_BUILDKIT=1 docker build \
--build-arg IMG_TAG="nonroot" \
-t kyve-network/kyve:${VERSION}-nonroot .

# Build a release debug image
.PHONY: docker-image-debug
docker-image-debug:
@DOCKER_BUILDKIT=1 docker build \
--build-arg IMG_TAG="debug" \
-t kyve-network/kyve:${VERSION}-debug .

# Build a release debug-nonroot image
.PHONY: docker-image-debug-nonroot
docker-image-debug-nonroot:
@DOCKER_BUILDKIT=1 docker build \
--build-arg IMG_TAG="debug-nonroot" \
-t kyve-network/kyve:${VERSION}-debug-nonroot .

###############################################################################
### Development ###
###############################################################################
Expand Down