mirror of
https://github.com/caronc/apprise-api.git
synced 2025-01-31 10:01:34 +01:00
Rework of Dockerfile and multiarch build with workflows (#23)
This commit is contained in:
parent
6f165aff43
commit
696b20cd91
63
.github/workflows/build.yml
vendored
Normal file
63
.github/workflows/build.yml
vendored
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
name: Build Apprise API image
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: container-rework
|
||||||
|
tags:
|
||||||
|
- v*
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
buildx:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
-
|
||||||
|
name: Prepare
|
||||||
|
id: prepare
|
||||||
|
run: |
|
||||||
|
DOCKER_IMAGE=georgegedox/apprise-api
|
||||||
|
DOCKER_PLATFORMS=linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/386
|
||||||
|
VERSION=edge
|
||||||
|
|
||||||
|
if [[ $GITHUB_REF == refs/tags/* ]]; then
|
||||||
|
VERSION=${GITHUB_REF#refs/tags/v}
|
||||||
|
fi
|
||||||
|
|
||||||
|
TAGS="--tag ${DOCKER_IMAGE}:${VERSION}"
|
||||||
|
if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
|
||||||
|
TAGS="$TAGS --tag ${DOCKER_IMAGE}:latest"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ::set-output name=docker_image::${DOCKER_IMAGE}
|
||||||
|
echo ::set-output name=version::${VERSION}
|
||||||
|
echo ::set-output name=buildx_args::--platform ${DOCKER_PLATFORMS} \
|
||||||
|
--build-arg VERSION=${VERSION} \
|
||||||
|
--build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \
|
||||||
|
--build-arg VCS_REF=${GITHUB_SHA::8} \
|
||||||
|
${TAGS} .
|
||||||
|
-
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
uses: crazy-max/ghaction-docker-buildx@v3
|
||||||
|
-
|
||||||
|
name: Docker Buildx (build)
|
||||||
|
run: |
|
||||||
|
docker buildx build --output "type=image,push=false" ${{ steps.prepare.outputs.buildx_args }}
|
||||||
|
-
|
||||||
|
name: Login to DockerHub
|
||||||
|
if: success() && github.event_name != 'pull_request'
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
-
|
||||||
|
name: Docker Buildx (push)
|
||||||
|
if: success() && github.event_name != 'pull_request'
|
||||||
|
run: |
|
||||||
|
docker buildx build --output "type=image,push=true" ${{ steps.prepare.outputs.buildx_args }}
|
||||||
|
-
|
||||||
|
name: Inspect image
|
||||||
|
if: always() && github.event_name != 'pull_request'
|
||||||
|
run: |
|
||||||
|
docker buildx imagetools inspect ${{ steps.prepare.outputs.docker_image }}:${{ steps.prepare.outputs.version }}
|
41
Dockerfile
41
Dockerfile
@ -1,5 +1,5 @@
|
|||||||
# Use the standard Nginx image from Docker Hub
|
ARG ARCH
|
||||||
FROM nginx
|
FROM ${ARCH}python:3.8-slim
|
||||||
|
|
||||||
# set version label
|
# set version label
|
||||||
ARG BUILD_DATE
|
ARG BUILD_DATE
|
||||||
@ -12,28 +12,23 @@ ENV PYTHONDONTWRITEBYTECODE 1
|
|||||||
ENV PYTHONUNBUFFERED 1
|
ENV PYTHONUNBUFFERED 1
|
||||||
ENV APPRISE_CONFIG_DIR /config
|
ENV APPRISE_CONFIG_DIR /config
|
||||||
|
|
||||||
# Install Python Dependencies
|
# Install requirements and gunicorn
|
||||||
COPY ./requirements.txt etc/requirements.txt
|
COPY ./requirements.txt /etc/requirements.txt
|
||||||
|
RUN pip3 install -r /etc/requirements.txt gunicorn
|
||||||
|
|
||||||
# Install Python
|
# Install nginx and supervisord
|
||||||
RUN apt-get update && \
|
RUN apt-get update && \
|
||||||
apt-get install -y curl python3 python3-pip && \
|
apt-get install -y nginx supervisor
|
||||||
pip3 install -r etc/requirements.txt gunicorn
|
|
||||||
|
|
||||||
# Install s6-overlay
|
# Nginx configuration
|
||||||
RUN curl -fL -o /tmp/s6-overlay.tar.gz \
|
RUN echo "daemon off;" >> /etc/nginx/nginx.conf
|
||||||
https://github.com/just-containers/s6-overlay/releases/download/v1.22.1.0/s6-overlay-amd64.tar.gz \
|
COPY /etc/nginx.conf /etc/nginx/conf.d/nginx.conf
|
||||||
&& tar -xzf /tmp/s6-overlay.tar.gz -C / \
|
|
||||||
&& rm -rf /tmp/*
|
|
||||||
|
|
||||||
ENV S6_KEEP_ENV=1 \
|
|
||||||
S6_CMD_WAIT_FOR_SERVICES=1
|
|
||||||
|
|
||||||
# Copy our static content in place
|
# Copy our static content in place
|
||||||
COPY apprise_api/static /usr/share/nginx/html/s/
|
COPY apprise_api/static /usr/share/nginx/html/s/
|
||||||
|
|
||||||
# System Configuration
|
# Supervisor configuration
|
||||||
COPY etc /etc/
|
COPY /etc/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
||||||
|
|
||||||
# set work directory
|
# set work directory
|
||||||
WORKDIR /opt/apprise
|
WORKDIR /opt/apprise
|
||||||
@ -41,16 +36,10 @@ WORKDIR /opt/apprise
|
|||||||
# Copy over Apprise API
|
# Copy over Apprise API
|
||||||
COPY apprise_api/ webapp
|
COPY apprise_api/ webapp
|
||||||
|
|
||||||
# gunicorn to expose on port 8080
|
# Change port of gunicorn
|
||||||
# nginx to expose on port 8000
|
RUN sed -i -e 's/:8000/:8080/g' /opt/apprise/webapp/gunicorn.conf.py
|
||||||
# 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
|
EXPOSE 8000
|
||||||
VOLUME /config
|
VOLUME /config
|
||||||
|
|
||||||
ENTRYPOINT ["/init"]
|
CMD ["/usr/bin/supervisord"]
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
# pull official base image
|
|
||||||
FROM python:3.8.0-alpine
|
|
||||||
|
|
||||||
# set work directory
|
|
||||||
WORKDIR /opt/apprise
|
|
||||||
|
|
||||||
# set environment variables
|
|
||||||
ENV PYTHONDONTWRITEBYTECODE 1
|
|
||||||
ENV PYTHONUNBUFFERED 1
|
|
||||||
ENV APPRISE_CONFIG_DIR /var/apprise/config
|
|
||||||
|
|
||||||
# install dependencies
|
|
||||||
RUN pip install --upgrade pip
|
|
||||||
COPY ./requirements.txt etc/requirements.txt
|
|
||||||
RUN pip install -r etc/requirements.txt \
|
|
||||||
gunicorn
|
|
||||||
|
|
||||||
# copy project
|
|
||||||
COPY apprise_api/ webapp
|
|
||||||
|
|
||||||
EXPOSE 8000
|
|
||||||
CMD ["gunicorn", "-c", "/opt/apprise/webapp/gunicorn.conf.py", "core.wsgi"]
|
|
@ -1,8 +0,0 @@
|
|||||||
# pull official base image
|
|
||||||
FROM nginx
|
|
||||||
|
|
||||||
# Copy our customized NginX configuration (for container usage)
|
|
||||||
COPY etc/nginx /etc/nginx/
|
|
||||||
|
|
||||||
# Copy our static content in place
|
|
||||||
COPY apprise_api/static /usr/share/nginx/html/s/
|
|
@ -1,19 +1,8 @@
|
|||||||
version: '3.3'
|
version: '3'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
backend:
|
apprise:
|
||||||
build:
|
build: .
|
||||||
context: .
|
container_name: apprise
|
||||||
dockerfile: Dockerfile-gunicorn
|
|
||||||
volumes:
|
|
||||||
- ./var:/var/apprise
|
|
||||||
restart: always
|
|
||||||
|
|
||||||
frontend:
|
|
||||||
build:
|
|
||||||
context: .
|
|
||||||
dockerfile: Dockerfile-nginx
|
|
||||||
ports:
|
ports:
|
||||||
- "8000:80"
|
- 8000:8000
|
||||||
links:
|
|
||||||
- backend
|
|
@ -1,13 +1,5 @@
|
|||||||
|
|
||||||
# The backend API server
|
|
||||||
upstream apprise_backend {
|
|
||||||
server backend:8000 fail_timeout=0;
|
|
||||||
}
|
|
||||||
|
|
||||||
server {
|
server {
|
||||||
listen 80;
|
listen 8000;
|
||||||
server_name _;
|
|
||||||
charset utf-8;
|
|
||||||
|
|
||||||
# Main Website
|
# Main Website
|
||||||
location / {
|
location / {
|
||||||
@ -16,7 +8,7 @@ server {
|
|||||||
proxy_set_header X-Real-IP $remote_addr;
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
proxy_set_header X-Forwarded-Proto $scheme;
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
proxy_pass http://apprise_backend;
|
proxy_pass http://localhost:8080;
|
||||||
# Give ample time for notifications to fire
|
# Give ample time for notifications to fire
|
||||||
proxy_read_timeout 120s;
|
proxy_read_timeout 120s;
|
||||||
}
|
}
|
||||||
@ -35,4 +27,4 @@ server {
|
|||||||
location = /50x.html {
|
location = /50x.html {
|
||||||
root /usr/share/nginx/html;
|
root /usr/share/nginx/html;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,31 +0,0 @@
|
|||||||
#
|
|
||||||
# Apprise Docker NginX Configuration
|
|
||||||
#
|
|
||||||
error_log /dev/stdout info;
|
|
||||||
|
|
||||||
user nginx;
|
|
||||||
worker_processes 1;
|
|
||||||
pid /var/run/nginx.pid;
|
|
||||||
|
|
||||||
|
|
||||||
events {
|
|
||||||
worker_connections 1024;
|
|
||||||
}
|
|
||||||
|
|
||||||
http {
|
|
||||||
include /etc/nginx/mime.types;
|
|
||||||
default_type application/octet-stream;
|
|
||||||
|
|
||||||
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
|
||||||
'$status $body_bytes_sent "$http_referer" '
|
|
||||||
'"$http_user_agent" "$http_x_forwarded_for"';
|
|
||||||
|
|
||||||
access_log /dev/stdout main;
|
|
||||||
sendfile on;
|
|
||||||
#tcp_nopush on;
|
|
||||||
|
|
||||||
keepalive_timeout 65;
|
|
||||||
gzip on;
|
|
||||||
|
|
||||||
include /etc/nginx/conf.d/*.conf;
|
|
||||||
}
|
|
@ -1,5 +0,0 @@
|
|||||||
#!/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
|
|
@ -1,3 +0,0 @@
|
|||||||
#!/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
|
|
@ -1,5 +0,0 @@
|
|||||||
#!/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
|
|
@ -1,3 +0,0 @@
|
|||||||
#!/usr/bin/with-contenv sh
|
|
||||||
echo >&2 "Starting nginx"
|
|
||||||
nginx -g 'daemon off;'
|
|
17
etc/supervisord.conf
Normal file
17
etc/supervisord.conf
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
[supervisord]
|
||||||
|
nodaemon=true
|
||||||
|
|
||||||
|
[program:nginx]
|
||||||
|
command=/usr/sbin/nginx
|
||||||
|
stdout_logfile=/dev/stdout
|
||||||
|
stdout_logfile_maxbytes=0
|
||||||
|
stderr_logfile=/dev/stderr
|
||||||
|
stderr_logfile_maxbytes=0
|
||||||
|
|
||||||
|
[program:gunicorn]
|
||||||
|
command=gunicorn -c /opt/apprise/webapp/gunicorn.conf.py --worker-tmp-dir /dev/shm core.wsgi
|
||||||
|
directory=/opt/apprise/webapp
|
||||||
|
stdout_logfile=/dev/stdout
|
||||||
|
stdout_logfile_maxbytes=0
|
||||||
|
stderr_logfile=/dev/stderr
|
||||||
|
stderr_logfile_maxbytes=0
|
Loading…
Reference in New Issue
Block a user