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

10 dockerize #15

Merged
merged 22 commits into from
Mar 7, 2018
Merged
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
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
npm-debug.log
.git/
13 changes: 9 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
language: node_js
node_js: "6"

node_js: '8'
sudo: required
services:
- docker
install: npm install
script: npm test
after_success: npm run coverage
script:
- npm test
- npm run coverage
after_success:
- "./.travis/after_success.sh"
29 changes: 29 additions & 0 deletions .travis/after_success.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash
# These are run after the tests.
# Errors here won't show as a failed build.

# Only build for master
if [ "$TRAVIS_BRANCH" != "master" ]; then
exit 0
fi

# get variables ready
VERSION=$(grep "version" ./package.json | sed -e 's/.*"version".*\([0-9]\.[0-9]\.[0-9]\)".*/\1/')
BUILD_DATE=$(date --date="Feb 2 2014 13:12:10")
COMMIT=$(git rev-parse --short HEAD)

# docker login
docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD"

# make an image
docker build -t fetmar/elevator:latest . \
--build-arg VCS_REF="$COMMIT" \
--build-arg VERSION="$VERSION" \
--build-arg BUILD_DATE="$BUILD_DATE"

# push latest image
docker push fetmar/elevator:"$VERSION"

# push a versioned image
docker tag fetmar/elevator:latest fetmar/elevator:"$VERSION"
docker push fetmar/elevator:latest
38 changes: 38 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
FROM keymetrics/pm2:8-stretch

ARG BUILD_DATE
ARG VCS_REF
ARG VCS_URL
ARG VERSION

# Metadata
LABEL org.label-schema.vendor="Also Engineering" \
org.label-schema.url="https://github.com/fetmar/elevator" \
org.label-schema.name="elevator" \
org.label-schema.description="Manages simple updates from CouchDB to PouchDB." \
org.label-schema.version=$VERSION \
org.label-schema.vcs-url=$VCS_URL \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.build-date=$BUILD_DATE \
org.label-schema.docker.schema-version="1.0"

# Install pm2 as root
RUN npm install pm2 -g

# Make a non-root user.
RUN useradd --create-home -s /bin/bash user
USER user
RUN mkdir /home/user/app
WORKDIR /home/user/app

# For caching
COPY package.json /home/user/app
RUN npm install

# Copy everything
COPY . /home/user/app

# Use pm2 to get the elevator up again when it goes down.
CMD ["pm2-runtime", "process.yaml"]

EXPOSE 4448
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

[![Build Status](https://travis-ci.org/fetmar/elevator.svg?branch=master)](https://travis-ci.org/fetmar/elevator)
[![Coverage Status](https://coveralls.io/repos/github/fetmar/elevator/badge.svg?branch=master)](https://coveralls.io/github/fetmar/elevator?branch=master)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/9b5bd7ee60954e5e96821fbabfbcb0cb)](https://www.codacy.com/app/fetmar/elevator?utm_source=github.com&utm_medium=referral&utm_content=fetmar/elevator&utm_campaign=Badge_Grade)
[![](https://images.microbadger.com/badges/version/fetmar/elevator.svg)](https://microbadger.com/images/fetmar/elevator "Get your own version badge on microbadger.com")

The Elevator provides simple polling based updates for CouchDB server PouchDB client based applications.
The Elevator provides simple polling based updates from CouchDB to PouchDB within Tangerine®.

## Summary
## Overview

These calls were meant to be followed in order `version`, `revs`, `fetch`. The version is retrieved to see if there is a desire for the client devices to update. If the local version doesn't match the server version, the update sequence is triggered. Local document ids can be sent in to the `revs` endpoint to see which need to be updated. The server revs are compared with the local revs and all differing document `_id`s are marked to be fetched. The server also sends new documents that are not archived as well as an update document that will contain any javascript necessary for hotfixing small bugs.
The following API endpoints were meant to be called in order `version`, `revs`, `fetch`. The version is retrieved to see if there is a desire for the client devices to update. If the local version doesn't match the server version, the update sequence is triggered. Local document ids can be sent in to the `revs` endpoint to see which need to be updated. The server revs are compared with the local revs and all differing document `_id`s are marked to be fetched. The server also sends new documents that are not archived as well as an update document that will contain any javascript necessary for hotfixing small bugs.

This service provides a convenient alternative when true CouchDB replication is not required and only a server to client overwrite is required.

## Usage

Expand Down
Loading