Skip to content

Commit

Permalink
TD-6: Replace rbkmoney build image with common one (#4)
Browse files Browse the repository at this point in the history
* TD-6: Decouple from rbkmoney build image

* Add env variables to build CI

* Fix image name

* Try to fix arg

* Import .env in Makefile

* Add args to docker step

* Fix build-args format

* Fix typo

* Add setup buildx to CI
  • Loading branch information
ndiezel0 authored Feb 1, 2022
1 parent 7c026e2 commit 8bd7828
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
5 changes: 2 additions & 3 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
# You SHOULD specify point releases here so that build time and run time Erlang/OTPs
# are the same. See: https://github.com/erlware/relx/pull/902
ERLANG_VERSION=24.2.0
THRIFT_VERSION=0.14.2.1

DOCKER_BUILDKIT=1
THRIFT_VERSION=0.14.2.2
SERVICE=dominant
11 changes: 11 additions & 0 deletions .github/workflows/build-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,20 @@ jobs:
tags: |
type=sha
# https://docs.github.com/en/actions/learn-github-actions/workflow-commands-for-github-actions#setting-an-environment-variable
- name: Update environment variables
run: grep -v '^#' .env >> $GITHUB_ENV

- name: Setup Buildx
uses: docker/setup-buildx-action@v1

- 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 }}
build-args: |
ERLANG_VERSION=${{ env.ERLANG_VERSION }}
THRIFT_VERSION=${{ env.THRIFT_VERSION }}
SERVICE=${{ env.SERVICE }}
15 changes: 11 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
FROM ghcr.io/rbkmoney/build-erlang:785d48cbfa7e7f355300c08ba9edc6f0e78810cb AS builder
ARG ERLANG_VERSION

FROM erlang:${ERLANG_VERSION} AS builder

ARG THRIFT_VERSION
ARG BUILDARCH
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 erlang:24.1.3.0-slim
ENV SERVICE=dominant
FROM erlang:${ERLANG_VERSION}-slim
ARG SERVICE
ENV CHARSET=UTF-8
ENV LANG=C.UTF-8
COPY --from=builder /build/_build/prod/rel/${SERVICE} /opt/${SERVICE}
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# For example, to run with podman put `DOCKER=podman` there.
-include Makefile.env

SERVICE := dominant
-include .env

# NOTE
# Variables specified in `.env` file are used to pick and setup specific
Expand Down

0 comments on commit 8bd7828

Please sign in to comment.