TECHDEBT-21: Fix decoding module initialization error + updated build system (#1)

* removed build utils sub module

* added iosetopts dep

* added pure image build

* added dockerfile content

* fixed service name
This commit is contained in:
Артем 2022-01-14 11:00:57 +03:00 committed by GitHub
parent 90f64bb523
commit 37a8017739
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 57 additions and 94 deletions

38
.github/workflows/build-image.yaml vendored Normal file
View File

@ -0,0 +1,38 @@
name: Build Docker image
on:
push:
branches: [master]
pull_request:
branches: ["*"]
env:
REGISTRY: ghcr.io
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Construct tags / labels for an image
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: |
${{ env.REGISTRY }}/${{ github.repository }}
tags: |
type=sha
- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
push: ${{ github.event_name == 'push' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

2
.gitignore vendored
View File

@ -9,8 +9,6 @@ erl_crash.dump
\#*
.\#*
.tags*
Dockerfile
docker-compose.yml
rebar3.crashdump
/_checkouts/
/test/policies/bundle.tar.gz

3
.gitmodules vendored
View File

@ -1,3 +0,0 @@
[submodule "build-utils"]
path = build_utils
url = git@github.com:rbkmoney/build_utils

17
Dockerfile Normal file
View File

@ -0,0 +1,17 @@
FROM ghcr.io/rbkmoney/build-erlang:785d48cbfa7e7f355300c08ba9edc6f0e78810cb AS builder
RUN mkdir /build
COPY . /build/
WORKDIR /build
RUN rebar3 compile
RUN rebar3 as prod release
# Keep in sync with Erlang/OTP version in build image
FROM erlang:24.1.3.0-slim
ENV SERVICE=bouncer
ENV CHARSET=UTF-8
ENV LANG=C.UTF-8
COPY --from=builder /build/_build/prod/rel/${SERVICE} /opt/${SERVICE}
WORKDIR /opt/${SERVICE}
ENTRYPOINT []
CMD /opt/${SERVICE}/bin/${SERVICE} foreground
EXPOSE 8022

View File

@ -1,24 +0,0 @@
#!/bin/bash
cat <<EOF
FROM $BASE_IMAGE
LABEL maintainer="Andrey Mayorov <a.mayorov@rbkmoney.com>"
RUN mkdir -p /var/log/bouncer
COPY ./_build/prod/rel/bouncer /opt/bouncer
WORKDIR /opt/bouncer
CMD /opt/bouncer/bin/bouncer foreground
EXPOSE 8022
LABEL com.rbkmoney.$SERVICE_NAME.parent=$BASE_IMAGE_NAME \
com.rbkmoney.$SERVICE_NAME.parent_tag=$BASE_IMAGE_TAG \
com.rbkmoney.$SERVICE_NAME.build_img=build \
com.rbkmoney.$SERVICE_NAME.build_img_tag=$BUILD_IMAGE_TAG \
com.rbkmoney.$SERVICE_NAME.commit_id=$(git rev-parse HEAD) \
com.rbkmoney.$SERVICE_NAME.commit_number=$(git rev-list --count HEAD) \
com.rbkmoney.$SERVICE_NAME.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)
EOF

23
Jenkinsfile vendored
View File

@ -1,23 +0,0 @@
#!groovy
// -*- mode: groovy -*-
def finalHook = {
runStage('store CT logs') {
archive '_build/test/logs/'
}
}
build('bouncer', 'docker-host', finalHook) {
checkoutRepo()
loadBuildUtils()
def pipeErlangService
runStage('load pipeline') {
env.JENKINS_LIB = "build_utils/jenkins_lib"
env.SH_TOOLS = "build_utils/sh"
pipeErlangService = load("${env.JENKINS_LIB}/pipeErlangService.groovy")
}
pipeErlangService.runPipe(true, false)
}

@ -1 +0,0 @@
Subproject commit a7655bc60c877a65cdfe3d9b668021d970d88a76

View File

@ -1,41 +0,0 @@
#!/bin/bash
OPA_VSN="0.26.0-debug"
OPA_IMAGE="openpolicyagent/opa:${OPA_VSN}"
POLICY_DIR="/var/opa/policies"
cat <<EOF
version: '2.1'
services:
${SERVICE_NAME}:
image: ${BUILD_IMAGE}
volumes:
- .:$PWD
- $HOME/.cache:/home/$UNAME/.cache
working_dir: $PWD
command: /sbin/init
depends_on:
opa:
condition: service_healthy
opa:
image: ${OPA_IMAGE}
entrypoint: ["sh", "-c"]
command: ["cd ${POLICY_DIR} &&
/opa build . &&
/opa run
--server
--addr :8181
--set decision_logs.console=true
--bundle bundle.tar.gz
"]
volumes:
- ./test/policies:${POLICY_DIR}:rw
healthcheck:
test: ["CMD", "sh", "-c", "wget -q --tries=1 --spider http://localhost:8181/"]
interval: 5s
timeout: 1s
retries: 5
EOF

View File

@ -44,6 +44,7 @@
% Production-only deps.
% Defined here for the sake of rebar-locking.
{recon, "2.5.2"},
{iosetopts, {git, "https://github.com/valitydev/iosetopts.git", {ref, "edb445c"}}},
{logger_logstash_formatter,
{git, "https://github.com/rbkmoney/logger_logstash_formatter.git", {branch, "master"}}},
{how_are_you, {git, "https://github.com/rbkmoney/how_are_you.git", {branch, "master"}}},
@ -158,6 +159,7 @@
%% Relx configuration
{relx, [
{release, {bouncer, "0.1.0"}, [
iosetopts,
% tools for introspection
{recon, load},
% debugger