diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..d0f31b08 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "build_utils"] + path = build_utils + url = git+ssh://git@github.com/rbkmoney/build_utils diff --git a/Dockerfile.sh b/Dockerfile.sh new file mode 100755 index 00000000..887ec836 --- /dev/null +++ b/Dockerfile.sh @@ -0,0 +1,24 @@ +#!/bin/bash +cat < +COPY dist /usr/share/nginx/html +COPY nginx.conf /etc/nginx/vhosts.d/payform.js.conf +COPY containerpilot.json /etc/containerpilot.json +CMD /bin/containerpilot -config file:///etc/containerpilot.json /usr/sbin/nginx -g "daemon off;" +LABEL base_image_tag=$BASE_IMAGE_TAG +LABEL build_image_tag=$BUILD_IMAGE_TAG +# A bit of magic to get a proper branch name +# even when the HEAD is detached (Hey Jenkins! +# BRANCH_NAME is available in Jenkins env). +LABEL branch=$( \ + if [ "HEAD" != $(git rev-parse --abbrev-ref HEAD) ]; then \ + echo $(git rev-parse --abbrev-ref HEAD); \ + elif [ -n "$BRANCH_NAME" ]; then \ + echo $BRANCH_NAME; \ + else \ + echo $(git name-rev --name-only HEAD); \ + fi) +LABEL commit=$(git rev-parse HEAD) +LABEL commit_number=$(git rev-list --count HEAD) +EOF diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 00000000..cdfc4db2 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,38 @@ +#!groovy + +build('tokenizer.js', 'docker-host') { + checkoutRepo() + loadBuildUtils() + + def pipeDefault + runStage('load pipeline') { + env.JENKINS_LIB = "build_utils/jenkins_lib" + pipeDefault = load("${env.JENKINS_LIB}/pipeDefault.groovy") + } + + pipeDefault() { + //ToDo: npm stuff should be in a cache, when caching is implemented! + runStage('init') { + sh 'make wc_init' + } + runStage('build') { + sh 'make wc_build' + } + runStage('build image') { + sh 'make build_image' + } + + try { + if (env.BRANCH_NAME == 'master') { + runStage('push image') { + sh 'make push_image' + } + } + } finally { + runStage('rm local image') { + sh 'make rm_local_image' + } + } + } +} + diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..74c4da84 --- /dev/null +++ b/Makefile @@ -0,0 +1,42 @@ +SUBMODULES = build_utils +SUBTARGETS = $(patsubst %,%/.git,$(SUBMODULES)) + +UTILS_PATH := build_utils +TEMPLATES_PATH := . + +# Name of the service +SERVICE_NAME := tokenizer.js +# Service image default tag +SERVICE_IMAGE_TAG ?= $(shell git rev-parse HEAD) +# The tag for service image to be pushed with +SERVICE_IMAGE_PUSH_TAG ?= $(SERVICE_IMAGE_TAG) + +# Base image for the service +BASE_IMAGE_NAME := service-fe +BASE_IMAGE_TAG := a58a828755e9d342ecbd7071e7dc224ffe546378 + +BUILD_IMAGE_TAG := 6fb209e428feaa0ef6cec07d3909d8a3c4013537 + +CALL_W_CONTAINER := init build clean submodules + +.PHONY: $(CALL_W_CONTAINER) + +all: build + +-include $(UTILS_PATH)/make_lib/utils_image.mk +-include $(UTILS_PATH)/make_lib/utils_container.mk + +$(SUBTARGETS): %/.git: % + git submodule update --init $< + touch $@ + +submodules: $(SUBTARGETS) + +init: + npm install + +build: + npm run build + +clean: + rm -rf dist diff --git a/build_utils b/build_utils new file mode 160000 index 00000000..4858499f --- /dev/null +++ b/build_utils @@ -0,0 +1 @@ +Subproject commit 4858499fdd62af516a2239d51d12d82be0921857 diff --git a/containerpilot.json b/containerpilot.json new file mode 100644 index 00000000..87f29cd1 --- /dev/null +++ b/containerpilot.json @@ -0,0 +1,13 @@ +{ + "consul": "{{ .CONSUL_ADDR }}", + "services": [ + { + "name": "{{ .SERVICE_NAME }}", + "port": 8080, + "health": "/usr/bin/curl --silent --show-error --output /dev/null localhost:8080", + "poll": 1, + "ttl": 2, + "interfaces": ["inet6", "inet"] + } + ] +} diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 00000000..d121a0ea --- /dev/null +++ b/nginx.conf @@ -0,0 +1,14 @@ +server { + listen 8080; + server_name localhost; + + location / { + root /usr/share/nginx/html; + index index.html index.htm; + } + + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } +} \ No newline at end of file diff --git a/package.json b/package.json index 32456c1f..565588c0 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "1.0.0", "description": "", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "build": "gulp build" }, "repository": { "type": "git",