From 2f30f000194a1505c5566b8b84c39c696993a279 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Duchesneau?= Date: Fri, 8 Dec 2023 15:17:47 -0500 Subject: [PATCH] tweak docker ci builds to use alpine and not include firecore --- .github/workflows/docker.yml | 22 +--------- .github/workflows/poller.yml | 79 ------------------------------------ Dockerfile | 34 ++++++++++------ Dockerfile.bundle | 2 +- 4 files changed, 24 insertions(+), 113 deletions(-) delete mode 100644 .github/workflows/poller.yml diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 0cb32c8f..1aa30d91 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -34,10 +34,6 @@ jobs: contents: read packages: write - strategy: - matrix: - go-version: [1.21.x] - outputs: tags: ${{ steps.meta.outputs.tags }} @@ -46,19 +42,6 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Set up Go - uses: actions/setup-go@v4 - with: - go-version: ${{ matrix.go-version }} - - - uses: actions/cache@v3 - with: - path: | - ~/.cache/go-build - ~/go/pkg/mod - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- - name: Branch name id: extract_branch @@ -67,9 +50,6 @@ jobs: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})" echo "##[set-output name=release_train;]$(echo ${GITHUB_REF#refs/heads/release/})" - - name: Build - run: go build -v -ldflags "-X main.version=${{ github.event.ref }}" -o ./fireeth ./cmd/fireeth - - name: Log in to the Container registry uses: docker/login-action@v2 with: @@ -110,6 +90,8 @@ jobs: with: context: . push: true + build-args: | + VERSION=${{ github.event.ref }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/poller.yml b/.github/workflows/poller.yml deleted file mode 100644 index b6c90d64..00000000 --- a/.github/workflows/poller.yml +++ /dev/null @@ -1,79 +0,0 @@ -name: fireeth poller docker image - -on: - push: - tags: - - "v*" - branches: - - "develop" - - "block_any" - workflow_dispatch: - -env: - REGISTRY: ghcr.io - IMAGE_NAME: streamingfast/firehose-core-ethereum - -jobs: - build: - runs-on: ubuntu-20.04 - - permissions: - contents: read - packages: write - - strategy: - matrix: - go-version: [ 1.20.x ] - - outputs: - tags: ${{ steps.meta.outputs.tags }} - - steps: - - uses: actions/checkout@v3 - - - name: Log in to the Container registry - uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Get repo name - id: extract_repo_name - shell: bash - run: | - echo "REPO_NAME=$(basename ${{ github.repository }})" >> $GITHUB_ENV - - - name: Generate docker tags/labels from github build context - id: meta - uses: docker/metadata-action@v4 - 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 - flavor: | - latest=${{ startsWith(github.ref, 'refs/tags/') }} - - - name: Build and push Docker image - uses: docker/build-push-action@v4 - with: - file: ./Dockerfile.poller - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - - - slack-notifications: - if: ${{ !startsWith(github.ref, 'refs/tags/') && github.event_name != 'workflow_dispatch' }} - needs: [ build ] - runs-on: ubuntu-20.04 - steps: - - name: Slack notification - env: - SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} - uses: Ilshidur/action-slack@2.0.2 - with: - args: | - :done: *${{ github.repository }}* Success building docker image from ${{ github.ref_type }} _${{ github.ref_name }}_ (${{ github.actor }}) :sparkling_heart: ```${{ join(needs.build.outputs.tags, ' ') }}``` diff --git a/Dockerfile b/Dockerfile index 048478c9..33c6ebce 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,23 +1,31 @@ -FROM ubuntu:20.04 +FROM golang:1.21-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 . ./ -ADD /fireeth /app/fireeth +RUN go build ./cmd/fireeth + +#### + +FROM alpine:edge + +ENV PATH "$PATH:/app" COPY tools/fireeth/motd_generic /etc/motd COPY tools/fireeth/99-fireeth.sh /etc/profile.d/ - -# On SSH connection, /root/.bashrc is invoked which invokes '/root/.bash_aliases' if existing, -# so we hijack the file to "execute" our specialized bash script RUN echo ". /etc/profile.d/99-fireeth.sh" > /root/.bash_aliases -ENV PATH "$PATH:/app" +RUN apk --no-cache add \ + ca-certificates htop iotop sysstat \ + strace lsof curl jq tzdata -ENTRYPOINT ["/app/fireeth"] +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/fireeth /app/fireeth + +ENTRYPOINT ["/app/fireeth"] diff --git a/Dockerfile.bundle b/Dockerfile.bundle index a9c6b502..3bdfd2f1 100644 --- a/Dockerfile.bundle +++ b/Dockerfile.bundle @@ -4,7 +4,7 @@ ARG SF_VERSION=latest FROM ghcr.io/streamingfast/go-ethereum:$CHAIN_VERSION as chain FROM ghcr.io/streamingfast/firehose-ethereum:$SF_VERSION -COPY --from=chain /app/geth /app/geth +COPY --from=chain /usr/local/bin/geth /app/geth COPY tools/fireeth/motd_node_manager /etc/motd COPY tools/fireeth/scripts/. /usr/local/bin/