Skip to content

Commit

Permalink
Create a container image
Browse files Browse the repository at this point in the history
  • Loading branch information
joeyates committed Nov 2, 2023
1 parent 661d064 commit 134c631
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 0 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/publish-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Build and publish the production container image to the GitHub Registry

# Run this workflow every time on every push to the branch `release`.
on:
push:
branches: ['feature/runnable-container']

env:
IMAGE_NAME: imap-backup
REGISTRY_USER: ${{ github.actor }}
REGISTRY_PASSWORD: ${{ github.token }}
REGISTRY: ghcr.io/${{ github.repository_owner }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Build Image
# https://github.com/marketplace/actions/buildah-build
id: build-image
uses: redhat-actions/buildah-build@v2
with:
image: ${{ env.IMAGE_NAME }}
tags: latest ${{ github.sha }}
extra-args: |
--ignorefile ./container/.containerignore
containerfiles: |
./container/Containerfile
labels: |
${{ env.IMAGE_NAME }}:latest
- name: Publish Image
# https://github.com/marketplace/actions/push-to-registry
id: push-to-registry
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build-image.outputs.image }}
tags: ${{ steps.build-image.outputs.tags }}
registry: ${{ secrets.REGISTRY }}
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASSWORD }}
6 changes: 6 additions & 0 deletions container/.containerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*
!bin/imap-backup
!Gemfile
!imap-backup.gemspec
!lib
!LICENSE
12 changes: 12 additions & 0 deletions container/Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM docker.io/library/ruby:3.2.2-alpine3.18

WORKDIR /app

RUN gem install bundler --version "2.4.21"
COPY . .
RUN \
BUNDLE_WITHOUT=development bundle install --no-binstubs && \
rm -f /usr/local/bundle/bin/imap-backup
ENV PATH=${PATH}:/app/bin

CMD ["imap-backup", "backup", "-c", "/config/imap-backup.json"]

0 comments on commit 134c631

Please sign in to comment.