Skip to content

Commit

Permalink
ci: add basic docker test for docker workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
MSevey committed Jun 26, 2024
1 parent 5727092 commit 7840030
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 0 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/dockerfile_workflow_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#
# This workflow is used to test the `reusable_dockerfile_pipeline` action used
# to build and push the Docker image to the container registries.
#
# The reason this workflow targets the develop branch is so that we can test the
# action in the PR. If we targeted main, we would need to merge changes into main
# before being able to test them.
#
name: Build Using Reusable Workflow
on: [push, pull_request]
jobs:
# reusable-build tests calling the reusable_dockerfile_pipeline while
# providing a custom packageName
reusable-build:
permissions:
contents: write
packages: write
uses: rollkit/.github/.github/workflows/reusable_dockerfile_pipeline.yml@develop
with:
dockerfile: docker-action-test/Dockerfile
packageName: docker-test
secrets: inherit

# reusable-build-defaults tests calling the reusable_dockerfile_pipeline with
# the defaults
reusable-build-defaults:
permissions:
contents: write
packages: write
uses: rollkit/.github/.github/workflows/reusable_dockerfile_pipeline.yml@develop
with:
dockerfile: docker-action-test/Dockerfile
secrets: inherit
20 changes: 20 additions & 0 deletions docker-action-test/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 ./docker-action-test /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"]
3 changes: 3 additions & 0 deletions docker-action-test/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/celestiaorg/.celestia-github/docker-action-test

go 1.21
7 changes: 7 additions & 0 deletions docker-action-test/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package main

import "fmt"

func main() {
fmt.Println("Docker CICD! ⚙️ ")
}

0 comments on commit 7840030

Please sign in to comment.