Skip to content

Commit 74fc7c6

Browse files
fix: reintroduce gaia docker builds (#3199)
* Set UID and GUID to 1025 in Dockerfile This is for compatibility with interchaintest, since it will chown files to that UID/GUID * Reenable docker builds. They execute on the main branch, releases, and on workflow dispatch. Also get rid of the Dockerfile and use just the e2e one * add changelog entry * Only run docker build on GIT_DIFF * Nightly docker builds, plus add a DOCKER_README
1 parent cafd702 commit 74fc7c6

File tree

6 files changed

+72
-49
lines changed

6 files changed

+72
-49
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- Reintroduce docker builds for gaia and make them compatible with
2+
interchaintest ([\#3199](https://github.com/cosmos/gaia/pull/3199))

.github/workflows/docker-push.yml

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22
name: Create and publish a Docker image
33

44
on:
5-
push:
6-
branches: ['release']
5+
schedule:
6+
- cron: "0 0 * * *"
7+
release:
8+
types: [published]
9+
workflow_dispatch:
710

811
env:
912
REGISTRY: ghcr.io
@@ -20,6 +23,19 @@ jobs:
2023
- name: Checkout repository
2124
uses: actions/checkout@v4
2225

26+
- uses: technote-space/get-diff-action@v6.1.2
27+
id: git_diff
28+
with:
29+
PATTERNS: |
30+
**/*.go
31+
go.mod
32+
go.sum
33+
**/go.mod
34+
**/go.sum
35+
**/Makefile
36+
Makefile
37+
Dockerfile
38+
2339
- name: Log in to the Container registry
2440
uses: docker/login-action@v3.2.0
2541
with:
@@ -32,20 +48,14 @@ jobs:
3248
uses: docker/metadata-action@v5.5.1
3349
with:
3450
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
51+
flavor: "latest=false"
3552

36-
- name: Build and push Docker image
53+
- name: Build and push docker image
3754
uses: docker/build-push-action@v6.1.0
3855
with:
3956
context: .
57+
file: Dockerfile
4058
push: true
4159
tags: ${{ steps.meta.outputs.tags }}
4260
labels: ${{ steps.meta.outputs.labels }}
43-
44-
- name: Build and push e2e docker image
45-
uses: docker/build-push-action@v6.1.0
46-
with:
47-
context: .
48-
file: Dockerfile.e2e
49-
push: true
50-
tags: ${{ steps.meta.outputs.tags }}-e2e
51-
labels: ${{ steps.meta.outputs.labels }}
61+
if: env.GIT_DIFF

DOCKER_README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Gaia Docker image
2+
3+
There's a `gaia` docker image built on a nightly basis, as well as for every
4+
release tag, and pushed to `ghcr.io/cosmos/gaia`. It's built from the
5+
[`Dockerfile`](./Dockerfile) in this directory.
6+
7+
The images contain statically compiled `gaiad` binaries running on an `alpine`
8+
container. By default, `gaiad` runs as user `nonroot`, with UID/GUID `1025`.
9+
The image exposes ports `26656,26657,1317,9090`. This is how the `gaiad` is
10+
compiled:
11+
12+
```Dockerfile
13+
RUN LEDGER_ENABLED=false LINK_STATICALLY=true BUILD_TAGS=muslc make build
14+
```
15+
16+
Since the image has an entrypoint of `gaiad start`, you can use it to start a
17+
node by mounting in a `.gaia` config directory. So, for instance, you can start
18+
a `v17.3.0` node running a chain configured at `$HOME/.gaia` by running:
19+
20+
```bash
21+
docker run --rm -it -v "$HOME/.gaia:/opt/gaia" ghcr.io/cosmos/gaia:v17.3.0 --home /opt/gaia
22+
```
23+
24+
Of course, you can also use the images to just run generic gaia commands:
25+
26+
```bash
27+
docker run --rm -it --entrypoint gaiad -v "$HOME/.gaia:/opt/gaia" ghcr.io/cosmos/gaia:v17.3.0 q tendermint-validator-set --home /opt/gaia
28+
```
29+
30+
## Building
31+
32+
The images are built by workflow
33+
[docker-push.yml](./.github/workflows/docker-push.yml). This workflow is
34+
invoked on release as well as every night, and may be invoked manually by
35+
people to build an arbitrary branch. It uses the `docker/metadata-action` to
36+
decide how to tag the image, according to the following rules:
37+
38+
* If invoked via schedule, the image is tagged `nightly` and `main` (since it's a build of the `main` branch)
39+
* If invoked from a release, including an rc, it is tagged with the release tag
40+
* If invoked manually on a branch, it is tagged with the branch name
41+
42+
**NOTE:** To avoid surprising users, there is no `latest` tag generated.

Dockerfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
# Info on how to use this docker image can be found in DOCKER_README.md
12
ARG IMG_TAG=latest
23

34
# Compile the gaiad binary
45
FROM golang:1.22-alpine AS gaiad-builder
56
WORKDIR /src/app/
6-
ENV PACKAGES="curl make git libc-dev bash file gcc linux-headers eudev-dev python3"
7+
ENV PACKAGES="curl make git libc-dev bash file gcc linux-headers eudev-dev"
78
RUN apk add --no-cache $PACKAGES
89

910
# See https://github.com/CosmWasm/wasmvm/releases
@@ -18,13 +19,14 @@ COPY go.mod go.sum* ./
1819
RUN go mod download
1920

2021
COPY . .
21-
RUN LEDGER_ENABLED=true LINK_STATICALLY=true BUILD_TAGS=muslc make build
22+
RUN LEDGER_ENABLED=false LINK_STATICALLY=true BUILD_TAGS=muslc make build
2223
RUN echo "Ensuring binary is statically linked ..." \
2324
&& file /src/app/build/gaiad | grep "statically linked"
2425

2526
FROM alpine:$IMG_TAG
2627
RUN apk add --no-cache build-base
27-
RUN adduser -D nonroot
28+
RUN addgroup -g 1025 nonroot
29+
RUN adduser -D nonroot -u 1025 -G nonroot
2830
ARG IMG_TAG
2931
COPY --from=gaiad-builder /src/app/build/gaiad /usr/local/bin/
3032
EXPOSE 26656 26657 1317 9090

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ endif
285285
.PHONY: run-tests $(TEST_TARGETS)
286286

287287
docker-build-debug:
288-
@docker build -t cosmos/gaiad-e2e -f e2e.Dockerfile .
288+
@docker build -t cosmos/gaiad-e2e -f Dockerfile .
289289

290290
# TODO: Push this to the Cosmos Dockerhub so we don't have to keep building it
291291
# in CI.

e2e.Dockerfile

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)