Skip to content

Commit

Permalink
Merge pull request #74 from spowelljr/cloudbuild
Browse files Browse the repository at this point in the history
CI: Add cloudrun deploy script
  • Loading branch information
spowelljr authored Aug 11, 2023
2 parents e29f5df + 407676b commit 7511214
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 6 deletions.
14 changes: 14 additions & 0 deletions Dockerfile.server
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM golang:1.21 AS builder
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY cmd/gopogh-server/main.go ./
COPY pkg ./pkg
RUN CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -o /gopogh-server

FROM alpine:3
WORKDIR /
RUN apk add --no-cache ca-certificates
COPY --from=builder /gopogh-server /gopogh-server
EXPOSE 8080
CMD ["/gopogh-server", "-use_cloudsql", "-use_iam_auth"]
6 changes: 0 additions & 6 deletions cmd/gopogh-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@ var useIAMAuth = flag.Bool("use_iam_auth", false, "whether to use IAM to authent

func main() {
flag.Parse()
if *dbPath == "" {
log.Fatalf("The db_path flag is required")
}
if *dbHost == "" {
log.Fatalf("The db_host flag is required")
}
flagValues := db.FlagValues{
Backend: "postgres",
Host: *dbHost,
Expand Down
18 changes: 18 additions & 0 deletions deploy/cloudrun/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

set -eux

export IMAGE=gcr.io/k8s-minikube/gopogh-server

docker buildx build --platform linux/amd64 -t "${IMAGE}" -f Dockerfile.server .

docker push "${IMAGE}" || exit 2

gcloud run deploy gopogh-server \
--project k8s-minikube \
--image "${IMAGE}" \
--set-env-vars="DB_HOST=${DB_HOST},DB_PATH=${DB_PATH}" \
--allow-unauthenticated \
--region us-central1 \
--memory 4Gi \
--platform managed

0 comments on commit 7511214

Please sign in to comment.