commit 619a99a6dddd880cfd2499ad59f14b5fb14a5150
| author | 斟酌 鵬兄 <tgckpg@gmail.com> |
| date | 2022-09-14T15:21:27Z |
| subject | Added CI resources |
commit 619a99a6dddd880cfd2499ad59f14b5fb14a5150
Author: 斟酌 鵬兄 <tgckpg@gmail.com>
Date: 2022-09-14T15:21:27Z
Added CI resources
---
Dockerfile | 15 +++++++++++++++
concourse/build.yaml | 24 ++++++++++++++++++++++++
concourse/prepare-deployment-resources.yaml | 21 +++++++++++++++++++++
k8s/deployments.yaml | 26 ++++++++++++++++++++++++++
4 files changed, 86 insertions(+)
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..c0f86ad
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,15 @@
+FROM golang:1.19-alpine
+
+WORKDIR /app
+
+COPY [ "go.mod", "go.sum", "./" ]
+
+RUN go mod download
+
+COPY "datasources" "./datasources/"
+COPY "utils" "./utils/"
+COPY *.go ./
+
+RUN go build -o /golifehkbot
+
+CMD [ "/golifehkbot" ]
diff --git a/concourse/build.yaml b/concourse/build.yaml
new file mode 100644
index 0000000..ca9a9b4
--- /dev/null
+++ b/concourse/build.yaml
@@ -0,0 +1,24 @@
+platform: linux
+
+image_resource:
+ type: registry-image
+ source:
+ repository: concourse/oci-build-task
+
+inputs:
+ - name: project-src
+ path: .
+
+outputs:
+ - name: image
+
+caches:
+ - path: cache
+
+params:
+ CONTEXT: .
+ # Reference: https://concourse-ci.org/building-an-image-and-using-it-in-a-task.html#build-the-image
+ UNPACK_ROOTFS: true
+
+run:
+ path: build
diff --git a/concourse/prepare-deployment-resources.yaml b/concourse/prepare-deployment-resources.yaml
new file mode 100644
index 0000000..ab371da
--- /dev/null
+++ b/concourse/prepare-deployment-resources.yaml
@@ -0,0 +1,21 @@
+platform: linux
+
+image_resource:
+ type: registry-image
+ source:
+ repository: alpine
+
+inputs:
+ - name: project-src
+ path: .
+
+outputs:
+ - name: deploy-confs
+
+run:
+ path: sh
+ args:
+ - -exc
+ - |
+ VERSION=$( cat commit.sha )
+ sed "s/IMAGE_TAG/$VERSION/g" k8s/deployments.yaml >> deploy-confs/prod.yaml
diff --git a/k8s/deployments.yaml b/k8s/deployments.yaml
new file mode 100644
index 0000000..1ff8d63
--- /dev/null
+++ b/k8s/deployments.yaml
@@ -0,0 +1,26 @@
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: golifehk
+spec:
+ selector:
+ matchLabels:
+ app: golifehk
+ replicas: 1
+ template:
+ metadata:
+ labels:
+ app: golifehk
+ srv: go
+ spec:
+ imagePullSecrets:
+ - name: registry-auth
+ containers:
+ - name: app
+ image: registry.k8s.astropenguin.net/golifehk:IMAGE_TAG
+ env:
+ - name: TELEGRAM_API_TOKEN
+ valueFrom:
+ secretKeyRef:
+ name: golifehk-conf
+ key: TELEGRAM_API_TOKEN