build: refs #4409 Deployment files added
This commit is contained in:
parent
b9826d3e8e
commit
e72f54fe98
|
@ -0,0 +1,35 @@
|
||||||
|
FROM debian:bookworm-slim
|
||||||
|
|
||||||
|
ARG DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
|
# NodeJs
|
||||||
|
|
||||||
|
RUN apt-get update \
|
||||||
|
&& apt-get install -y --no-install-recommends \
|
||||||
|
curl \
|
||||||
|
ca-certificates \
|
||||||
|
gnupg2 \
|
||||||
|
&& curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
|
||||||
|
&& apt-get install -y --no-install-recommends nodejs \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Consumer
|
||||||
|
|
||||||
|
WORKDIR /mycdc
|
||||||
|
COPY package.json package-lock.json ./
|
||||||
|
RUN npm install --only=prod
|
||||||
|
|
||||||
|
ARG BUILD_ID=unknown
|
||||||
|
ARG VERSION
|
||||||
|
ENV VERSION $VERSION
|
||||||
|
RUN echo $VERSION
|
||||||
|
|
||||||
|
COPY config config
|
||||||
|
COPY \
|
||||||
|
LICENSE \
|
||||||
|
README.md \
|
||||||
|
consumer.js \
|
||||||
|
queue.js \
|
||||||
|
./
|
||||||
|
|
||||||
|
CMD ["node", "consumer.js"]
|
|
@ -0,0 +1,34 @@
|
||||||
|
FROM debian:bookworm-slim
|
||||||
|
|
||||||
|
ARG DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
|
# NodeJs
|
||||||
|
|
||||||
|
RUN apt-get update \
|
||||||
|
&& apt-get install -y --no-install-recommends \
|
||||||
|
curl \
|
||||||
|
ca-certificates \
|
||||||
|
gnupg2 \
|
||||||
|
&& curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
|
||||||
|
&& apt-get install -y --no-install-recommends nodejs \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Consumer
|
||||||
|
|
||||||
|
WORKDIR /mycdc
|
||||||
|
COPY package.json package-lock.json ./
|
||||||
|
RUN npm install --only=prod
|
||||||
|
|
||||||
|
ARG BUILD_ID=unknown
|
||||||
|
ARG VERSION
|
||||||
|
ENV VERSION $VERSION
|
||||||
|
RUN echo $VERSION
|
||||||
|
|
||||||
|
COPY config config
|
||||||
|
COPY \
|
||||||
|
LICENSE \
|
||||||
|
README.md \
|
||||||
|
mycdc.js \
|
||||||
|
./
|
||||||
|
|
||||||
|
CMD ["node", "mycdc.js"]
|
|
@ -0,0 +1,40 @@
|
||||||
|
#!/usr/bin/env groovy
|
||||||
|
|
||||||
|
pipeline {
|
||||||
|
agent any
|
||||||
|
options {
|
||||||
|
disableConcurrentBuilds()
|
||||||
|
}
|
||||||
|
stages {
|
||||||
|
stage('Build') {
|
||||||
|
when {branch 'master'}
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
def packageJson = readJSON file: 'package.json'
|
||||||
|
env.VERSION = packageJson.version
|
||||||
|
}
|
||||||
|
sh 'docker-compose build --build-arg BUILD_ID=$BUILD_ID --parallel'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Push') {
|
||||||
|
when {branch 'master'}
|
||||||
|
environment {
|
||||||
|
CREDENTIALS = credentials('docker-registry')
|
||||||
|
}
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
def packageJson = readJSON file: 'package.json'
|
||||||
|
env.VERSION = packageJson.version
|
||||||
|
}
|
||||||
|
sh 'docker login --username $CREDS_USR --password $CREDS_PSW $REGISTRY'
|
||||||
|
sh 'docker-compose push'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
post {
|
||||||
|
unsuccessful {
|
||||||
|
setEnv()
|
||||||
|
sendEmail()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
Copyright (C) 2024 - Verdnatura Levante S.L.
|
||||||
|
|
||||||
|
This package is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
On Debian systems, the complete text of the GNU General Public
|
||||||
|
License can be found in "/usr/share/common-licenses/GPL-3".
|
|
@ -0,0 +1,12 @@
|
||||||
|
version: '3.7'
|
||||||
|
services:
|
||||||
|
producer:
|
||||||
|
image: registry.verdnatura.es/mycdc-producer:${VERSION:?}
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile.producer
|
||||||
|
consumer:
|
||||||
|
image: registry.verdnatura.es/mycdc-consumer:${VERSION:?}
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile.consumer
|
5
queue.js
5
queue.js
|
@ -5,7 +5,10 @@ module.exports = class Queue {
|
||||||
}
|
}
|
||||||
|
|
||||||
async consume() {
|
async consume() {
|
||||||
if (this.conf.mode !== 'fk') return;
|
if (this.conf.mode !== 'fk') {
|
||||||
|
console.warn(`Ignoring queue '${this.name} with unknown mode '${this.conf.mode}'`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const channel = await this.consumer.amqpConn.createChannel();
|
const channel = await this.consumer.amqpConn.createChannel();
|
||||||
channel.prefetch(this.conf.amqpPrefetch);
|
channel.prefetch(this.conf.amqpPrefetch);
|
||||||
|
|
Loading…
Reference in New Issue