-
Notifications
You must be signed in to change notification settings - Fork 0
[FEAT] Dockerfile #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| 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 }} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" ] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused
tagoutput variable in workflow stepLow Severity
The
tagoutput computed in theSet Environmentstep is never referenced anywhere in the workflow. Onlyrevisionandbuild_dateare consumed (viasteps.vars.outputs.revisionandsteps.vars.outputs.build_date). Thetagoutput is dead code that adds confusion about whether something downstream was supposed to use it.