Skip to content

Commit

Permalink
add Docker images (#156)
Browse files Browse the repository at this point in the history
* add Docker images

* remove branch builds
  • Loading branch information
fschoell authored Sep 4, 2024
1 parent 6b410f6 commit d039e46
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 16 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Build docker image

on:
push:
tags:
- "v*"
branches:
- "dockerbuild"
- "develop"
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:

build:
runs-on: ubuntu-22.04

permissions:
contents: read
packages: write

outputs:
tags: ${{ steps.meta.outputs.tags }}

steps:
- uses: actions/checkout@v4

- name: Branch name
id: extract_branch
shell: bash
run: |
echo "branch=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_OUTPUT
echo "release_train=$(echo ${GITHUB_REF#refs/heads/release/})" >> $GITHUB_OUTPUT
echo "core_version=$(grep 'github.com/streamingfast/firehose-core' go.mod | cut -d' ' -f2)" >> $GITHUB_OUTPUT
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Generate docker tags/labels from github build context
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=tag
type=sha,prefix=,enable=true
type=raw,enable=${{ github.ref == 'refs/heads/develop' }},value=develop
type=raw,enable=${{ startsWith(github.ref, 'refs/heads/release/v') }},value=${{ steps.extract_branch.outputs.release_train }}
flavor: |
latest=${{ startsWith(github.ref, 'refs/tags/') }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: true
build-args: |
VERSION=${{ github.event.ref }}
COREVERSION=${{ steps.extract_branch.outputs.core_version }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
49 changes: 33 additions & 16 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,41 @@
# syntax=docker/dockerfile:1.2
ARG COREVERSION="latest"

FROM ubuntu:20.04
FROM golang:1.22-alpine as build
WORKDIR /app

RUN DEBIAN_FRONTEND=noninteractive apt-get update && \
apt-get -y install -y \
ca-certificates libssl1.1 vim htop iotop sysstat \
dstat strace lsof curl jq tzdata && \
rm -rf /var/cache/apt /var/lib/apt/lists/*
COPY go.mod go.sum ./
RUN go mod download

RUN rm /etc/localtime && ln -snf /usr/share/zoneinfo/America/Montreal /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
COPY . ./

RUN mkdir /tmp/wasmer-install && cd /tmp/wasmer-install && \
curl -L https://github.com/wasmerio/wasmer/releases/download/2.3.0/wasmer-linux-amd64.tar.gz | tar xzf - && \
mv lib/libwasmer.a lib/libwasmer.so /usr/lib/ && cd / && rm -rf /tmp/wasmer-install
# to get buildinfo in golang
RUN apk add git
ARG VERSION="dev"
RUN go build -v -ldflags "-X main.version=${VERSION}" ./cmd/fireantelope

ADD /fireantelope /app/fireantelope
####

COPY tools/fireantelope/motd_generic /etc/
COPY tools/fireantelope/motd_node_manager /etc/
COPY tools/fireantelope/99-firehose.sh /etc/profile.d/
COPY tools/fireantelope/scripts/* /usr/local/bin
FROM ghcr.io/streamingfast/firehose-core:${COREVERSION} as core

####

FROM alpine:3

ENV PATH "$PATH:/app"

#COPY tools/fireeth/motd_generic /etc/motd
#COPY tools/fireeth/99-fireeth.sh /etc/profile.d/
#RUN echo ". /etc/profile.d/99-fireeth.sh" > /root/.bash_aliases

RUN apk --no-cache add \
ca-certificates htop iotop sysstat \
strace lsof curl jq tzdata bash

RUN mkdir -p /app/ && curl -Lo /app/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/v0.4.12/grpc_health_probe-linux-amd64 && chmod +x /app/grpc_health_probe

WORKDIR /app

COPY --from=build /app/fireantelope /app/fireantelope
COPY --from=core /app/firecore /app/firecore

ENTRYPOINT ["/app/fireantelope"]

0 comments on commit d039e46

Please sign in to comment.