Skip to content

Commit

Permalink
add docker image push ci
Browse files Browse the repository at this point in the history
  • Loading branch information
YancyParker committed Jul 8, 2024
1 parent 20e3b85 commit d69d1ca
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 52 deletions.
55 changes: 33 additions & 22 deletions .github/workflows/publish-docker-image.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,42 @@
name: Build and Publish Docker Image
# source: https://docs.github.com/en/enterprise-cloud@latest/actions/publishing-packages/publishing-docker-images
name: Create and publish a Docker image

on:
push:
branches:
- main
tags:
- "v[0-9]+.[0-9]+.[0-9]+" # Push events to matching v*, i.e. v1.0, v20.15.10
- "v[0-9]+.[0-9]+.[0-9]+-rc*" # Push events to matching v*, i.e. v1.0-rc1, v20.15.10-rc5
branches: ['main']

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
setup-build-publish:
name: Setup, Build and Publish
build-and-push-image:
runs-on: ubuntu-latest
environment: production
permissions:
contents: read
packages: write

steps:
- name: Checkout
uses: actions/checkout@v4
- name: Checkout repository
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/[email protected]
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/[email protected]
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and Push Docker Image
uses: docker/build-push-action@v2
with:
file: ./contrib/images/fiammad/Dockerfile
push: true
tags: fiammachain/fiammad:${{ github.ref == 'refs/tags/*' && github.ref || github.sha }}
- name: Build and push Docker image
uses: docker/[email protected]
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
9 changes: 0 additions & 9 deletions contrib/images/fiammad/Dockerfile → Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ FROM golang:1.22 AS build-env

# TARGETPLATFORM should be one of linux/amd64 or linux/arm64.
ARG TARGETPLATFORM="linux/amd64"
# Version to build. Default is empty
ARG VERSION

ARG LEDGER_ENABLED="false"
# Cosmos build options
ARG COSMOS_BUILD_OPTIONS=""

Expand All @@ -29,10 +26,6 @@ COPY go.mod go.sum .
RUN go mod download
# Then copy everything else
COPY . .
# If version is set, then checkout this version
RUN if [ -n "${VERSION}" ]; then \
git checkout -f ${VERSION}; \
fi

RUN LEDGER_ENABLED=$LEDGER_ENABLED \
BUILD_TAGS=$BUILD_TAGS \
Expand All @@ -44,8 +37,6 @@ FROM debian:bookworm-slim AS run

RUN apt-get update && apt-get install -y bash curl jq wget pkg-config openssl libssl-dev

# Label should match your github repo
LABEL org.opencontainers.image.source="https://github.com/fiamma-chain/fiammad:${VERSION}"

# Install libraries
# Cosmwasm - Download correct libwasmvm version
Expand Down
11 changes: 9 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,13 @@ test:
###############################################################################

build-docker:
$(MAKE) -C contrib/images fiammad
docker build \
-t fiammachain/fiammad \
--build-arg GIT_VERSION=$(VERSION) \
--build-arg GIT_COMMIT=$(COMMIT) \
-f Dockerfile .

.PHONY: build-docker
docker-rmi:
docker rmi fiammachain/fiammad 2>/dev/null; true

.PHONY: build-docker docker-rmi
13 changes: 0 additions & 13 deletions contrib/images/Makefile

This file was deleted.

4 changes: 2 additions & 2 deletions scripts/docker/node.docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ services:
image: fiammachain/fiammad
build:
context: ../../
dockerfile: ../../contrib/images/fiammad/Dockerfile
dockerfile: ../../Dockerfile
volumes:
- ../testnet-nodes/${NODE_NAME}:/root/.fiamma
- ../setup_node.sh:/entrypoint.sh
Expand All @@ -14,7 +14,7 @@ services:
node-runner:
image: fiammachain/fiammad
build:
dockerfile: ../../contrib/images/fiammad/Dockerfile
dockerfile: ../../Dockerfile
volumes:
- ../testnet-nodes/${NODE_NAME}:/root/.fiamma
command: start
Expand Down
8 changes: 4 additions & 4 deletions scripts/docker/validator.docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ services:
image: fiammachain/fiammad
build:
context: ../../
dockerfile: ./contrib/images/fiammad/Dockerfile
dockerfile: ../../Dockerfile
volumes:
- ../testnet-nodes/${NODE_NAME}:/root/.fiamma
- ../setup_node.sh:/entrypoint.sh
Expand All @@ -14,8 +14,8 @@ services:
validator-setup:
image: fiammachain/fiammad
build:
context: ../
dockerfile: ./contrib/images/fiammad/Dockerfile
context: ../../
dockerfile: ../../Dockerfile
volumes:
- ../testnet-nodes/${NODE_NAME}:/root/.fiamma
- ../setup_validator.sh:/entrypoint.sh
Expand All @@ -25,7 +25,7 @@ services:
image: fiammachain/fiammad
build:
context: ../../
dockerfile: ./contrib/images/fiammad/Dockerfile
dockerfile: ../../Dockerfile
ports:
- 26656:26656
- 26657:26657
Expand Down

0 comments on commit d69d1ca

Please sign in to comment.