Compare commits
16 Commits
56cd2dde79
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ca5d3cc3e0 | ||
|
|
7d3c68066c | ||
|
|
7437e109fe | ||
|
|
eb1d6daf2c | ||
|
|
4f2dc5110f | ||
|
|
607074eb33 | ||
|
|
1202e3464f | ||
|
|
96a934a3de | ||
|
|
318f21c826 | ||
|
|
19a3de9eb9 | ||
|
|
1925adaf42 | ||
|
|
74d9eb6124 | ||
|
|
b6c0ada4a5 | ||
|
|
7f32130e27 | ||
|
|
f27f7b9ab5 | ||
|
|
bee0edbc52 |
56
.gitea/workflows/ci.yml
Normal file
56
.gitea/workflows/ci.yml
Normal file
@@ -0,0 +1,56 @@
|
||||
name: Build and Deploy Scheduler
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
env:
|
||||
REGISTRY: localhost:9999
|
||||
IMAGE_NAME: ${{ secrets.PROJECT_NAME }}
|
||||
|
||||
jobs:
|
||||
cleaning:
|
||||
runs-on: host
|
||||
steps:
|
||||
- name: Cleanup docker
|
||||
run: |
|
||||
docker container prune -f
|
||||
docker image prune -af
|
||||
|
||||
build_image:
|
||||
runs-on: host
|
||||
needs: cleaning
|
||||
steps:
|
||||
- name: Clone repo
|
||||
run: |
|
||||
git clone ${{ gitea.server_url }}/${{ gitea.repository }} .
|
||||
git checkout ${{ gitea.ref_name }}
|
||||
|
||||
- name: Build image
|
||||
run: |
|
||||
docker build -t $REGISTRY/$IMAGE_NAME:${{ gitea.run_number }} .
|
||||
|
||||
- name: Push image
|
||||
run: |
|
||||
docker push $REGISTRY/$IMAGE_NAME:${{ gitea.run_number }}
|
||||
|
||||
deploy:
|
||||
runs-on: host
|
||||
needs: build_image
|
||||
steps:
|
||||
- name: Clone repo
|
||||
run: |
|
||||
git clone ${{ gitea.server_url }}/${{ gitea.repository }} .
|
||||
git checkout ${{ gitea.ref_name }}
|
||||
|
||||
- name: Prepare env for compose
|
||||
run: |
|
||||
echo "REGISTRY=$REGISTRY" > .env
|
||||
echo "IMAGE_NAME=$IMAGE_NAME" >> .env
|
||||
echo "TAG=${{ gitea.run_number }}" >> .env
|
||||
cat .env
|
||||
|
||||
- name: Deploy stack
|
||||
run: |
|
||||
docker compose up -d
|
||||
14
compose.yml
14
compose.yml
@@ -1,14 +0,0 @@
|
||||
services:
|
||||
app:
|
||||
image: localhost:9999/$PROJECT_NAME:$CI_PIPELINE_ID
|
||||
deploy:
|
||||
replicas: 1
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
resources:
|
||||
limits:
|
||||
cpus: "0.01"
|
||||
memory: "50m"
|
||||
restart: always
|
||||
volumes:
|
||||
- /home/script:/home/script
|
||||
18
docker-compose.yaml
Normal file
18
docker-compose.yaml
Normal file
@@ -0,0 +1,18 @@
|
||||
services:
|
||||
app:
|
||||
image: ${REGISTRY}/${IMAGE_NAME}:${TAG}
|
||||
container_name: scheduler-app
|
||||
|
||||
restart: always
|
||||
|
||||
volumes:
|
||||
- /home/script:/home/script
|
||||
|
||||
mem_limit: 50m
|
||||
cpus: 0.01
|
||||
networks:
|
||||
- scheduler-net
|
||||
|
||||
networks:
|
||||
scheduler-net:
|
||||
external: true
|
||||
38
index.js
38
index.js
@@ -13,25 +13,9 @@ cron.schedule(
|
||||
"0 9 * * *",
|
||||
async () => {
|
||||
const module = "Birthday Notification";
|
||||
try {
|
||||
let res = await axios.get("http://36.66.3.44:7010/birthday-notification");
|
||||
console.log(module, "success", res.data);
|
||||
} catch (error) {
|
||||
console.error(module, "error", error.message);
|
||||
}
|
||||
},
|
||||
{
|
||||
timezone: "Asia/Jakarta",
|
||||
}
|
||||
);
|
||||
|
||||
cron.schedule(
|
||||
"1 9 * * *",
|
||||
async () => {
|
||||
const module = "Workanniversary";
|
||||
try {
|
||||
let res = await axios.get(
|
||||
"http://36.66.3.44:7010/workanniversary-notification"
|
||||
"http://email-notification:9997/birthday-notification",
|
||||
);
|
||||
console.log(module, "success", res.data);
|
||||
} catch (error) {
|
||||
@@ -40,7 +24,25 @@ cron.schedule(
|
||||
},
|
||||
{
|
||||
timezone: "Asia/Jakarta",
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
cron.schedule(
|
||||
"1 9 * * *",
|
||||
async () => {
|
||||
const module = "Workanniversary";
|
||||
try {
|
||||
let res = await axios.get(
|
||||
"http://email-notification:9997/workanniversary-notification",
|
||||
);
|
||||
console.log(module, "success", res.data);
|
||||
} catch (error) {
|
||||
console.error(module, "error", error.message);
|
||||
}
|
||||
},
|
||||
{
|
||||
timezone: "Asia/Jakarta",
|
||||
},
|
||||
);
|
||||
|
||||
app.use((req, res) => {
|
||||
|
||||
Reference in New Issue
Block a user