Skip to content

Commit

Permalink
👷 Populated footer build info in Docker images
Browse files Browse the repository at this point in the history
Closes #14
  • Loading branch information
Luke Carr committed Apr 7, 2022
1 parent a94dffa commit 3263d00
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,17 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Generate build date
id: build_date_gen
run: echo ::set-output name=build_date::$(date --iso-8601=minutes)

- name: Build and push image
uses: docker/build-push-action@v2
with:
context: .
push: true
build-args: |
BUILD_DATE:${{ steps.build_date_gen.outputs.build_date }}
BUILD_COMMIT:${{ github.sha }}
BUILD_VERSION:nightly
labels: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:nightly
8 changes: 8 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,18 @@ jobs:
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Generate build date
id: build_date_gen
run: echo ::set-output name=build_date::$(date --iso-8601=minutes)

- name: Build and push image
uses: docker/build-push-action@v2
with:
context: .
push: true
build-args: |
BUILD_DATE:${{ steps.build_date_gen.outputs.build_date }}
BUILD_COMMIT:${{ github.sha }}
BUILD_VERSION:${{ github.ref_name }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ COPY --from=node-builder /build/dist ./frontend/dist/
ENV CGO_ENABLED=0
ENV GOOS=linux
ENV GOARCH=amd64
RUN go build -ldflags='-w -s -extldflags "-static"' -a -o /usr/bin/tiny-todo main.go
ARG BUILD_VERSION
ARG BUILD_COMMIT
ARG BUILD_DATE
RUN go build -ldflags="-w -s -extldflags '-static' -X github.com/lukecarr/tiny-todo/internal/info.Version=${BUILD_VERSION} -X github.com/lukecarr/tiny-todo/internal/info.Commit=${BUILD_COMMIT} -X github.com/lukecarr/tiny-todo/internal/info.Date=${BUILD_DATE}" -a -o /usr/bin/tiny-todo main.go

FROM scratch

Expand Down
8 changes: 4 additions & 4 deletions frontend/src/components/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ const BuildInfo: FunctionalComponent = () => {

return <div text="gray-700 sm right" font="mono">
{data.version && <p>
<Link href={`https://github.com/lukecarr/tiny-todo/releases/tag/${data.version}`} newTab>{data.version}</Link>
<Link href={`https://github.com/lukecarr/tiny-todo/releases/tag/${data.version}`} newTab>
{data.version}
{data.commit && <Link href={`https://github.com/lukecarr/tiny-todo/commit/${data.commit}`} newTab>{' '}({data.commit.slice(0, 7)})</Link>}
</Link>
</p>}
<p text="xs">Built at: {data.date}</p>
{data.commit && <p text="xs">
<Link href={`https://github.com/lukecarr/tiny-todo/commit/${data.commit}`} newTab>{data.commit.slice(0, 7)}</Link>
</p>}
</div>
}

Expand Down

0 comments on commit 3263d00

Please sign in to comment.