Build and push images w/ GH Actions workflow

This commit is contained in:
Andrew Mayorov 2021-12-28 18:11:52 +03:00
parent e3f6320077
commit 47cd1589a1
No known key found for this signature in database
GPG Key ID: 2837C62ACFBFED5D
3 changed files with 56 additions and 2 deletions

39
.github/workflows/build-image.yaml vendored Normal file
View 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@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

@ -8,8 +8,6 @@ erl_crash.dump
*.sublime-workspace *.sublime-workspace
.edts .edts
.DS_Store .DS_Store
Dockerfile
docker-compose.yml
/.idea/ /.idea/
*.beam *.beam
/test/log/ /test/log/

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=fistful-server
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