diff --git a/.github/workflows/docker-build-push.yml b/.github/workflows/docker-build-push.yml new file mode 100644 index 0000000..3869f23 --- /dev/null +++ b/.github/workflows/docker-build-push.yml @@ -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 }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..481f849 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM node:14.19.3-slim + +LABEL maintainer="Hossam Hammady " + +COPY package.json . +RUN npm install + +COPY . . + +EXPOSE 3333 +ENV HOST=0.0.0.0 + +CMD [ "npm", "start" ] diff --git a/README.md b/README.md index 043d160..c455199 100644 --- a/README.md +++ b/README.md @@ -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: @@ -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 @@ -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= \ + -e AWS_SECRET_ACCESS_KEY= \ + -e 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 diff --git a/app/Controllers/Http/SesTemplateController.js b/app/Controllers/Http/SesTemplateController.js index fbeae97..eb7f0d2 100644 --- a/app/Controllers/Http/SesTemplateController.js +++ b/app/Controllers/Http/SesTemplateController.js @@ -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 {