From 03c6f4db503919c34ccc65ea65012c69fdd4da92 Mon Sep 17 00:00:00 2001 From: Nguyen Nhu Viet Date: Tue, 14 Nov 2023 17:02:35 +0100 Subject: [PATCH] feat: add a simple DockerFile and runner test (#87) --- .../workflows/dockerfile_workflow_test.yaml | 8 ++++++++ .gitignore | 2 ++ docker-action-test/Dockerfile | 20 +++++++++++++++++++ docker-action-test/go.mod | 3 +++ docker-action-test/main.go | 7 +++++++ 5 files changed, 40 insertions(+) create mode 100644 .github/workflows/dockerfile_workflow_test.yaml create mode 100644 .gitignore create mode 100644 docker-action-test/Dockerfile create mode 100644 docker-action-test/go.mod create mode 100644 docker-action-test/main.go diff --git a/.github/workflows/dockerfile_workflow_test.yaml b/.github/workflows/dockerfile_workflow_test.yaml new file mode 100644 index 0000000..0475afe --- /dev/null +++ b/.github/workflows/dockerfile_workflow_test.yaml @@ -0,0 +1,8 @@ +name: Build Using Reusable Workflow +on: [push, pull_request] +jobs: + reusable-build: + uses: celestiaorg/.github/.github/workflows/reusable_dockerfile_pipeline.yml@${{ github.event.pull_request.head.ref || 'main' }} + with: + dockerfile: docker-action-test/Dockerfile + packageName: docker-action-test diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..66f8fb5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.idea/ +.vscode/ diff --git a/docker-action-test/Dockerfile b/docker-action-test/Dockerfile new file mode 100644 index 0000000..045b565 --- /dev/null +++ b/docker-action-test/Dockerfile @@ -0,0 +1,20 @@ +FROM --platform=$BUILDPLATFORM docker.io/golang:1.21-alpine3.18 as builder + +ARG TARGETOS +ARG TARGETARCH + +ENV CGO_ENABLED=0 +ENV GO111MODULE=on + +ADD . /app +WORKDIR /app + +RUN uname -a &&\ + CGO_ENABLED=${CGO_ENABLED} GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -o main . +######## Start a new stage from scratch ####### +FROM docker.io/alpine:3.18.4 + +RUN apk update && apk add --no-cache bash curl jq +COPY --from=builder /app/main . +# Command to run the executable +CMD ["./main"] diff --git a/docker-action-test/go.mod b/docker-action-test/go.mod new file mode 100644 index 0000000..184f4ae --- /dev/null +++ b/docker-action-test/go.mod @@ -0,0 +1,3 @@ +module github.com/celestiaorg/.celestia-github/docker-action-test + +go 1.21 diff --git a/docker-action-test/main.go b/docker-action-test/main.go new file mode 100644 index 0000000..7534a75 --- /dev/null +++ b/docker-action-test/main.go @@ -0,0 +1,7 @@ +package main + +import "fmt" + +func main() { + fmt.Println("Docker CICD! ⚙️ ") +}