feat(ci/cd): add deploy pipelines
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
e2be652a60
commit
8e46fe38d3
88
.drone.yml
88
.drone.yml
|
@ -64,8 +64,94 @@ trigger:
|
||||||
- pull_request
|
- pull_request
|
||||||
branch:
|
branch:
|
||||||
- master
|
- master
|
||||||
|
|
||||||
|
---
|
||||||
|
kind: pipeline
|
||||||
|
type: docker
|
||||||
|
name: linux-amd64
|
||||||
|
|
||||||
|
platform:
|
||||||
|
os: linux
|
||||||
|
arch: amd64
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: publish
|
||||||
|
image: plugins/docker
|
||||||
|
settings:
|
||||||
|
username:
|
||||||
|
from_secret: docker_username
|
||||||
|
password:
|
||||||
|
from_secret: docker_password
|
||||||
|
registry: gitea.dwysokinski.me
|
||||||
|
repo: gitea.dwysokinski.me/twhelp-packages/dcbot
|
||||||
|
auto_tag: true
|
||||||
|
auto_tag_suffix: linux-amd64
|
||||||
|
dockerfile: ./build/docker/dcbot/prod/Dockerfile
|
||||||
|
build_args_from_env: [DRONE_TAG]
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
event:
|
||||||
|
- tag
|
||||||
|
|
||||||
|
---
|
||||||
|
kind: pipeline
|
||||||
|
type: docker
|
||||||
|
name: manifest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: manifest
|
||||||
|
image: plugins/manifest
|
||||||
|
settings:
|
||||||
|
auto_tag: "true"
|
||||||
|
ignore_missing: "true"
|
||||||
|
spec: ./build/docker/dcbot/prod/manifest.tmpl
|
||||||
|
username:
|
||||||
|
from_secret: docker_username
|
||||||
|
password:
|
||||||
|
from_secret: docker_password
|
||||||
|
- name: manifest-latest
|
||||||
|
image: plugins/manifest
|
||||||
|
settings:
|
||||||
|
tags: latest
|
||||||
|
ignore_missing: "true"
|
||||||
|
spec: ./build/docker/dcbot/prod/manifest.tmpl
|
||||||
|
username:
|
||||||
|
from_secret: docker_username
|
||||||
|
password:
|
||||||
|
from_secret: docker_password
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
event:
|
||||||
|
- tag
|
||||||
|
|
||||||
|
depends_on:
|
||||||
|
- linux-amd64
|
||||||
|
|
||||||
|
---
|
||||||
|
kind: pipeline
|
||||||
|
type: docker
|
||||||
|
name: deploy
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: deploy-k8s
|
||||||
|
image: alpine/k8s:1.25.0
|
||||||
|
environment:
|
||||||
|
KUBECONFIG:
|
||||||
|
from_secret: kubeconfig
|
||||||
|
commands:
|
||||||
|
- "mkdir ~/.kube && echo \"$KUBECONFIG\" > ~/.kube/twhelp"
|
||||||
|
- "cd ./k8s/overlays/prod && kustomize edit set image twhelp=gitea.dwysokinski.me/twhelp-packages/dcbot:${DRONE_TAG##v} && cd ../../.."
|
||||||
|
- "kubectl --kubeconfig ~/.kube/twhelp -n twhelp delete jobs.batch twhelp-dcbot-migrations-job || true"
|
||||||
|
- kustomize build ./k8s/overlays/prod | kubectl --kubeconfig ~/.kube/twhelp apply -n twhelp -f -
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
event:
|
||||||
|
- tag
|
||||||
|
|
||||||
|
depends_on:
|
||||||
|
- manifest
|
||||||
---
|
---
|
||||||
kind: signature
|
kind: signature
|
||||||
hmac: d3d244bdb305befafa4382a48a5ec1c68e79371706383a9a8d455e28ff3996c0
|
hmac: 5f322bb5ee59be0e758fc2b28812a50589851b3c0502995c89a1d7bf8adcb7bf
|
||||||
|
|
||||||
...
|
...
|
||||||
|
|
22
build/docker/dcbot/prod/Dockerfile
Normal file
22
build/docker/dcbot/prod/Dockerfile
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
FROM golang:1.19.2-alpine3.16 as builder
|
||||||
|
|
||||||
|
WORKDIR /dcbot
|
||||||
|
|
||||||
|
COPY go.mod go.sum ./
|
||||||
|
RUN go mod download
|
||||||
|
|
||||||
|
RUN apk --no-cache add make
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
RUN make generate
|
||||||
|
ARG DRONE_TAG="development"
|
||||||
|
RUN CGO_ENABLED=0 go build -ldflags "-X main.version=${DRONE_TAG##v}" -trimpath -o dcbot ./cmd/dcbot/main.go
|
||||||
|
|
||||||
|
######## Start a new stage from scratch #######
|
||||||
|
FROM alpine:3.16
|
||||||
|
|
||||||
|
RUN apk --no-cache add ca-certificates tzdata
|
||||||
|
|
||||||
|
COPY --from=builder /dcbot/dcbot /usr/bin/
|
||||||
|
|
||||||
|
ENTRYPOINT ["dcbot"]
|
13
build/docker/dcbot/prod/manifest.tmpl
Normal file
13
build/docker/dcbot/prod/manifest.tmpl
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
image: gitea.dwysokinski.me/twhelp-packages/dcbot:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}
|
||||||
|
{{#if build.tags}}
|
||||||
|
tags:
|
||||||
|
{{#each build.tags}}
|
||||||
|
- {{this}}
|
||||||
|
{{/each}}
|
||||||
|
{{/if}}
|
||||||
|
manifests:
|
||||||
|
-
|
||||||
|
image: gitea.dwysokinski.me/twhelp-packages/dcbot:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64
|
||||||
|
platform:
|
||||||
|
architecture: amd64
|
||||||
|
os: linux
|
33
k8s/overlays/prod/bot.yml
Normal file
33
k8s/overlays/prod/bot.yml
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: twhelp-dcbot-deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: twhelp-dcbot
|
||||||
|
image: dcbot
|
||||||
|
env:
|
||||||
|
- name: APP_MODE
|
||||||
|
value: production
|
||||||
|
- name: DB_DSN
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: twhelp-dcbot-secret
|
||||||
|
key: db-dsn
|
||||||
|
- name: DB_MAX_OPEN_CONNECTIONS
|
||||||
|
value: "15"
|
||||||
|
- name: DB_MAX_IDLE_CONNECTIONS
|
||||||
|
value: "8"
|
||||||
|
- name: BOT_TOKEN
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: twhelp-dcbot-secret
|
||||||
|
key: token
|
||||||
|
- name: TWHELP_URL
|
||||||
|
value: "https://tribalwarshelp.com"
|
||||||
|
- name: BOT_MAX_GROUPS_PER_SERVER
|
||||||
|
value: "5"
|
||||||
|
- name: BOT_MAX_MONITORS_PER_GROUP
|
||||||
|
value: "10"
|
21
k8s/overlays/prod/jobs.yml
Normal file
21
k8s/overlays/prod/jobs.yml
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
apiVersion: batch/v1
|
||||||
|
kind: Job
|
||||||
|
metadata:
|
||||||
|
name: twhelp-dcbot-migrations-job
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: twhelp-dcbot-migrations
|
||||||
|
image: dcbot
|
||||||
|
args: ["db", "migrate"]
|
||||||
|
env:
|
||||||
|
- name: APP_MODE
|
||||||
|
value: production
|
||||||
|
- name: DB_MAX_OPEN_CONNECTIONS
|
||||||
|
value: "1"
|
||||||
|
- name: DB_DSN
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: twhelp-dcbot-secret
|
||||||
|
key: db-dsn
|
9
k8s/overlays/prod/kustomization.yaml
Normal file
9
k8s/overlays/prod/kustomization.yaml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
namespace: twhelp
|
||||||
|
resources:
|
||||||
|
- ../../base
|
||||||
|
- ingress.yml
|
||||||
|
patchesStrategicMerge:
|
||||||
|
- bot.yml
|
||||||
|
- jobs.yml
|
Loading…
Reference in New Issue
Block a user