Skip to content

Commit 98317e8

Browse files
authored
add tasks docker (#1349)
1 parent 6bbd1e0 commit 98317e8

File tree

2 files changed

+85
-0
lines changed

2 files changed

+85
-0
lines changed

.github/workflows/tasks_release.yml

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Tasks Publish docker image
2+
3+
on:
4+
release:
5+
types: ['released']
6+
7+
env:
8+
REGISTRY: ghcr.io
9+
IMAGE_NAME: ${{ github.repository }}_tasks
10+
11+
jobs:
12+
build-and-push-image:
13+
if: (startswith(github.event.release.tag_name, 'v'))
14+
15+
runs-on: ubuntu-latest
16+
17+
permissions:
18+
contents: read
19+
packages: write
20+
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
25+
- name: Log in to the Container registry
26+
uses: docker/login-action@5f4866a30a54f16a52d2ecb4a3898e9e424939cf
27+
with:
28+
registry: ${{ env.REGISTRY }}
29+
username: ${{ github.actor }}
30+
password: ${{ secrets.GITHUB_TOKEN }}
31+
32+
- name: Extract metadata (tags, labels) for Docker
33+
id: meta
34+
uses: docker/[email protected]
35+
with:
36+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
37+
38+
- name: Build and push Docker image
39+
uses: docker/[email protected]
40+
with:
41+
context: .
42+
file: "Dockerfile_tasks"
43+
push: true
44+
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest, ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.event.release.tag_name }}
45+
labels: ${{ steps.meta.outputs.labels }}

Dockerfile_tasks

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
FROM golang:1.22 as builder
2+
ARG COMMIT_SHA
3+
RUN echo "commit sha: ${COMMIT_SHA}"
4+
5+
# Set the working directory
6+
WORKDIR $GOPATH/src/github.com/diggerhq/digger
7+
8+
# Copy all required source, blacklist files that are not required through `.dockerignore`
9+
COPY . .
10+
11+
# Get the vendor library
12+
RUN go version
13+
14+
# RUN vgo install
15+
16+
# https://github.com/ethereum/go-ethereum/issues/2738
17+
# Build static binary "-getmode=vendor" does not work with go-ethereum
18+
19+
RUN go build -ldflags="-X 'main.Version=${COMMIT_SHA}'" -o tasks_exe ./backend/tasks
20+
21+
# Multi-stage build will just copy the binary to an alpine image.
22+
FROM ubuntu:22.04 as runner
23+
ENV ATLAS_VERSION v0.16.0
24+
ARG COMMIT_SHA
25+
WORKDIR /app
26+
27+
RUN apt-get update && apt-get install -y ca-certificates curl && apt-get install -y git && apt-get clean all
28+
RUN update-ca-certificates
29+
30+
RUN echo "commit sha: ${COMMIT_SHA}"
31+
32+
# install atlas
33+
RUN curl -sSf https://atlasgo.sh | sh
34+
35+
36+
# Copy the binary to the corresponding folder
37+
COPY --from=builder /go/src/github.com/diggerhq/digger/tasks_exe /app/tasks
38+
39+
# Run the binary
40+
ENTRYPOINT ["/app/tasks"]

0 commit comments

Comments
 (0)