Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8aadf4c29e |
@@ -1,2 +0,0 @@
|
|||||||
.env
|
|
||||||
.git
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
name: Build
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
- name: Login to Gitea Registry
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
|
||||||
registry: gitea.coupxd.com
|
|
||||||
username: ${{ secrets.REGISTRY_USER }}
|
|
||||||
password: ${{ secrets.REGISTRY_PASSWORD }}
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v3
|
|
||||||
- name: Build and Push
|
|
||||||
uses: docker/build-push-action@v5
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
platforms: linux/arm64
|
|
||||||
push: true
|
|
||||||
tags: gitea.coupxd.com/cody/go-weather:latest
|
|
||||||
@@ -1,2 +1 @@
|
|||||||
.env
|
.env
|
||||||
.dockerenv
|
|
||||||
|
|||||||
-12
@@ -1,12 +0,0 @@
|
|||||||
FROM golang:1.25-bookworm AS builder
|
|
||||||
WORKDIR /app
|
|
||||||
COPY go.mod go.sum ./
|
|
||||||
RUN go mod download
|
|
||||||
COPY . .
|
|
||||||
# Buildx automatically injects TARGETARCH, TARGETOS, and TARGETPLATFORM as build args into the Dockerfile
|
|
||||||
ARG TARGETARCH
|
|
||||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build -o go-weather .
|
|
||||||
FROM gcr.io/distroless/static-debian12
|
|
||||||
COPY --from=builder /app/go-weather /go-weather
|
|
||||||
EXPOSE 8080
|
|
||||||
ENTRYPOINT ["/go-weather"]
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
echo "Creating build environment"
|
|
||||||
docker buildx create --name pibuilder --use
|
|
||||||
|
|
||||||
echo "Printing build environment info"
|
|
||||||
docker buildx inspect --bootstrap
|
|
||||||
|
|
||||||
echo "Doing build"
|
|
||||||
docker buildx build \
|
|
||||||
--platform linux/arm64 \
|
|
||||||
--push \
|
|
||||||
-t gitea.coupxd.com/cody/go-weather:latest \
|
|
||||||
.
|
|
||||||
|
|
||||||
@@ -36,10 +36,6 @@ type Reading struct {
|
|||||||
FetchedAt time.Time `json:"fetched_at"`
|
FetchedAt time.Time `json:"fetched_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type HealthResponse struct {
|
|
||||||
Status string `json:"status"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func getEnv(key string) string {
|
func getEnv(key string) string {
|
||||||
val := os.Getenv(key)
|
val := os.Getenv(key)
|
||||||
if val == "" {
|
if val == "" {
|
||||||
@@ -247,19 +243,6 @@ func main() {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
// GET /health
|
|
||||||
http.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) {
|
|
||||||
// TODO: Check if database is ready as well
|
|
||||||
if r.Method != http.MethodGet {
|
|
||||||
http.Error(w, "method not allowed", http.StatusMethodNotAllowed)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
okStatus := HealthResponse{Status: "ok"}
|
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "application/json")
|
|
||||||
json.NewEncoder(w).Encode(okStatus)
|
|
||||||
})
|
|
||||||
|
|
||||||
// GET /weather/history?city=London&limit=10
|
// GET /weather/history?city=London&limit=10
|
||||||
http.HandleFunc("/weather/history", func(w http.ResponseWriter, r *http.Request) {
|
http.HandleFunc("/weather/history", func(w http.ResponseWriter, r *http.Request) {
|
||||||
if r.Method != http.MethodGet {
|
if r.Method != http.MethodGet {
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://docs.renovatebot.com/renovate-schema.json"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user