mirror of
https://github.com/valitydev/hellgate.git
synced 2024-11-06 02:45:20 +00:00
Setup GA based docker image publication (#5)
This commit is contained in:
parent
93d065b8c4
commit
7ac5596cfa
4
.dockerignore
Normal file
4
.dockerignore
Normal file
@ -0,0 +1,4 @@
|
||||
_build/
|
||||
.git/
|
||||
.github/
|
||||
.vscode/
|
39
.github/workflows/build-image.yaml
vendored
Normal file
39
.github/workflows/build-image.yaml
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
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@v1.12.0
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Construct tags / labels for an image
|
||||
id: meta
|
||||
uses: docker/metadata-action@v3.6.2
|
||||
with:
|
||||
images: |
|
||||
${{ env.REGISTRY }}/${{ github.repository }}
|
||||
tags: |
|
||||
type=sha
|
||||
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v2.8.0
|
||||
with:
|
||||
push: ${{ github.event_name == 'push' }}
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -7,8 +7,6 @@ erl_crash.dump
|
||||
.tags*
|
||||
*.sublime-workspace
|
||||
.DS_Store
|
||||
Dockerfile
|
||||
docker-compose.yml
|
||||
/.idea/
|
||||
*.beam
|
||||
tags
|
||||
|
21
Dockerfile
Normal file
21
Dockerfile
Normal file
@ -0,0 +1,21 @@
|
||||
FROM docker.io/library/erlang:24.1.7.0 AS builder
|
||||
ARG BUILDARCH
|
||||
ARG THRIFT_VERSION=0.14.2.2
|
||||
RUN wget -q -O- "https://github.com/valitydev/thrift/releases/download/${THRIFT_VERSION}/thrift-${THRIFT_VERSION}-linux-${BUILDARCH}.tar.gz" \
|
||||
| tar -xvz -C /usr/local/bin/
|
||||
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 docker.io/library/erlang:24.1.7.0-slim
|
||||
ENV SERVICE=hellgate
|
||||
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
|
@ -1,23 +0,0 @@
|
||||
#!/bin/bash
|
||||
cat <<EOF
|
||||
FROM $BASE_IMAGE
|
||||
MAINTAINER Andrey Mayorov <a.mayorov@rbkmoney.com>
|
||||
COPY ./_build/prod/rel/hellgate /opt/hellgate
|
||||
WORKDIR /opt/hellgate
|
||||
CMD /opt/hellgate/bin/hellgate 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
|
82
Makefile
82
Makefile
@ -1,82 +0,0 @@
|
||||
REBAR := $(shell which rebar3 2>/dev/null || which ./rebar3)
|
||||
SUBMODULES = build_utils
|
||||
SUBTARGETS = $(patsubst %,%/.git,$(SUBMODULES))
|
||||
|
||||
UTILS_PATH := build_utils
|
||||
TEMPLATES_PATH := .
|
||||
|
||||
# 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)
|
||||
|
||||
# Base image for the service
|
||||
BASE_IMAGE_NAME := service-erlang
|
||||
BASE_IMAGE_TAG := ef20e2ec1cb1528e9214bdeb862b15478950d5cd
|
||||
|
||||
# Build image tag to be used
|
||||
BUILD_IMAGE_NAME := build-erlang
|
||||
BUILD_IMAGE_TAG := aaa79c2d6b597f93f5f8b724eecfc31ec2e2a23b
|
||||
|
||||
CALL_ANYWHERE := all submodules rebar-update compile xref lint dialyze plt_update \
|
||||
release clean distclean format check_format
|
||||
|
||||
CALL_W_CONTAINER := $(CALL_ANYWHERE) test
|
||||
|
||||
all: compile
|
||||
|
||||
-include $(UTILS_PATH)/make_lib/utils_container.mk
|
||||
-include $(UTILS_PATH)/make_lib/utils_image.mk
|
||||
|
||||
.PHONY: $(CALL_W_CONTAINER)
|
||||
|
||||
# CALL_ANYWHERE
|
||||
$(SUBTARGETS): %/.git: %
|
||||
git submodule update --init $<
|
||||
touch $@
|
||||
|
||||
submodules: $(SUBTARGETS)
|
||||
|
||||
rebar-update:
|
||||
$(REBAR) update
|
||||
|
||||
compile: submodules rebar-update
|
||||
$(REBAR) compile
|
||||
|
||||
xref: submodules
|
||||
$(REBAR) xref
|
||||
|
||||
lint:
|
||||
elvis rock -V
|
||||
|
||||
check_format:
|
||||
$(REBAR) fmt -c
|
||||
|
||||
format:
|
||||
$(REBAR) fmt -w
|
||||
|
||||
dialyze: submodules
|
||||
$(REBAR) as test dialyzer
|
||||
|
||||
plt_update:
|
||||
$(REBAR) dialyzer -u true -s false
|
||||
|
||||
|
||||
release: submodules
|
||||
$(REBAR) as prod release
|
||||
|
||||
clean:
|
||||
$(REBAR) clean
|
||||
|
||||
distclean:
|
||||
$(REBAR) clean -a
|
||||
rm -rf _build
|
||||
|
||||
# CALL_W_CONTAINER
|
||||
test: submodules
|
||||
$(REBAR) do eunit, ct
|
||||
|
||||
test.%: apps/hellgate/test/hg_%_tests_SUITE.erl
|
||||
$(REBAR) ct --suite=$^
|
@ -1 +0,0 @@
|
||||
Subproject commit 24aa772730be966667adb285a09fcb494d4f218e
|
@ -76,7 +76,7 @@
|
||||
% for introspection on production
|
||||
{recon, "2.5.2"},
|
||||
{logger_logstash_formatter,
|
||||
{git, "https://github.com/valitydev/logger_logstash_formatter.git", {tag, "2c7b716"}}},
|
||||
{git, "https://github.com/valitydev/logger_logstash_formatter.git", {ref, "2c7b716"}}},
|
||||
{iosetopts, {git, "https://github.com/valitydev/iosetopts.git", {ref, "edb445c"}}}
|
||||
]},
|
||||
{relx, [
|
||||
|
Loading…
Reference in New Issue
Block a user