From 55328798d1d2d01a5b54e501dc66f276838a188d Mon Sep 17 00:00:00 2001 From: jidicula Date: Mon, 31 Jan 2022 18:39:20 -0500 Subject: [PATCH] feat(docker): Containerize app Resolves: #1 --- .github/workflows/publish.yml | 34 +++++++++++++++++++++++++++-- .github/workflows/release-draft.yml | 1 - .gitignore | 2 ++ Dockerfile | 11 ++++++++++ 4 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 Dockerfile diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 2867931..031b983 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -3,13 +3,43 @@ on: types: - published -name: Update Go Module Index +name: Publish + +env: + REGISTRY: ghcr.io + IMAGE_NAME: vci-check jobs: bump-index: + name: Update Go Module Index runs-on: ubuntu-latest steps: - name: Checkout repo uses: actions/checkout@v2.4.0 - name: Ping endpoint - run: curl "https://proxy.golang.org/github.com/jidicula/template-go/@v/$(git describe HEAD --tags --abbrev=0).info" + run: curl "https://proxy.golang.org/github.com/jidicula/vci-check/@v/${{ env.GITHUB_REF }}.info" + publish-image: + name: Publish Docker image + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Log in to the Container registry + uses: docker/login-action@v1.12.0 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v3.6.2 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + - name: Build and push Docker image + uses: docker/build-push-action@v2.8.0 + with: + push: true + tags: ${{ env.REGISTRY}}/jidicula/${{ env.IMAGE_NAME}}:${{ env.GITHUB_REF }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + "UBUNTU_VERSION=${{ matrix.version-pair.ubuntu }}" + "CLANG_FORMAT_VERSION=${{ matrix.version-pair.version }}" diff --git a/.github/workflows/release-draft.yml b/.github/workflows/release-draft.yml index 5a188e6..f8c12d3 100644 --- a/.github/workflows/release-draft.yml +++ b/.github/workflows/release-draft.yml @@ -65,7 +65,6 @@ jobs: - name: Release with Notes uses: softprops/action-gh-release@v1 with: - body_path: ".github/RELEASE-TEMPLATE.md" draft: true files: ${{env.BINARY_NAME}} env: diff --git a/.gitignore b/.gitignore index 66fd13c..43c3fcd 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,5 @@ # Dependency directories (remove the comment below to include it) # vendor/ + +vci-check diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..5563389 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM golang:1.16-alpine as builder + +RUN apk --no-cache add ca-certificates +WORKDIR /src/ +COPY . /src/ +RUN CGO_ENABLED=0 go build -o /bin/vci-check . + +FROM scratch +COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ +COPY --from=builder /bin/vci-check /bin/vci-check +ENTRYPOINT [ "/bin/vci-check" ]