mirror of
https://github.com/valitydev/party-management.git
synced 2024-11-06 01:05:21 +00:00
MSPF-73: use build_utils (#13)
* MSPF-73: use build_utils - align with the latest & greatest WoWs
This commit is contained in:
parent
d54e4e64a3
commit
b321e8952d
9
.gitignore
vendored
9
.gitignore
vendored
@ -6,11 +6,6 @@ erl_crash.dump
|
||||
.tags*
|
||||
*.sublime-workspace
|
||||
.DS_Store
|
||||
Dockerfile
|
||||
docker-compose.yml
|
||||
|
||||
# wercker
|
||||
/_builds/
|
||||
/_cache/
|
||||
/_projects/
|
||||
/_steps/
|
||||
/_temp/
|
||||
/.wercker/
|
||||
|
4
.gitmodules
vendored
4
.gitmodules
vendored
@ -2,3 +2,7 @@
|
||||
path = apps/hg_proto/damsel
|
||||
url = git@github.com:keynslug/damsel.git
|
||||
branch = HG-40/fix/events
|
||||
[submodule "build_utils"]
|
||||
path = build_utils
|
||||
url = git@github.com:rbkmoney/build_utils.git
|
||||
branch = master
|
||||
|
@ -1,7 +0,0 @@
|
||||
FROM rbkmoney/service_erlang:latest
|
||||
MAINTAINER Andrey Mayorov <a.mayorov@rbkmoney.com>
|
||||
COPY ./_build/prod/rel/hellgate /opt/hellgate
|
||||
CMD /opt/hellgate/bin/hellgate foreground
|
||||
LABEL service_version="semver"
|
||||
WORKDIR /opt/hellgate
|
||||
|
24
Dockerfile.sh
Executable file
24
Dockerfile.sh
Executable file
@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
cat <<EOF
|
||||
FROM $BASE_IMAGE
|
||||
MAINTAINER Andrey Mayorov <a.mayorov@rbkmoney.com>
|
||||
COPY ./_build/prod/rel/hellgate /opt/hellgate
|
||||
CMD /opt/hellgate/bin/hellgate foreground
|
||||
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)
|
||||
WORKDIR /opt/hellgate
|
||||
EOF
|
||||
|
52
Jenkinsfile
vendored
52
Jenkinsfile
vendored
@ -1,38 +1,48 @@
|
||||
#!groovy
|
||||
|
||||
// Args:
|
||||
// GitHub repo name
|
||||
// Jenkins agent label
|
||||
// Tracing artifacts to be stored alongside build logs
|
||||
pipeline("hellgate", 'docker-host', "_build/") {
|
||||
|
||||
runStage('submodules') {
|
||||
sh 'make w_container_submodules'
|
||||
def finalHook = {
|
||||
runStage('store CT logs') {
|
||||
archive '_build/test/logs/'
|
||||
}
|
||||
}
|
||||
|
||||
build('hellgate', 'docker-host', finalHook) {
|
||||
checkoutRepo()
|
||||
loadBuildUtils()
|
||||
|
||||
def pipeDefault
|
||||
runStage('load pipeline') {
|
||||
env.JENKINS_LIB = "build_utils/jenkins_lib"
|
||||
pipeDefault = load("${env.JENKINS_LIB}/pipeDefault.groovy")
|
||||
}
|
||||
|
||||
pipeDefault() {
|
||||
runStage('compile') {
|
||||
sh 'make w_container_compile'
|
||||
sh 'make wc_compile'
|
||||
}
|
||||
|
||||
runStage('lint') {
|
||||
sh 'make w_container_lint'
|
||||
sh 'make wc_lint'
|
||||
}
|
||||
|
||||
runStage('xref') {
|
||||
sh 'make w_container_xref'
|
||||
sh 'make wc_xref'
|
||||
}
|
||||
|
||||
runStage('test') {
|
||||
sh "make w_compose_test"
|
||||
}
|
||||
|
||||
runStage('dialyze') {
|
||||
sh 'make w_container_dialyze'
|
||||
sh 'make wc_dialyze'
|
||||
}
|
||||
runStage('test') {
|
||||
sh "make wdeps_test"
|
||||
}
|
||||
|
||||
if (env.BRANCH_NAME == 'master') {
|
||||
runStage('push container') {
|
||||
sh 'make push'
|
||||
runStage('make release') {
|
||||
sh "make wc_release"
|
||||
}
|
||||
runStage('build image') {
|
||||
sh "make build_image"
|
||||
}
|
||||
runStage('push image') {
|
||||
sh "make push_image"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
42
Makefile
42
Makefile
@ -1,25 +1,34 @@
|
||||
REBAR := $(shell which rebar3 2>/dev/null || which ./rebar3)
|
||||
SUBMODULES = apps/hg_proto/damsel
|
||||
SUBMODULES = apps/hg_proto/damsel build_utils
|
||||
SUBTARGETS = $(patsubst %,%/.git,$(SUBMODULES))
|
||||
|
||||
REGISTRY := dr.rbkmoney.com
|
||||
ORG_NAME := rbkmoney
|
||||
BASE_IMAGE := "$(REGISTRY)/$(ORG_NAME)/build:latest"
|
||||
UTILS_PATH := build_utils/make_lib
|
||||
TEMPLATES_PATH := .
|
||||
|
||||
# Note: RELNAME should match the name of
|
||||
# the first service in docker-compose.yml
|
||||
RELNAME := hellgate
|
||||
# Name of the service
|
||||
SERVICE_NAME := hellgate
|
||||
# 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)
|
||||
|
||||
TAG = latest
|
||||
IMAGE_NAME = "$(REGISTRY)/$(ORG_NAME)/$(RELNAME):$(TAG)"
|
||||
# Base image for the service
|
||||
BASE_IMAGE_NAME := service_erlang
|
||||
BASE_IMAGE_TAG := 170b7dd12d62431303f8bb514abe2b43468223a1
|
||||
|
||||
CALL_ANYWHERE := submodules rebar-update compile xref lint dialyze start devrel release clean distclean
|
||||
# Build image tag to be used
|
||||
BUILD_IMAGE_TAG := 530114ab63a7ff0379a2220169a0be61d3f7c64c
|
||||
|
||||
CALL_ANYWHERE := all submodules rebar-update compile xref lint dialyze start devrel release clean distclean
|
||||
|
||||
CALL_W_CONTAINER := $(CALL_ANYWHERE) test
|
||||
|
||||
include utils.mk
|
||||
all: compile
|
||||
|
||||
.PHONY: $(CALL_W_CONTAINER) all containerize push $(UTIL_TARGETS)
|
||||
-include $(UTILS_PATH)/utils_container.mk
|
||||
-include $(UTILS_PATH)/utils_image.mk
|
||||
|
||||
.PHONY: $(CALL_W_CONTAINER)
|
||||
|
||||
# CALL_ANYWHERE
|
||||
$(SUBTARGETS): %/.git: %
|
||||
@ -63,12 +72,3 @@ distclean:
|
||||
test: submodules
|
||||
$(REBAR) ct
|
||||
|
||||
# OTHER
|
||||
all: compile
|
||||
|
||||
containerize: w_container_release
|
||||
$(DOCKER) build --force-rm --tag $(IMAGE_NAME) .
|
||||
|
||||
push: containerize
|
||||
$(DOCKER) push "$(IMAGE_NAME)"
|
||||
|
||||
|
1
build_utils
Submodule
1
build_utils
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 454ef80c7a398cac37fb5ad2034a892bafd19cfd
|
13
docker-compose.yml → docker-compose.sh
Normal file → Executable file
13
docker-compose.yml → docker-compose.sh
Normal file → Executable file
@ -1,22 +1,23 @@
|
||||
#!/bin/bash
|
||||
cat <<EOF
|
||||
version: '2'
|
||||
|
||||
services:
|
||||
hellgate:
|
||||
image: dr.rbkmoney.com/rbkmoney/build:latest
|
||||
${SERVICE_NAME}:
|
||||
image: ${BUILD_IMAGE}
|
||||
volumes:
|
||||
- .:/code
|
||||
working_dir: /code
|
||||
command: /sbin/init
|
||||
links:
|
||||
depends_on:
|
||||
- machinegun
|
||||
|
||||
machinegun:
|
||||
image: dr.rbkmoney.com/rbkmoney/mg_prototype:87bef0b
|
||||
command: /opt/mgun/bin/mgun foreground
|
||||
|
||||
networks:
|
||||
default:
|
||||
driver: bridge
|
||||
driver_opts:
|
||||
com.docker.network.enable_ipv6: "true"
|
||||
com.docker.network.bridge.enable_ip_masquerade: "false"
|
||||
EOF
|
||||
|
46
utils.mk
46
utils.mk
@ -1,46 +0,0 @@
|
||||
SHELL := /bin/bash
|
||||
|
||||
which = $(if $(shell which $(1) 2>/dev/null),\
|
||||
$(shell which $(1) 2>/dev/null),\
|
||||
$(error "Error: could not locate $(1)!"))
|
||||
|
||||
DOCKER = $(call which,docker)
|
||||
DOCKER_COMPOSE = $(call which,docker-compose)
|
||||
|
||||
UTIL_TARGETS := to_dev_container w_container_% w_compose_% run_w_container_% check_w_container_%
|
||||
|
||||
ifndef RELNAME
|
||||
$(error RELNAME is not set)
|
||||
endif
|
||||
|
||||
ifndef CALL_W_CONTAINER
|
||||
$(error CALL_W_CONTAINER is not set)
|
||||
endif
|
||||
|
||||
to_dev_container:
|
||||
$(DOCKER) run -it --rm -v $$PWD:$$PWD --workdir $$PWD $(BASE_IMAGE) /bin/bash
|
||||
|
||||
w_container_%:
|
||||
$(MAKE) -s run_w_container_$*
|
||||
|
||||
w_compose_%:
|
||||
$(MAKE) -s run_w_compose_$*
|
||||
|
||||
run_w_container_%: check_w_container_%
|
||||
{ \
|
||||
$(DOCKER) run --rm -v $$PWD:$$PWD --workdir $$PWD $(BASE_IMAGE) make $* ; \
|
||||
res=$$? ; exit $$res ; \
|
||||
}
|
||||
|
||||
run_w_compose_%: check_w_container_%
|
||||
{ \
|
||||
$(DOCKER_COMPOSE) up -d ; \
|
||||
$(DOCKER_COMPOSE) exec -T $(RELNAME) make $* ; \
|
||||
res=$$? ; \
|
||||
$(DOCKER_COMPOSE) down ; \
|
||||
exit $$res ; \
|
||||
}
|
||||
|
||||
check_w_container_%:
|
||||
$(if $(filter $*,$(CALL_W_CONTAINER)),,\
|
||||
$(error "Error: target '$*' cannot be called w_container_"))
|
Loading…
Reference in New Issue
Block a user