Skip to content

Commit

Permalink
feat: docker container and auto build (#3)
Browse files Browse the repository at this point in the history
* feat: docker container and auto build

* fix base image

* cross build even on push for better checks

* fix docker

* docs: docker build badge

* use text in aedes help docs
  • Loading branch information
robertsLando authored Jun 11, 2020
1 parent 2728d35 commit b45d9e1
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 1 deletion.
9 changes: 9 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.git
.github
*.md
docs
.vscode
.nyc_output
.coverage
test
node_modules
57 changes: 57 additions & 0 deletions .github/workflows/dockerbuild.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Docker Build

on:
push:
branches:
- master
pull_request:
release:
types:
- created

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: crazy-max/ghaction-docker-buildx@v1

- name: Just build on PR without push
if: ${{ github.event_name == 'pull_request' }}
run: |
docker buildx build \
-f docker/Dockerfile \
--platform linux/arm64/v8,linux/amd64,linux/arm/v6,linux/arm/v7,linux/386 \
-t moscajs/aedes:dev \
.
- name: Login to dockerhub
if: ${{ github.event_name != 'pull_request' }}
run: |
docker login --username $DOCKER_USERNAME --password $DOCKER_PASSWORD
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}

- uses: crazy-max/ghaction-docker-buildx@v1
if: ${{ github.event_name != 'pull_request' }}

- name: Dev
if: ${{ github.ref == 'refs/heads/master'}}
run: |
docker buildx build \
-f docker/Dockerfile \
--platform linux/arm64/v8,linux/amd64,linux/arm/v6,linux/arm/v7,linux/386 \
-t moscajs/aedes:dev \
--push \
.
- name: Latest & tag
if: ${{ github.event_name == 'release' }}
run: |
docker buildx build \
-f docker/Dockerfile \
--platform linux/arm64/v8,linux/amd64,linux/arm/v6,linux/arm/v7,linux/386 \
-t moscajs/aedes:$(echo ${GITHUB_REF} | sed "s/refs\/tags\/v//") \
-t moscajs/aedes:latest \
--push \
.
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# aedes-cli

![CI](https://github.com/moscajs/aedes-cli/workflows/CI/badge.svg)
![Docker Build](https://github.com/moscajs/aedes-cli/workflows/Docker%20Build/badge.svg)
[![Total alerts](https://img.shields.io/lgtm/alerts/g/moscajs/aedes-cli.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/moscajs/aedes-cli/alerts/)
[![Language grade: JavaScript](https://img.shields.io/lgtm/grade/javascript/g/moscajs/aedes-cli.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/moscajs/aedes-cli/context:javascript)
[![NPM version](https://img.shields.io/npm/v/aedes-cli.svg?style=flat)](https://www.npmjs.com/aedes-cli)
Expand All @@ -11,6 +12,13 @@

Aedes MQTT broker cli plugin

- [aedes-cli](#aedes-cli)
- [Install](#install)
- [Usage](#usage)
- [Docker](#docker)
- [Authorization](#authorization)
- [Persistence and Emitters](#persistence-and-emitters)

## Install

Install the library using [npm](http://npmjs.org/).
Expand All @@ -23,7 +31,7 @@ npm install aedes-cli -g

Here you can see the options accepted by the command line tool:

```bash
```text
$ aedes --help
______ ________ _______ ________ ______
/ \ | \| \ | \ / \
Expand Down Expand Up @@ -108,6 +116,10 @@ module.exports = {

```

## Docker

In order to use `aedes-cli` with docker just run the command `docker run moscajs/aedes:latest [options]` or use [docker-compose](/docker/docker-compose.yml)

## Authorization

Aedes supports user authentication through the use of a specific json file.
Expand Down
13 changes: 13 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node:erbium-alpine

LABEL maintainer="robertsLando"

WORKDIR /usr/src/app/

COPY . .

RUN npm install

EXPOSE 1883 3000 8883 4000

ENTRYPOINT [ "/usr/src/app/bin/aedes" ]
21 changes: 21 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
version: '3.7'
services:
aedes:
container_name: aedes
image: moscajs/aedes:latest
restart: always
stop_signal: SIGINT
ports:
- '1883:1883'
- '3000:3000'
- '4000:4000'
- '8883:8883'
mongo:
container_name: mongo
logging:
driver: none
image: mvertes/alpine-mongo
volumes:
- db-data:/data/db
ports:
- "27017:27017"

0 comments on commit b45d9e1

Please sign in to comment.