-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update the Makefile and intorduce Dockerfile to improve lavad build. Notable make targets (for all targets - see Makefile): make build - local build (output in ./build/) make test - run unit-tests make lint - run the linter make docker-build - local build with docker image (host arch) make build-images - build and produce docker images (all archs) make build-image-amd64 - build and produce docker image (linux/amd64) make build-image-amd64 - build and produce docker image (linux/arm64) Other notable changes: - See Makefile for options to turn on/off via LAVA_BUILD_OPTIONS variable - Specifically, use LAVA_BUILD_OPTIONS="static" to build static binary Also updated .dockerignore (notably, added .git/ to avoid the cost). Anyway, the copy only affects the builder stage in docker - nothing is copied to the final image. Also updates .gitignote (primarily some cleanup).
- Loading branch information
1 parent
b2fd20c
commit 41ca04b
Showing
5 changed files
with
254 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,12 @@ | ||
vue/node_modules | ||
vue/dist | ||
release/ | ||
.idea/ | ||
.vscode/ | ||
.DS_Store | ||
notes.txt | ||
vue/src/store/generated/* | ||
vue/src/store/generated/lavanet/lava/lavanet.lava.servicer/index.js | ||
vue/src/store/generated/lavanet/lava/lavanet.lava.servicer/index.ts | ||
vue/src/store/generated/lavanet/lava/lavanet.lava.servicer/module/index.d.ts | ||
vue/src/store/generated/lavanet/lava/lavanet.lava.servicer/module/index.js | ||
vue/src/store/generated/lavanet/lava/lavanet.lava.servicer/module/index.ts | ||
vue/src/store/generated/lavanet/lava/lavanet.lava.user/index.js | ||
vue/src/store/generated/lavanet/lava/lavanet.lava.user/index.ts | ||
vue/src/store/generated/lavanet/lava/lavanet.lava.user/module/index.d.ts | ||
vue/src/store/generated/lavanet/lava/lavanet.lava.user/module/index.js | ||
vue/src/store/generated/lavanet/lava/lavanet.lava.user/module/index.ts | ||
relayer/cmd/relayer/__debug_bin | ||
relayer/.env | ||
testutil/e2e/logs/ | ||
ptnet/ | ||
build/ | ||
vue/src/store/generated/ | ||
vue/node_modules/ | ||
vue/dist/ | ||
scripts/vars/ | ||
testutil/e2e/logs/ | ||
testutil/debugging/ | ||
ts-client/ | ||
.github/ | ||
.git/ | ||
.idea/ | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,27 @@ | ||
vue/node_modules | ||
vue/dist | ||
build/ | ||
release/ | ||
|
||
# Intellij | ||
.idea/ | ||
.vscode/ | ||
|
||
# macOS | ||
.DS_Store | ||
notes.txt | ||
vue/src/store/generated/* | ||
vue/src/store/generated/lavanet/lava/lavanet.lava.servicer/index.js | ||
vue/src/store/generated/lavanet/lava/lavanet.lava.servicer/index.ts | ||
vue/src/store/generated/lavanet/lava/lavanet.lava.servicer/module/index.d.ts | ||
vue/src/store/generated/lavanet/lava/lavanet.lava.servicer/module/index.js | ||
vue/src/store/generated/lavanet/lava/lavanet.lava.servicer/module/index.ts | ||
vue/src/store/generated/lavanet/lava/lavanet.lava.user/index.js | ||
vue/src/store/generated/lavanet/lava/lavanet.lava.user/index.ts | ||
vue/src/store/generated/lavanet/lava/lavanet.lava.user/module/index.d.ts | ||
vue/src/store/generated/lavanet/lava/lavanet.lava.user/module/index.js | ||
vue/src/store/generated/lavanet/lava/lavanet.lava.user/module/index.ts | ||
relayer/cmd/relayer/__debug_bin | ||
relayer/.env | ||
|
||
# vscode | ||
.vscode/ | ||
|
||
# vim | ||
.*.sw? | ||
|
||
# Vue | ||
vue/src/store/generated/ | ||
vue/node_modules | ||
vue/dist | ||
|
||
# Logs and debug | ||
scripts/automation_scripts/automation_results* | ||
testutil/e2e/logs/ | ||
ptnet/ | ||
scripts/vars/ | ||
testutil/debugging/ | ||
ts-client/ | ||
scripts/automation_scripts/automation_results* | ||
|
||
# Misc | ||
scripts/vars/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
# syntax = docker/dockerfile:1.2 | ||
# WARNING! Use with `docker buildx ...` or `DOCKER_BUILDKIT=1 docker build ...` | ||
# to enable --mount feature used below. | ||
|
||
######################################################################## | ||
# Dockerfile for reproducible build of lavad binary and docker image | ||
######################################################################## | ||
|
||
ARG GO_VERSION="1.18.2" | ||
ARG RUNNER_IMAGE="debian:11-slim" | ||
|
||
# -------------------------------------------------------- | ||
# Base | ||
# -------------------------------------------------------- | ||
|
||
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION} as base | ||
|
||
ARG GIT_VERSION | ||
ARG GIT_COMMIT | ||
|
||
# Download debian packages for building | ||
RUN --mount=type=cache,target=/var/cache/apt \ | ||
rm -f /etc/apt/apt.conf.d/docker-clean && \ | ||
apt-get update && \ | ||
apt-get install -yqq --no-install-recommends \ | ||
build-essential \ | ||
ca-certificates \ | ||
curl | ||
|
||
# -------------------------------------------------------- | ||
# Builder | ||
# -------------------------------------------------------- | ||
|
||
FROM --platform=$BUILDPLATFORM base as builder | ||
|
||
ARG TARGETOS | ||
ARG TARGETARCH | ||
|
||
# set GIT_CLONE=true to force 'git clone' of sources from repository | ||
# (useful to compile a specific version, combined with GIT_VERSION). | ||
ARG GIT_CLONE=false | ||
|
||
# Download go dependencies | ||
WORKDIR /lava | ||
COPY go.mod go.sum ./ | ||
RUN --mount=type=cache,target=/root/.cache/go-build \ | ||
--mount=type=cache,target=/go/pkg/mod \ | ||
go mod download | ||
|
||
# Copy the remaining files | ||
COPY . . | ||
|
||
# Git clone the sources if requested | ||
# NOTE TODO: after reset of chain (lava-testnet-1) prefix 'v' to ${GIT_VERISON} | ||
RUN if [ "${GIT_CLONE}" = true ]; then \ | ||
find . -mindepth 1 -delete && \ | ||
git clone --depth 1 --branch ${GIT_VERSION} https://github.com/lavanet/lava . \ | ||
; fi | ||
|
||
# Remove tag v0.4.0 (same v0.4.0-rc2, which was used in the upgrade proposal | ||
# and must always be reported) to not eclipse the v0.4.0-rc2 tag. | ||
# NOTE TODO: after reset of chain (lava-testnet-1) remove this | ||
RUN git tag -d v0.4.0 || true | ||
|
||
# Fix glitch in Makefile for versions < 0.4.3 | ||
# NOTE TODO: after reset of chain (lava-testnet-1) remove this | ||
RUN sed -i 's/whitespace += $(whitespace)/whitespace := $(whitespace) $(whitespace)/g' Makefile | ||
|
||
# Export our version/commit for the Makefile to know (the .git directory | ||
# is not here, so the Makefile cannot infer them). | ||
ENV BUILD_VERSION=${GIT_VERSION} | ||
ENV BUILD_COMMIT=${GIT_COMMIT} | ||
|
||
ENV GOOS=${TARGETOS} | ||
ENV GOARCH=${TARGETARCH} | ||
|
||
# Build lavad binary | ||
RUN --mount=type=cache,target=/root/.cache/go-build \ | ||
--mount=type=cache,target=/go/pkg/mod \ | ||
LAVA_BUILD_OPTIONS="static" make build | ||
|
||
# -------------------------------------------------------- | ||
# Cosmovisor | ||
# -------------------------------------------------------- | ||
|
||
FROM --platform=$BUILDPLATFORM builder as cosmovisor | ||
|
||
# Download Cosmovisor | ||
RUN --mount=type=cache,target=/root/.cache/go-build \ | ||
--mount=type=cache,target=/go/pkg/mod \ | ||
go get github.com/cosmos/cosmos-sdk/cosmovisor/cmd/cosmovisor@v1.0.0 \ | ||
&& go install github.com/cosmos/cosmos-sdk/cosmovisor/cmd/cosmovisor@v1.0.0 | ||
|
||
|
||
# -------------------------------------------------------- | ||
# Runner-base | ||
# -------------------------------------------------------- | ||
|
||
# Download debian packages for runner | ||
|
||
FROM ${RUNNER_IMAGE} | ||
|
||
COPY --from=builder /lava/build/lavad /bin/lavad | ||
|
||
ENV HOME /lava | ||
WORKDIR $HOME | ||
|
||
ENTRYPOINT ["/bin/lavad"] |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters