Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

Commit

Permalink
Work in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
skhaz committed Nov 9, 2023
1 parent 4b6cc08 commit 9e5653c
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 11 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,15 @@ jobs:
tags: ${{ secrets.REGISTRY }}/${{ secrets.SERVICE_NAME }}:latest
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Deploy
uses: google-github-actions/deploy-cloudrun@v1
with:
service: ${{ secrets.SERVICE_NAME }}
image: ${{ secrets.REGISTRY }}/${{ secrets.SERVICE_NAME }}:latest
region: ${{ secrets.REGION }}
platform: managed
allow-unauthenticated: true

- name: "Check deployment"
run: curl -fsS -m 10 --retry 5 -o /dev/null "${{ steps.deploy.outputs.url }}"
22 changes: 11 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ conan install .. --output-folder=. --build=missing --profile=webassembly --sett
cmake .. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release
EOF

# FROM golang:1.21
# WORKDIR /opt
# COPY go.mod .
# COPY go.sum .
# RUN go mod download
# COPY . .
# RUN CGO_ENABLED=0 go build -ldflags="-s -w" -trimpath -o app

# FROM gcr.io/distroless/static-debian12
# COPY --from=0 /opt/app /
# CMD ["/app"]
FROM golang:1.21
WORKDIR /opt
COPY go.mod .
COPY go.sum .
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 go build -ldflags="-s -w" -trimpath -o app

FROM gcr.io/distroless/static-debian12
COPY --from=1 /opt/app /
CMD ["/app"]
26 changes: 26 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package main

import (
"encoding/json"
"fmt"
"net/http"
"os"
)

type Message struct {
Text string `json:"message"`
}

func handler(w http.ResponseWriter, r *http.Request) {
message := Message{
Text: "Hello, world!",
}

w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(message)
}

func main() {
http.HandleFunc("/", handler)
http.ListenAndServe(fmt.Sprintf(":%s", os.Getenv("PORT")), nil)
}

0 comments on commit 9e5653c

Please sign in to comment.