Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions .github/workflows/containers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Containers
on:
push:
branches:
- main
tags:
- "v*"
pull_request:
branches:
- main

jobs:
uptime:
name: Uptime
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v6

- name: Set Environment
id: vars
run: |
echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused tag output variable in workflow step

Low Severity

The tag output computed in the Set Environment step is never referenced anywhere in the workflow. Only revision and build_date are consumed (via steps.vars.outputs.revision and steps.vars.outputs.build_date). The tag output is dead code that adds confusion about whether something downstream was supposed to use it.

Fix in Cursor Fix in Web

echo "revision=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "build_date=$(date -u +%Y-%m-%d)" >> $GITHUB_OUTPUT

- name: Docker Metadata
id: meta
uses: docker/metadata-action@v6
with:
# list of Docker images to use as basenames for tags
# this should be configured for each container built
images: |
rotationalio/uptime
gcr.io/rotationalio-habanero/uptime
tags: |
type=semver,pattern={{raw}}
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha,prefix=,suffix=,format=short

- name: Setup QEMU
uses: docker/setup-qemu-action@v4

- name: Setup Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v4

- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }}

- name: Login to GCR
if: github.event_name != 'pull_request'
uses: docker/login-action@v4
with:
registry: gcr.io
username: _json_key
password: ${{ secrets.GCR_SERVICE_ACCOUNT }}

- name: Build and push
id: docker_build
uses: docker/build-push-action@v7
with:
context: .
file: ./Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
build-args: |
GIT_REVISION=${{ steps.vars.outputs.revision }}
BUILD_DATE=${{ steps.vars.outputs.build_date }}
50 changes: 50 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Dynamic builds
ARG BUILDER_IMAGE=dhi.io/golang:1.26-debian13-dev
ARG FINAL_IMAGE=dhi.io/golang:1.26-debian13

# Build stage
FROM --platform=${BUILDPLATFORM} ${BUILDER_IMAGE} AS builder

# Build args
ARG GIT_REVISION=""
ARG BUILD_DATE=""

# Platform args
ARG TARGETOS
ARG TARGETARCH
ARG TARGETPLATFORM

# Use modules for dependencies
WORKDIR $GOPATH/src/go.rtnl.ai/uptime

COPY go.mod .
COPY go.sum .

# Set the build environment
ENV CGO_ENABLED=0
ENV GO111MODULE=on
ENV GOOS=${TARGETOS}
ENV GOARCH=${TARGETARCH}

# Install dependencies
RUN go mod download && go mod verify

# Copy the source code
COPY pkg/ pkg/
COPY cmd/ cmd/

# Build the uptime binary
RUN go build -o /go/bin/uptime \
-ldflags="-X 'go.rtnl.ai/uptime/pkg.GitVersion=${GIT_REVISION}' -X 'go.rtnl.ai/uptime/pkg.BuildDate=${BUILD_DATE}'" \
./cmd/uptime

# Final stage
FROM ${FINAL_IMAGE} AS final

LABEL maintainer="Rotational Labs, Inc. <support@rotational.io>"
LABEL description="Service status monitor for Rotational applications and systems."

# Copy the uptime binary
COPY --from=builder /go/bin/uptime /usr/local/bin/uptime

CMD [ "/usr/local/bin/uptime", "serve" ]
Loading