Skip to content

Commit

Permalink
Merge branch 'feature/runnable-container'
Browse files Browse the repository at this point in the history
  • Loading branch information
joeyates committed Nov 2, 2023
2 parents 5cdbef2 + 243a480 commit a82013e
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 6 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: ${{ env.REGISTRY }}
username: ${{ env.REGISTRY_USER }}
password: ${{ env.REGISTRY_PASSWORD }}
14 changes: 8 additions & 6 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ source "https://rubygems.org"

gemspec

gem "aruba", ">= 0.0.0"
gem "pry-byebug"
gem "rspec", ">= 3.0.0"
gem "rubocop-rspec"
gem "simplecov"
gem "yard"
group :development do
gem "aruba", ">= 0.0.0"
gem "pry-byebug"
gem "rspec", ">= 3.0.0"
gem "rubocop-rspec"
gem "simplecov"
gem "yard"
end
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,45 @@ See below for a [full list of commands](#Commands).

# Installation

## Docker or Podman

If you have Docker or Podman installed, the easist way to use imap-backup
is via the container image.

You'll need to choose a path on your computer where your backups will be saved,
we'll use `./my-data` here.

If you have just one account, you can do as follows

```sh
docker run -v ./my-data:/data -ti ghcr.io/joeyates/imap-backup:latest \
imap-backup single backup \
--email me@example.com --password mysecret --server imap.example.com \
--path /data/me_example.com
```

Podman will work exactly the same.

If you have multiple accounts, you can create a configuration file.

You'll need to choose a path on your computer where your configuration will be saved,
we'll use `./my-config` here.

First, run the menu-driven setup program to configure your accounts

```sh
docker run -ti -v ./my-config:/config -v ./my-data:/data -ti ghcr.io/joeyates/imap-backup:latest \
imap-backup setup -c /config/imap-backup.json
```

Then, run the backup

```sh
docker run -v ./my-config:/config -v ./my-data:/data -ti ghcr.io/joeyates/imap-backup:latest \
imap-backup backup -c /config/imap-backup.json
```


## Homebrew (macOS)

![Homebrew installs](https://img.shields.io/homebrew/installs/dm/imap-backup?label=Homebrew%20installs)
Expand Down
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

COPY . .
RUN \
gem install bundler --version "2.4.21" && \
BUNDLE_WITHOUT=development bundle install && \
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 a82013e

Please sign in to comment.