From b54b795c0c71ea8a65336958df8cd2c34e88fbaa Mon Sep 17 00:00:00 2001 From: Chris Caron Date: Thu, 2 Jan 2020 23:24:07 -0500 Subject: [PATCH 1/2] prepared for docker hub --- Dockerfile | 57 +++++++++++++++++++ Dockerfile-nginx | 3 +- .../nginx/conf.d/default.conf | 0 {apprise_api => etc/nginx}/nginx.conf | 0 etc/services.d/gunicorn/finish | 5 ++ etc/services.d/gunicorn/run | 3 + etc/services.d/nginx/finish | 5 ++ etc/services.d/nginx/run | 3 + 8 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 Dockerfile rename apprise_api/apprise_api.conf => etc/nginx/conf.d/default.conf (100%) rename {apprise_api => etc/nginx}/nginx.conf (100%) create mode 100755 etc/services.d/gunicorn/finish create mode 100755 etc/services.d/gunicorn/run create mode 100755 etc/services.d/nginx/finish create mode 100755 etc/services.d/nginx/run diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8de5fd7 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,57 @@ +# Use the standard Nginx image from Docker Hub +FROM nginx + +# set version label +ARG BUILD_DATE +ARG VERSION +ARG HEALTHCHECKS_RELEASE +LABEL build_version="Apprise API version:- ${VERSION} Build-date:- ${BUILD_DATE}" +LABEL maintainer="Chris-Caron" + +# set environment variables +ENV PYTHONDONTWRITEBYTECODE 1 +ENV PYTHONUNBUFFERED 1 +ENV APPRISE_CONFIG_DIR /config + +# Install Python Dependencies +COPY ./requirements.txt etc/requirements.txt + +# Install Python +RUN apt-get update && \ + apt-get install -y curl python3 python3-pip && \ + pip3 install -r etc/requirements.txt gunicorn + +# Install s6-overlay +RUN curl -fL -o /tmp/s6-overlay.tar.gz \ + https://github.com/just-containers/s6-overlay/releases/download/v1.22.1.0/s6-overlay-amd64.tar.gz \ + && tar -xzf /tmp/s6-overlay.tar.gz -C / \ + && rm -rf /tmp/* + +ENV S6_KEEP_ENV=1 \ + S6_CMD_WAIT_FOR_SERVICES=1 + +# set work directory +WORKDIR /opt/apprise + +# Copy our static content in place +COPY apprise_api/static /usr/share/nginx/html/s/ + +# Copy over Apprise API +COPY apprise_api/ webapp + +# System Configuration +COPY etc /etc/ + +# gunicorn to expose on port 8080 +# nginx to expose on port 8000 +# disable logging on gunicorn +RUN \ + sed -i -e 's/backend:8000/localhost:8080/g' \ + -e 's/listen\([ \t]\+\)[^;]\+;/listen\18000;/g' \ + /etc/nginx/conf.d/default.conf && \ + sed -i -e 's/:8000/:8080/g' /opt/apprise/webapp/gunicorn.conf.py + +EXPOSE 8000 +VOLUME /config + +ENTRYPOINT ["/init"] diff --git a/Dockerfile-nginx b/Dockerfile-nginx index 34dda84..0b94265 100644 --- a/Dockerfile-nginx +++ b/Dockerfile-nginx @@ -2,8 +2,7 @@ FROM nginx # Copy our customized NginX configuration (for container usage) -COPY apprise_api/nginx.conf /etc/nginx/nginx.conf -COPY apprise_api/apprise_api.conf /etc/nginx/conf.d/default.conf +COPY etc/nginx /etc/nginx/ # Copy our static content in place COPY apprise_api/static /usr/share/nginx/html/s/ diff --git a/apprise_api/apprise_api.conf b/etc/nginx/conf.d/default.conf similarity index 100% rename from apprise_api/apprise_api.conf rename to etc/nginx/conf.d/default.conf diff --git a/apprise_api/nginx.conf b/etc/nginx/nginx.conf similarity index 100% rename from apprise_api/nginx.conf rename to etc/nginx/nginx.conf diff --git a/etc/services.d/gunicorn/finish b/etc/services.d/gunicorn/finish new file mode 100755 index 0000000..348a5ac --- /dev/null +++ b/etc/services.d/gunicorn/finish @@ -0,0 +1,5 @@ +#!/usr/bin/env sh +echo >&2 "gunicorn exited. code=${1}" + +# terminate other services to exit from the container +exec s6-svscanctl -t /var/run/s6/services diff --git a/etc/services.d/gunicorn/run b/etc/services.d/gunicorn/run new file mode 100755 index 0000000..9f8a875 --- /dev/null +++ b/etc/services.d/gunicorn/run @@ -0,0 +1,3 @@ +#!/usr/bin/with-contenv sh +echo >&2 "Starting gunicorn" +exec gunicorn -c /opt/apprise/webapp/gunicorn.conf.py --worker-tmp-dir /dev/shm core.wsgi diff --git a/etc/services.d/nginx/finish b/etc/services.d/nginx/finish new file mode 100755 index 0000000..64ae513 --- /dev/null +++ b/etc/services.d/nginx/finish @@ -0,0 +1,5 @@ +#!/usr/bin/env sh +echo >&2 "nginx exited. code=${1}" + +# terminate other services to exit from the container +exec s6-svscanctl -t /var/run/s6/services diff --git a/etc/services.d/nginx/run b/etc/services.d/nginx/run new file mode 100755 index 0000000..caa5d14 --- /dev/null +++ b/etc/services.d/nginx/run @@ -0,0 +1,3 @@ +#!/usr/bin/with-contenv sh +echo >&2 "Starting nginx" +nginx -g 'daemon off;' From 61a1f68a31cfb603a83df640f47affab3fc32519 Mon Sep 17 00:00:00 2001 From: Chris Caron Date: Fri, 3 Jan 2020 09:30:54 -0500 Subject: [PATCH 2/2] README references Docker Pulls --- Dockerfile | 12 ++++++------ README.md | 38 ++++++++++++++++++++++++++------------ 2 files changed, 32 insertions(+), 18 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8de5fd7..044a6da 100644 --- a/Dockerfile +++ b/Dockerfile @@ -30,18 +30,18 @@ RUN curl -fL -o /tmp/s6-overlay.tar.gz \ ENV S6_KEEP_ENV=1 \ S6_CMD_WAIT_FOR_SERVICES=1 -# set work directory -WORKDIR /opt/apprise - # Copy our static content in place COPY apprise_api/static /usr/share/nginx/html/s/ -# Copy over Apprise API -COPY apprise_api/ webapp - # System Configuration COPY etc /etc/ +# set work directory +WORKDIR /opt/apprise + +# Copy over Apprise API +COPY apprise_api/ webapp + # gunicorn to expose on port 8080 # nginx to expose on port 8000 # disable logging on gunicorn diff --git a/README.md b/README.md index 3fb38ca..70e8375 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,8 @@ Take advantage of [Apprise](https://github.com/caronc/apprise) through your netw Apprise API was designed to easily fit into existing (and new) eco-systems that are looking for a simple notification solution. [![Paypal](https://img.shields.io/badge/paypal-donate-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=MHANV39UZNQ5E) -[![Discord](https://img.shields.io/discord/558793703356104724.svg?colorB=7289DA&label=Discord&logo=Discord&logoColor=7289DA&style=flat-square)](https://discord.gg/MMPeN2D) +[![Discord](https://img.shields.io/discord/558793703356104724.svg?colorB=7289DA&label=Discord&logo=Discord&logoColor=7289DA&style=flat-square)](https://discord.gg/MMPeN2D)
+[![Docker Pulls](https://img.shields.io/docker/pulls/caronc/apprise.svg?style=flat-square)](https://hub.docker.com/r/caronc/apprise) ## Screenshots There is a small built-in *Configuration Manager* that can be accesed using `/cfg/{KEY}`:
@@ -18,6 +19,30 @@ There is a small built-in *Configuration Manager* that can be accesed using `/cf Below is a screenshot of how you can set either a series of URL's to your `{KEY}`, or set your YAML and/or TEXT configuration below. ![Screenshot of GUI - Configuration](https://raw.githubusercontent.com/caronc/apprise-api/master/Screenshot-2.png) +## Installation +The following options should allow you to access the API at: `http://localhost:8000/` from your browser. + +Using [dockerhub](https://hub.docker.com/r/caronc/apprise), you can do the following: +```bash +# Retrieve container +docker pull caronc/apprise:latest + +# Start it up: +# /config is used for a persistent store, you do not have to mount +# this if you don't intend to use it. +docker run --name apprise \ + -p 8000:8000 \ + -v /var/lib/apprise/config:/config \ + -d caronc/apprise:latest +``` + +A `docker-compose.yml` file is already set up to grant you an instant production ready simulated environment: + +```bash +# Docker Compose +docker-compose up +``` + ## API Details | Path | Description | @@ -49,17 +74,6 @@ The use of environment variables allow you to provide over-rides to default sett | `DEBUG` | This defaults to `False` however can be set to `True`if defined with a non-zero value (such as `1`). -## Container Support - -A `docker-compose.yml` file is already set up to grant you an instant production ready simulated environment: - -```bash -# Docker Compose -docker-compose up -``` - -You can now access the API at: `http://localhost:8000/` from your browser. - ## Development Environment The following should get you a working development environment to test with: