-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
159 additions
and
11 deletions.
There are no files selected for viewing
This file contains 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,57 @@ | ||
name: Deploy | ||
on: | ||
push: | ||
branches: | ||
- main | ||
tags: | ||
- 'v*' | ||
|
||
jobs: | ||
noaalerts: | ||
name: Docker Build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup Environment | ||
id: vars | ||
run: | | ||
echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT | ||
echo "revision=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | ||
- name: Docker Metadata | ||
id: meta | ||
uses: docker/metadata-action@v3 | ||
with: | ||
images: | | ||
bbengfort/noaalerts | ||
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@v1 | ||
|
||
- name: Setup Docker Buildx | ||
id: buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Login to DockerHub | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_PASSWORD }} | ||
|
||
- name: Build and Push | ||
id: docker_build | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
build-args: | | ||
GIT_REVISION=${{ steps.vars.outputs.revision }} |
This file contains 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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: CI | ||
name: Tests | ||
on: | ||
push: | ||
branches: | ||
|
This file contains 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,45 @@ | ||
# Dynamic Builds | ||
ARG BUILDER_IMAGE=golang:1.20-buster | ||
ARG FINAL_IMAGE=debian:buster-slim | ||
|
||
# Build Stage | ||
FROM ${BUILDER_IMAGE} AS builder | ||
|
||
# Build Args | ||
ARG GIT_REVISION="" | ||
|
||
# Ensure ca-certificates are up to date on the image | ||
RUN update-ca-certificates | ||
|
||
# Use modules for dependencies | ||
WORKDIR $GOPATH/src/github.com/bbengfort/noaalert | ||
|
||
COPY go.mod . | ||
COPY go.sum . | ||
|
||
ENV CGO_ENABLED=0 | ||
ENV GO111MODULE=on | ||
RUN go mod download | ||
RUN go mod verify | ||
|
||
# Copy package | ||
COPY . . | ||
|
||
# Build binary | ||
RUN go build -v -o /go/bin/noaalert -ldflags="-X 'github.com/bbengfort/noaalert.GitVersion=${GIT_REVISION}'" ./cmd/noaalert | ||
|
||
# Final Stage | ||
FROM ${FINAL_IMAGE} AS final | ||
|
||
LABEL maintainer="Benjamin Bengfort <[email protected]>" | ||
LABEL description="Converts NOAA Severe Weather Alerts API requests into real time events" | ||
|
||
# Ensure ca-certificates are up to date | ||
RUN set -x && apt-get update && \ | ||
DEBIAN_FRONTEND=noninteractive apt-get install -y ca-certificates && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# Copy the binary to the production image from the builder stage | ||
COPY --from=builder /go/bin/noaalert /usr/local/bin/noaalert | ||
|
||
CMD [ "/usr/local/bin/noaalert", "publish" ] |
This file contains 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
This file contains 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,13 @@ | ||
version: "3" | ||
services: | ||
publisher: | ||
build: | ||
context: . | ||
dockerfile: ./ | ||
args: | ||
GIT_REVISION: ${GIT_REVISION} | ||
image: bbengfort/noaalerts | ||
init: true | ||
environment: | ||
- ENSIGN_CLIENT_ID | ||
- ENSIGN_CLEINT_SECRET |
This file contains 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