Skip to content

Commit 7511214

Browse files
authored
Merge pull request #74 from spowelljr/cloudbuild
CI: Add cloudrun deploy script
2 parents e29f5df + 407676b commit 7511214

File tree

3 files changed

+32
-6
lines changed

3 files changed

+32
-6
lines changed

Dockerfile.server

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM golang:1.21 AS builder
2+
WORKDIR /app
3+
COPY go.mod go.sum ./
4+
RUN go mod download
5+
COPY cmd/gopogh-server/main.go ./
6+
COPY pkg ./pkg
7+
RUN CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -o /gopogh-server
8+
9+
FROM alpine:3
10+
WORKDIR /
11+
RUN apk add --no-cache ca-certificates
12+
COPY --from=builder /gopogh-server /gopogh-server
13+
EXPOSE 8080
14+
CMD ["/gopogh-server", "-use_cloudsql", "-use_iam_auth"]

cmd/gopogh-server/main.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@ var useIAMAuth = flag.Bool("use_iam_auth", false, "whether to use IAM to authent
1616

1717
func main() {
1818
flag.Parse()
19-
if *dbPath == "" {
20-
log.Fatalf("The db_path flag is required")
21-
}
22-
if *dbHost == "" {
23-
log.Fatalf("The db_host flag is required")
24-
}
2519
flagValues := db.FlagValues{
2620
Backend: "postgres",
2721
Host: *dbHost,

deploy/cloudrun/deploy.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
set -eux
4+
5+
export IMAGE=gcr.io/k8s-minikube/gopogh-server
6+
7+
docker buildx build --platform linux/amd64 -t "${IMAGE}" -f Dockerfile.server .
8+
9+
docker push "${IMAGE}" || exit 2
10+
11+
gcloud run deploy gopogh-server \
12+
--project k8s-minikube \
13+
--image "${IMAGE}" \
14+
--set-env-vars="DB_HOST=${DB_HOST},DB_PATH=${DB_PATH}" \
15+
--allow-unauthenticated \
16+
--region us-central1 \
17+
--memory 4Gi \
18+
--platform managed

0 commit comments

Comments
 (0)