-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Norman Meier <[email protected]>
- Loading branch information
Showing
4 changed files
with
167 additions
and
220 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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: Docker | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- name: Gather info | ||
id: info | ||
run: echo "tags=$(git describe --tags || git rev-parse HEAD)" >> "$GITHUB_OUTPUT" | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Build image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
push: false | ||
platforms: linux/amd64 | ||
tags: rg.nl-ams.scw.cloud/teritori/teritorid:${{ steps.info.outputs.tags }} |
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
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,66 +1,48 @@ | ||
# syntax=docker/dockerfile:1 | ||
|
||
ARG GO_VERSION="1.19" | ||
ARG RUNNER_IMAGE="gcr.io/distroless/static" | ||
|
||
# -------------------------------------------------------- | ||
# Builder | ||
# -------------------------------------------------------- | ||
|
||
FROM golang:${GO_VERSION}-alpine as builder | ||
|
||
RUN set -eux; apk add --no-cache ca-certificates build-base; apk add git linux-headers | ||
|
||
# Download go dependencies | ||
WORKDIR /teritori | ||
COPY go.* ./ | ||
RUN --mount=type=cache,target=/root/.cache/go-build \ | ||
--mount=type=cache,target=/root/go/pkg/mod \ | ||
go mod download | ||
|
||
# Cosmwasm - download correct libwasmvm version | ||
RUN WASMVM_VERSION=$(go list -m github.com/CosmWasm/wasmvm | cut -d ' ' -f 2) && \ | ||
wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/libwasmvm_muslc.$(uname -m).a \ | ||
-O /lib/libwasmvm_muslc.a | ||
|
||
# Cosmwasm - verify checksum | ||
RUN wget https://github.com/CosmWasm/wasmvm/releases/download/v1.0.0/checksums.txt -O /tmp/checksums.txt && \ | ||
sha256sum /lib/libwasmvm_muslc.a | grep $(cat /tmp/checksums.txt | grep $(uname -m) | cut -d ' ' -f 1) | ||
|
||
# Copy the remaining files | ||
COPY . . | ||
|
||
# Build teritorid binary | ||
RUN --mount=type=cache,target=/root/.cache/go-build \ | ||
--mount=type=cache,target=/root/go/pkg/mod \ | ||
VERSION=$(echo $(git describe --tags) | sed 's/^v//') && \ | ||
COMMIT=$(git log -1 --format='%H') && \ | ||
go build \ | ||
-mod=readonly \ | ||
-tags "netgo,ledger,muslc" \ | ||
-ldflags "-X github.com/cosmos/cosmos-sdk/version.Name="teritori" \ | ||
-X github.com/cosmos/cosmos-sdk/version.AppName="teritorid" \ | ||
-X github.com/cosmos/cosmos-sdk/version.Version=$VERSION \ | ||
-X github.com/cosmos/cosmos-sdk/version.Commit=$COMMIT \ | ||
-X github.com/cosmos/cosmos-sdk/version.BuildTags='netgo,ledger,muslc' \ | ||
-w -s -linkmode=external -extldflags '-Wl,-z,muldefs -static'" \ | ||
-trimpath \ | ||
-o /teritori/build/ \ | ||
./... | ||
# docker build . -t rg.nl-ams.scw.cloud/teritori/teritorid:latest | ||
# docker run --rm -it rg.nl-ams.scw.cloud/teritori/teritorid:latest /bin/sh | ||
FROM golang:1.21-alpine3.17 AS go-builder | ||
ARG arch=x86_64 | ||
|
||
# this comes from standard alpine nightly file | ||
# https://github.com/rust-lang/docker-rust-nightly/blob/master/alpine3.12/Dockerfile | ||
# with some changes to support our toolchain, etc | ||
RUN set -eux; apk add --no-cache ca-certificates build-base; | ||
|
||
RUN apk add git | ||
# NOTE: add these to run with LEDGER_ENABLED=true | ||
# RUN apk add libusb-dev linux-headers | ||
|
||
WORKDIR /code | ||
COPY . /code/ | ||
# See https://github.com/CosmWasm/wasmvm/releases | ||
ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.5.1/libwasmvm_muslc.aarch64.a /lib/libwasmvm_muslc.aarch64.a | ||
ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.5.1/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.x86_64.a | ||
RUN sha256sum /lib/libwasmvm_muslc.aarch64.a | grep b89c242ffe2c867267621a6469f07ab70fc204091809d9c6f482c3fdf9293830 | ||
RUN sha256sum /lib/libwasmvm_muslc.x86_64.a | grep c0f4614d0835be78ac8f3d647a70ccd7ed9f48632bc1374db04e4df2245cb467 | ||
|
||
# Copy the library you want to the final location that will be found by the linker flag `-lwasmvm_muslc` | ||
RUN cp /lib/libwasmvm_muslc.${arch}.a /lib/libwasmvm_muslc.a | ||
|
||
# force it to use static lib (from above) not standard libgo_cosmwasm.so file | ||
RUN LEDGER_ENABLED=false BUILD_TAGS=muslc LINK_STATICALLY=true make build | ||
RUN echo "Ensuring binary is statically linked ..." \ | ||
&& (file /code/build/teritorid | grep "statically linked") | ||
|
||
# -------------------------------------------------------- | ||
# Runner | ||
# -------------------------------------------------------- | ||
FROM alpine:3.17 | ||
|
||
FROM ${RUNNER_IMAGE} | ||
COPY --from=go-builder /code/build/teritorid /usr/bin/teritorid | ||
|
||
COPY --from=builder /teritori/build/teritorid /bin/teritorid | ||
#COPY docker/* /opt/ | ||
#RUN chmod +x /opt/*.sh | ||
|
||
ENV HOME /teritori | ||
WORKDIR $HOME | ||
WORKDIR /opt | ||
|
||
# rest server | ||
EXPOSE 1317 | ||
# tendermint p2p | ||
EXPOSE 26656 | ||
# tendermint rpc | ||
EXPOSE 26657 | ||
EXPOSE 1317 | ||
|
||
ENTRYPOINT ["teritorid"] | ||
CMD ["/usr/bin/teritorid", "version"] |
Oops, something went wrong.