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

Containerize application & add GitHub action to build/push image #5

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
62 changes: 62 additions & 0 deletions .github/workflows/docker-build-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Docker

on:
push:
branches:
- master
tags:
- v*

env:
IMAGE_NAME: MattRuddick/aws-ses-template-manager

jobs:
docker:
runs-on: ubuntu-latest
if: github.event_name == 'push'

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Determine target image name
id: image-name
run: |
IMAGE_ID=ghcr.io/$IMAGE_NAME

# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')

# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')

# Use Docker `latest` tag convention
[ "$VERSION" == "master" ] && VERSION=latest

IMAGES=
IMAGES="$IMAGE_ID:$VERSION"$'\n'$IMAGES

# debug output
echo images $IMAGES
echo ::set-output name=images::"$IMAGES"

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true
tags: ${{ steps.image-name.outputs.images }}
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node:14.19.3-slim

LABEL maintainer="Hossam Hammady <github@hammady.net>"

COPY package.json .
RUN npm install

COPY . .

EXPOSE 3333
ENV HOST=0.0.0.0

CMD [ "npm", "start" ]
29 changes: 22 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[![Github All Releases](https://img.shields.io/github/v/release/MattRuddick/aws-ses-template-manager.svg?style=flat)](https://github.com/MattRuddick/aws-ses-template-manager/releases)
[![PR's Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat)](http://makeapullrequest.com)
## Features
A simple productivity tool presenting a user interface around the AWS SES command line interface. This application allows
A simple productivity tool presenting a user interface around the AWS SES command line interface. This application allows
for **quick and easy reviewing, creating, updating and deleting of AWS SES templates** within any region.

Other useful features include:
Expand All @@ -14,8 +14,8 @@ Other useful features include:
See [installation instructions](#Installation) to get started.

## Motivation
AWS currently only allows CRUD actions on SES templates via the command line. Performing these actions especially for multiple templates
can be time consuming and in some cases inefficient depending the volumes of templates you're managing. A simple GUI application
AWS currently only allows CRUD actions on SES templates via the command line. Performing these actions especially for multiple templates
can be time consuming and in some cases inefficient depending the volumes of templates you're managing. A simple GUI application
allowing the user to quickly perform these actions without need to run multiple CLI commands can be more efficient in some cases.

## Screenshots
Expand All @@ -39,21 +39,36 @@ Create/Update template:
- Ensure 'AWS_PROFILE_NAME' within the **.env file** is set to your desired aws named profile. Also ensure for the named profile chosen that all applicable permissions are granted to allow for creating, retrieving, updating, deleting and sending SES templates.
- ```adonis serve --dev``` will run the application.

### Docker installation

Run the following command to run the docker image:

```bash
docker run -p 3333:3333 \
-e AWS_ACCESS_KEY_ID=<your-aws-access-key-id> \
-e AWS_SECRET_ACCESS_KEY=<your-aws-secret-access-key> \
-e AWS_REGION=<your-aws-region> \
ghcr.io/MattRuddick/aws-ses-template-manager:latest
```

You can use the `latest` version of the image or pull a specific release tag.
Browse tags from the packages section on the right.

## How to use
Once installation steps have been followed, navigate to http://127.0.0.1:3333 (host and port can be changed via the .env file if required).

The index page will show a table of existing SES templates in your selected region using the AWS named profile specified in the .env file. You can further go ahead and either delete
The index page will show a table of existing SES templates in your selected region using the AWS named profile specified in the .env file. You can further go ahead and either delete
or edit an SES template from this same table.

## Staying up to date
![newer version screenshot](./resources/img/newer-version-screenshot.png)

The application will **automatically** check to see if you are using the latest release version. If you are not, then you will get
a visual prompt to let you know there is a newer version of the app available (as shown above in the top left). This is a great way to stay
The application will **automatically** check to see if you are using the latest release version. If you are not, then you will get
a visual prompt to let you know there is a newer version of the app available (as shown above in the top left). This is a great way to stay
up to date with new features etc.

You can easily get the latest changes by:
- running the command: ```git pull```
- running the command: ```git pull```
- stop and restarting adonis (```adonis serve --dev```)
- closing and re-opening your local browser tab

Expand Down
14 changes: 12 additions & 2 deletions app/Controllers/Http/SesTemplateController.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
'use strict'
const Env = use('Env');
const AWS = require('aws-sdk');
const credentials = new AWS.SharedIniFileCredentials({profile: Env.get('AWS_PROFILE_NAME', 'default')});
AWS.config.credentials = credentials;
if (
process.env.AWS_ACCESS_KEY_ID &&
process.env.AWS_SECRET_ACCESS_KEY &&
process.env.AWS_REGION
) {
// do nothing, the aws-sdk will read those environment variables
} else {
const credentials = new AWS.SharedIniFileCredentials({
profile: Env.get("AWS_PROFILE_NAME", "default"),
});
AWS.config.credentials = credentials;
}

class SesTemplateController {

Expand Down