From 03d0f42308d21d813af049e698f1ed17cbe6cff6 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Mon, 18 Oct 2021 10:54:32 +0200 Subject: [PATCH] First commit --- .dockerignore | 1 + Dockerfile | 26 ++++++++++++++++++++++++++ Jenkinsfile | 37 +++++++++++++++++++++++++++++++++++++ LICENSE | 17 +++++++++++++++++ README.md | 6 ++++++ docker-compose.yml | 11 +++++++++++ 6 files changed, 98 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 Jenkinsfile create mode 100644 LICENSE create mode 100644 README.md create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..b512c09 --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +node_modules \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d49ac5d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,26 @@ +FROM registry.verdnatura.es/vn-apache +ENV TZ Europe/Madrid + +ARG DEBIAN_FRONTEND=noninteractive +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + curl \ + ca-certificates \ + gnupg2 \ + libfontconfig \ + && curl -sL https://deb.nodesource.com/setup_12.x | bash - \ + && apt-get install -y --no-install-recommends \ + nodejs \ + && apt-get purge -y --auto-remove \ + gnupg2 \ + && rm -rf /var/lib/apt/lists/* + +WORKDIR /usr/local/apache2/htdocs +COPY package.json package-lock.json ./ +RUN npm install --only=prod + +COPY js js +COPY \ + LICENSE \ + README.md \ + ./ diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..e01c82e --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,37 @@ +#!/usr/bin/env groovy + +pipeline { + agent any + environment { + PROJECT_NAME = 'time-tracker' + STACK_NAME = "${env.PROJECT_NAME}-${env.BRANCH_NAME}" + } + stages { + stage('Checkout') { + steps { + setEnv() + } + } + stage('Build') { + environment { + CREDENTIALS = credentials('docker-registry') + } + steps { + dockerBuild() + } + } + stage('Deploy') { + environment { + DOCKER_HOST = "${env.SWARM_HOST}" + } + steps { + sh "docker stack deploy --with-registry-auth --prune --compose-file docker-compose.yml ${env.STACK_NAME}" + } + } + } + post { + always { + sendEmail() + } + } +} \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..aab011a --- /dev/null +++ b/LICENSE @@ -0,0 +1,17 @@ +Copyright (C) 2021 - 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 . + +On Debian systems, the complete text of the GNU General Public +License can be found in "/usr/share/common-licenses/GPL-3". diff --git a/README.md b/README.md new file mode 100644 index 0000000..435afd5 --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ +# Time tracker + +Launch application in development environment. +``` +$ php -S 0.0.0.0:9090 -t . +``` diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..f03a367 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,11 @@ +version: '3.7' +services: + main: + image: registry.verdnatura.es/time-tracker + ports: + - 80 + deploy: + replicas: 1 + placement: + constraints: + - node.role == worker