Skip to content

Commit

Permalink
add skaffold config to run locally
Browse files Browse the repository at this point in the history
  • Loading branch information
adlandh committed Aug 27, 2023
1 parent 177cf55 commit 87ac579
Show file tree
Hide file tree
Showing 10 changed files with 85 additions and 5 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*
!/internal
!/go.mod
!/go.sum
2 changes: 1 addition & 1 deletion .gcloudignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
!/go.mod
!/go.sum
!/app.yaml
!/secrets.yaml
!/app-secrets.yaml
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/TODO.md
/inf/Pulumi.prod.yaml
/secrets.yaml
/app-secrets.yaml
/local-secrets.env
16 changes: 16 additions & 0 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,22 @@ tasks:
description: Deploy to gcp
cmds:
- gcloud app deploy --quiet
secrets:
description: create kubernetes secrets
cmds:
- kubectl create secret generic post-forwarder --from-env-file=local-secrets.env
run:
description: run app locally in kubernetes
cmds:
- skaffold run --tail
dev:
description: run app locally in kubernetes with auto build when code is changed
cmds:
- skaffold dev --tail
stop:
description: stop app running locally
cmds:
- kubectl delete -f docker/deployment.yaml
logs:
description: Show logs
cmds:
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion app.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
runtime: go121
main: ./internal/post-forwarder/main.go
includes:
- secrets.yaml
- app-secrets.yaml
4 changes: 2 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM golang:1.21 as builder

ENV WORKDIR /go/src
WORKDIR /go/src
COPY . .
RUN cd ${WORKDIR}/internal/post-forwarder && CGO_ENABLED=0 go build -o "/go/bin/pf" -ldflags="-w -s"
RUN ls
RUN cd internal/post-forwarder && CGO_ENABLED=0 go build -o "/go/bin/pf" -ldflags="-w -s"

FROM alpine:3.18.2
RUN adduser -S -D -H -h /app appuser
Expand Down
35 changes: 35 additions & 0 deletions docker/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
apiVersion: v1
kind: Service
metadata:
name: post-forwarder
spec:
selector:
app: post-forwarder
type: LoadBalancer
ports:
- protocol: TCP
port: 8080
targetPort: 8080
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: post-forwarder
labels:
app: post-forwarder
spec:
replicas: 1
selector:
matchLabels:
app: post-forwarder
template:
metadata:
labels:
app: post-forwarder
spec:
containers:
- name: post-forwarder
image: post-forwarder
envFrom:
- secretRef:
name: post-forwarder
6 changes: 6 additions & 0 deletions local-secrets.env.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
BOT_TOKEN=your_bot_token
AUTH_TOKEN=your_auth_token
BOT_CHAT_ID=your_chat_id
SENTRY_DNS=your_sentry_dsn
SENTRY_TRACES_SAMPLE_RATE=1.0
SENTRY_PROFILES_SAMPLE_RATE=1.0
18 changes: 18 additions & 0 deletions skaffold.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: skaffold/v4beta6
kind: Config
metadata:
name: post-forwarder
build:
artifacts:
- image: post-forwarder
context: .
docker:
dockerfile: docker/Dockerfile
cacheFrom:
- post-forwarder
local:
push: false
useDockerCLI: true
manifests:
rawYaml:
- docker/deployment.yaml

0 comments on commit 87ac579

Please sign in to comment.