Skip to content

add tasks docker #1349

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/workflows/tasks_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Tasks Publish docker image

on:
release:
types: ['released']

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

jobs:
build-and-push-image:
if: (startswith(github.event.release.tag_name, 'v'))

runs-on: ubuntu-latest

permissions:
contents: read
packages: write

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

- name: Log in to the Container registry
uses: docker/login-action@5f4866a30a54f16a52d2ecb4a3898e9e424939cf
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5.5.1
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@v5.3.0
with:
context: .
file: "Dockerfile_tasks"
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest, ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.event.release.tag_name }}
labels: ${{ steps.meta.outputs.labels }}
40 changes: 40 additions & 0 deletions Dockerfile_tasks
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
FROM golang:1.22 as builder
ARG COMMIT_SHA
RUN echo "commit sha: ${COMMIT_SHA}"

# Set the working directory
WORKDIR $GOPATH/src/github.com/diggerhq/digger

# Copy all required source, blacklist files that are not required through `.dockerignore`
COPY . .

# Get the vendor library
RUN go version

# RUN vgo install

# https://github.com/ethereum/go-ethereum/issues/2738
# Build static binary "-getmode=vendor" does not work with go-ethereum

RUN go build -ldflags="-X 'main.Version=${COMMIT_SHA}'" -o tasks_exe ./backend/tasks

# Multi-stage build will just copy the binary to an alpine image.
FROM ubuntu:22.04 as runner
ENV ATLAS_VERSION v0.16.0
ARG COMMIT_SHA
WORKDIR /app

RUN apt-get update && apt-get install -y ca-certificates curl && apt-get install -y git && apt-get clean all
RUN update-ca-certificates

RUN echo "commit sha: ${COMMIT_SHA}"

# install atlas
RUN curl -sSf https://atlasgo.sh | sh


# Copy the binary to the corresponding folder
COPY --from=builder /go/src/github.com/diggerhq/digger/tasks_exe /app/tasks

# Run the binary
ENTRYPOINT ["/app/tasks"]