Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: push to github container registry #155

Merged
merged 4 commits into from
Dec 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/on_push_branch__execute_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
# Currently, this need to be synced manually with the Dockerfile. In the future, the workflow should be changed,
# so that a development container is built from the Dockerfile, pushed, and then re-used in the following steps.
# This would also remove the need to install cmake manually in each step:
container: hexpm/elixir:1.13.4-erlang-25.1.1-debian-bullseye-20220801-slim
container: hexpm/elixir:1.13.4-erlang-25.3.2.8-debian-bullseye-20231009-slim

steps:
# See https://github.com/actions/checkout
Expand All @@ -37,7 +37,7 @@ jobs:
# Containers must run in Linux based operating systems
runs-on: ubuntu-latest
# Docker Hub image that `container-job` executes in
container: hexpm/elixir:1.13.4-erlang-25.1.1-debian-bullseye-20220801-slim
container: hexpm/elixir:1.13.4-erlang-25.3.2.8-debian-bullseye-20231009-slim

needs: build_deps

Expand Down Expand Up @@ -92,7 +92,7 @@ jobs:

check_mix_format:
runs-on: ubuntu-latest
container: hexpm/elixir:1.13.4-erlang-25.1.1-debian-bullseye-20220801-slim
container: hexpm/elixir:1.13.4-erlang-25.3.2.8-debian-bullseye-20231009-slim

needs: build_deps

Expand Down
59 changes: 59 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# https://docs.github.com/en/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions#upgrading-a-workflow-that-accesses-ghcrio

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

# GitHub recommends pinning actions to a commit SHA.
# To get a newer version, you will need to update the SHA.
# You can also reference a tag or branch, but the action may change without warning.

name: Create and publish a Docker image

on:
push:
branches:
- main
release:
types: [published]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
platforms: linux/amd64,linux/arm64/v8
target: production
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
23 changes: 12 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
# - Ex: hexpm/elixir:1.13.3-erlang-24.3.4.2-debian-bullseye-20210902-slim
#
ARG ELIXIR_VERSION=1.13.4
ARG OTP_VERSION=25.1.1
ARG DEBIAN_VERSION=bullseye-20220801-slim
ARG OTP_VERSION=25.3.2.8
ARG DEBIAN_VERSION=bullseye-20231009-slim

ARG BUILDER_IMAGE="hexpm/elixir:${ELIXIR_VERSION}-erlang-${OTP_VERSION}-debian-${DEBIAN_VERSION}"
ARG RUNNER_IMAGE="debian:${DEBIAN_VERSION}"
Expand All @@ -32,21 +32,21 @@ RUN apt-get -y update && apt-get install -y curl

# install build dependencies
RUN curl -fsSL $NODE_URL | bash - && \
apt-get install -y nodejs \
build-essential \
inotify-tools \
postgresql-client \
git \
cmake && \
apt-get clean && \
rm -f /var/lib/apt/lists/*_*
apt-get install -y nodejs \
build-essential \
inotify-tools \
postgresql-client \
git \
cmake && \
apt-get clean && \
rm -f /var/lib/apt/lists/*_*

# prepare build dir
WORKDIR /app

# install hex + rebar
RUN mix local.hex --force && \
mix local.rebar --force
mix local.rebar --force

# This is the image we use during development:
FROM base as development
Expand All @@ -65,6 +65,7 @@ FROM base as production_builder
# set build ENV
ENV MIX_ENV="prod"
ENV NODE_ENV="production"
ENV ERL_FLAGS="+JPperf true"

# install mix dependencies
COPY mix.exs mix.lock ./
Expand Down
Loading